diff options
author | Nigel Tao <nigeltao@golang.org> | 2011-10-19 08:03:30 +1100 |
---|---|---|
committer | Nigel Tao <nigeltao@golang.org> | 2011-10-19 08:03:30 +1100 |
commit | 56074dd79bb043d1e1e48441244810dff2b2d849 (patch) | |
tree | 70dc9013dd20eb0d1f9f9b88798993229ebe921e /src/pkg/html/token_test.go | |
parent | 8e40f471f616f9e181da7493965609598d386602 (diff) | |
download | go-56074dd79bb043d1e1e48441244810dff2b2d849.tar.gz |
html: parse raw text and RCDATA elements, such as <script> and <title>.
Pass tests1.dat, test 26:
#data
<script><div></script></div><title><p></title><p><p>
#document
| <html>
| <head>
| <script>
| "<div>"
| <title>
| "<p>"
| <body>
| <p>
| <p>
Thanks to Andy Balholm for driving this change.
R=andybalholm
CC=golang-dev
http://codereview.appspot.com/5301042
Diffstat (limited to 'src/pkg/html/token_test.go')
-rw-r--r-- | src/pkg/html/token_test.go | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/pkg/html/token_test.go b/src/pkg/html/token_test.go index 2bd87e912..310cd97d6 100644 --- a/src/pkg/html/token_test.go +++ b/src/pkg/html/token_test.go @@ -174,6 +174,77 @@ var tokenTests = []tokenTest{ `<p id="0"</p>`, `<p id="0" <="" p="">`, }, + // Raw text and RCDATA. + { + "basic raw text", + "<script><a></b></script>", + "<script>$<a></b>$</script>", + }, + { + "unfinished script end tag", + "<SCRIPT>a</SCR", + "<script>$a</SCR", + }, + { + "broken script end tag", + "<SCRIPT>a</SCR ipt>", + "<script>$a</SCR ipt>", + }, + { + "EOF in script end tag", + "<SCRIPT>a</SCRipt", + "<script>$a</SCRipt", + }, + { + "scriptx end tag", + "<SCRIPT>a</SCRiptx", + "<script>$a</SCRiptx", + }, + { + "' ' completes script end tag", + "<SCRIPT>a</SCRipt ", + "<script>$a$</script>", + }, + { + "'>' completes script end tag", + "<SCRIPT>a</SCRipt>", + "<script>$a$</script>", + }, + { + "self-closing script end tag", + "<SCRIPT>a</SCRipt/>", + "<script>$a$</script>", + }, + { + "nested script tag", + "<SCRIPT>a</SCRipt<script>", + "<script>$a</SCRipt<script>", + }, + { + "script end tag after unfinished", + "<SCRIPT>a</SCRipt</script>", + "<script>$a</SCRipt$</script>", + }, + { + "script/style mismatched tags", + "<script>a</style>", + "<script>$a</style>", + }, + { + "style element with entity", + "<style>'", + "<style>$&apos;", + }, + { + "textarea with tag", + "<textarea><div></textarea>", + "<textarea>$<div>$</textarea>", + }, + { + "title with tag and entity", + "<title><b>K&R C</b></title>", + "<title>$<b>K&R C</b>$</title>", + }, // DOCTYPE tests. { "Proper DOCTYPE", |