Skip to content

Commit

Permalink
Test that createContextualFragment works on a variety of contexts
Browse files Browse the repository at this point in the history
As discovered and discussed in whatwg/html#2221 (comment) , some browsers have a blocklist here that seems historical and not supported by any spec.

The same blocklist is shared by innerText (tested in #3491) and outerText (not tested as it's not yet standard).
  • Loading branch information
domenic authored Jan 10, 2017
1 parent 4451bd8 commit b3163fb
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions domparsing/createContextualFragment.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,45 @@
assert_true(passed, "Fragment created and added to document, should run");
}, "<script>s should be run when appended to the document (but not before)");

// Historical bugs in browsers; see https://github.com/whatwg/html/issues/2222

[
// Void
"area",
"base",
"basefont",
"bgsound",
"br",
"col",
"embed",
"frame",
"hr",
"img",
"input",
"keygen",
"link",
"meta",
"param",
"source",
"track",
"wbr",

// Historical
"menuitem",
"image"
].forEach(name => {
test(() => {
const range = document.createRange();
const contextNode = document.createElement(name);
const selectedNode = document.createElement("div");
contextNode.appendChild(selectedNode);
range.selectNode(selectedNode);

range.createContextualFragment("some text");
}, `createContextualFragment should work even when the context is <${name}>`);
});


// Now that we've established basic sanity, let's do equivalence tests. Those
// are easier to write anyway.
function testEquivalence(element1, fragment1, element2, fragment2) {
Expand Down

0 comments on commit b3163fb

Please sign in to comment.