mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 18:26:15 +00:00
Bug 1591761 - parseXULToFragment should throw a clearer exception for non-well-formed markup. r=bgrins
*** Bug 1591671, revert a breaking change in calling DOMParser. Differential Revision: https://phabricator.services.mozilla.com/D50729 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
c092a45ba0
commit
0e30d06762
@ -521,6 +521,11 @@
|
||||
`,
|
||||
"application/xml"
|
||||
);
|
||||
|
||||
if (doc.documentElement.localName === "parsererror") {
|
||||
throw new Error("not well-formed XML");
|
||||
}
|
||||
|
||||
// The XUL/XBL parser is set to ignore all-whitespace nodes, whereas (X)HTML
|
||||
// does not do this. Most XUL code assumes that the whitespace has been
|
||||
// stripped out, so we simply remove all text nodes after using the parser.
|
||||
|
@ -121,6 +121,15 @@
|
||||
is(boxWithWhitespaceText.textContent, "", "Whitespace removed");
|
||||
let boxWithNonWhitespaceText = MozXULElement.parseXULToFragment(`<box>foo</box>`).querySelector("box");
|
||||
is(boxWithNonWhitespaceText.textContent, "foo", "Non-whitespace not removed");
|
||||
|
||||
try {
|
||||
// we didn't encode the & as &
|
||||
MozXULElement.parseXULToFragment(`<box id="foo=1&bar=2"/>`);
|
||||
ok(false, "parseXULToFragment should've thrown an exception for not-well-formed XML");
|
||||
}
|
||||
catch (ex) {
|
||||
is(ex.message, "not well-formed XML", "parseXULToFragment threw the wrong message");
|
||||
}
|
||||
}
|
||||
|
||||
function testInheritAttributes() {
|
||||
|
Loading…
Reference in New Issue
Block a user