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 e1715b2 commit 7cab7bb
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 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,34 @@
<!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);

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

0 comments on commit 7cab7bb

Please sign in to comment.