Skip to content

Commit

Permalink
Test inserting a script and a default-style meta
Browse files Browse the repository at this point in the history
  • Loading branch information
nox authored and annevk committed Dec 9, 2019
1 parent 074d3e8 commit 005ed5e
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting script and default-style meta from a fragment</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-node-appendChild">
<link rel=help href="https://dom.spec.whatwg.org/#concept-node-insert">
<link rel=help href="https://github.com/whatwg/dom/issues/575">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<link rel="stylesheet" href="data:text/css,">
<link rel="alternate stylesheet" title="alternative" href="data:text/css,%23div{display:none}">
</head>
<body>
<div id="log"></div>
<div id="div">hello</div>
<script>
var div = document.getElementById("div");

var meta = document.createElement("meta");
meta.httpEquiv = "default-style";
meta.content = "alternative";

var script = document.createElement("script");
var scriptRan = false;
script.textContent = `
assert_equals(getComputedStyle(div).display, "none", "div is still visible");
scriptRan = true;
`;

var df = document.createDocumentFragment();
df.appendChild(script);
df.appendChild(meta);

assert_equals(getComputedStyle(div).display, "block", "div is not a block");
assert_false(scriptRan, "script ran");
document.head.appendChild(df);
assert_true(scriptRan, "script has not run");
assert_equals(getComputedStyle(div).display, "none", "div is still visible after insertion");
done();
</script>

0 comments on commit 005ed5e

Please sign in to comment.