зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1491035 [wpt PR 12989] - Insert an error message block when parsing was stopped after an error, a=testonly
Automatic update from web-platform-testsInsert an error message block when parsing was stopped after an error The <parsererror> element was not being added to the parsed document in certain cases involving attribute parsing. For example, if an undeclared namespace prefix was used in the document, then parsing would stop, but a <parsererror> element would not be inserted into the document to indicate that a parsing error occurred. When XMLDocumentParser::StopParsing() is called to stop parsing, call InsertErrorMessageBlock() to insert the <parsererror> element if an error occurred. Based on https://codereview.chromium.org/771493002/ by dtrebbien@gmail.com Bug: 295809, 898775 Change-Id: Ic67a3ab885fae4b01ca92f6d927b3f523f7423ed Reviewed-on: https://chromium-review.googlesource.com/c/1224791 Commit-Queue: Fredrik Söderquist <fs@opera.com> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/master@{#602674} -- wpt-commits: f10f0251a051a0aff6f7b5d15e0c821d173ae837 wpt-pr: 12989
This commit is contained in:
Родитель
1ea2834a0b
Коммит
a972b9fd54
|
@ -0,0 +1,38 @@
|
|||
<!DOCTYPE html>
|
||||
<title>DOMParser: <parsererror> element added on error</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<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';
|
||||
|
||||
[
|
||||
'<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 => {
|
||||
test(() => {
|
||||
var document_string = xhtml_prologue + fragment + xhtml_epilogue;
|
||||
var doc = (new DOMParser).parseFromString(document_string, "application/xhtml+xml");
|
||||
var parsererrors = doc.getElementsByTagName("parsererror");
|
||||
assert_equals(parsererrors.length, 1, 'expecting one parsererror');
|
||||
}, document.title + ', ' + fragment);
|
||||
});
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче