Skip to content

Commit

Permalink
Test inserting text and script nodes in a style element
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Feb 11, 2019
1 parent 0f95919 commit 0253b2a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions dom/nodes/Node-appendChild-text-and-script-in-style.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting text and script nodes in a style element</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>
<body></body>
<div id="log"></div>
<style id="style"></style>
<script>
var style = document.getElementById("style");

var r1 = new Text("body {}");
var r2 = new Text("body {}");

var script = document.createElement("script");
var scriptRan = false;
script.textContent = `
assert_not_equals(style.sheet, null, "style sheet is not created");
assert_equals(style.sheet.cssRules.length, 2, "style sheet does not have two rules");
scriptRan = true;
`;

var df = document.createDocumentFragment();
df.appendChild(r1);
df.appendChild(script);
df.appendChild(r2);

assert_false(scriptRan, "script ran");
style.appendChild(df);
assert_true(scriptRan, "script did not run");
done();
</script>

0 comments on commit 0253b2a

Please sign in to comment.