forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb: Test for parseFromString parsererror
This tests if the parsed xml string gets tagged with a parsererror. (cherry picked from commit 64308c8c065206e129a9642b73bee813239a916b)
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
Tests/LibWeb/Text/expected/DOM/domparser-parsefromstring-xml-parsererror.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<span x:test="testing">1</span> has 1 parseerror | ||
< span>2</span> has 1 parseerror | ||
<span :test="testing">3</span> has 1 parseerror | ||
<span><em>4</span></em> has 1 parseerror | ||
<span>5 has 1 parseerror | ||
6</span> has 1 parseerror | ||
<span>7< /span> has 1 parseerror | ||
<span>8</ span> has 1 parseerror | ||
<span novalue>9</span> has 1 parseerror | ||
<span ="noattr">10</span> has 1 parseerror | ||
<span ::="test">11</span> has 1 parseerror | ||
<span xmlns:="urn:x-test:test">12</span> has 1 parseerror | ||
<span xmlns:xmlns="">13</span> has 1 parseerror | ||
<span data-test=testing>14</span> has 1 parseerror | ||
15<span has 1 parseerror | ||
<8:test xmlns:8="urn:x-test:test">16</8:test> has 1 parseerror | ||
<span xmlns:p1 xmlns:p2="urn:x-test:test"/>17 has 1 parseerror | ||
text/xml has 1 parseerror | ||
application/xml has 1 parseerror | ||
application/xhtml+xml has 1 parseerror | ||
image/svg+xml has 1 parseerror |
47 changes: 47 additions & 0 deletions
47
Tests/LibWeb/Text/input/DOM/domparser-parsefromstring-xml-parsererror.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
<script src="../include.js"></script> | ||
<link rel="match" href="reference/domparser-parsefromstring-xml-parsererror.html" /> | ||
<script> | ||
const xhtml_prologue = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"' + | ||
' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n' + | ||
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n' + | ||
'<body>\n', | ||
xhtml_epilogue = '</body>\n</html>\n'; | ||
test(() => { | ||
[ | ||
'<span x:test="testing">1</span>', // undeclared 'x' namespace prefix | ||
'< span>2</span>', // bad start tag | ||
'<span :test="testing">3</span>', // empty namespace prefix | ||
'<span><em>4</span></em>', // staggered tags | ||
'<span>5', // missing end </span> tag | ||
'6</span>', // missing start <span> tag | ||
'<span>7< /span>', // bad end tag | ||
'<span>8</ span>', // bad end tag | ||
'<span novalue>9</span>', // missing attribute value | ||
'<span ="noattr">10</span>', // missing attribute name | ||
'<span ::="test">11</span>', // bad namespace prefix | ||
'<span xmlns:="urn:x-test:test">12</span>', // missing namespace prefix | ||
'<span xmlns:xmlns="">13</span>', // invalid namespace prefix | ||
'<span data-test=testing>14</span>', // unquoted attribute value | ||
'15<span', // bad start tag | ||
'<8:test xmlns:8="urn:x-test:test">16</8:test>', // invalid namespace prefix | ||
'<span xmlns:p1 xmlns:p2="urn:x-test:test"/>17', // missing namespace URI | ||
].forEach((fragment, i) => { | ||
var document_string = xhtml_prologue + fragment + xhtml_epilogue; | ||
var doc = (new DOMParser).parseFromString(document_string, "application/xhtml+xml"); | ||
var parsererrors = doc.getElementsByTagName("parsererror"); | ||
println(`${fragment} has ${parsererrors.length} parseerror`); | ||
}); | ||
|
||
[ | ||
'text/xml', | ||
'application/xml', | ||
'application/xhtml+xml', | ||
'image/svg+xml' | ||
].forEach(mimeType => { | ||
const doc = (new DOMParser()).parseFromString('<span x:test="testing">1</span>', mimeType); | ||
var parsererrors = doc.getElementsByTagName("parsererror"); | ||
println(`${mimeType} has ${parsererrors.length} parseerror`); | ||
}); | ||
}); | ||
</script> |