Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk committed Dec 13, 2019
1 parent 6e91fd9 commit 1ba9f9c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 71 deletions.
26 changes: 15 additions & 11 deletions dom/nodes/Node-appendChild-text-in-script.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@
<div id="log"></div>
<script id="script"></script>
<script>
var script = document.getElementById("script");
var scriptRan = false;

var df = document.createDocumentFragment();
df.appendChild(new Text(";"));
df.appendChild(new Text("scriptRan = true;"));

assert_false(scriptRan, "script ran");
script.appendChild(df);
assert_true(scriptRan, "script did not run completely");
done();
const happened = [];
test(() => {
const script = document.getElementById("script");
const df = document.createDocumentFragment();
df.appendChild(new Text("happened.push('t1');"));
df.appendChild(new Text("happened.push('t2');"));
assert_array_equals(happened, []);
script.appendChild(df);
assert_array_equals(happened, ["t1", "t2"]);
// At this point it's already executed so further motifications are a no-op
script.appendChild(new Text("happened.push('t3');"));
script.textContent = "happened.push('t4');"
script.text = "happened.push('t5');"
assert_array_equals(happened, ["t1", "t2"]);
});
</script>
48 changes: 18 additions & 30 deletions dom/nodes/Node-appendChild-three-scripts-from-fragment.html
Original file line number Diff line number Diff line change
@@ -1,44 +1,32 @@
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting three scripts from a document 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>
</head>
<body>
<div id="log"></div>
<script>
var s1 = document.createElement("script");
var s2 = document.createElement("script");
var s3 = document.createElement("script");
const s1 = document.createElement("script");
const s2 = document.createElement("script");
const s3 = document.createElement("script");
const happened = [];

var s1Ran = false;
s1.textContent = `
s3.appendChild(new Text("s3Ran = true;"));
assert_true(s3Ran, "s3 did not run");
s1Ran = true;
test(() => {
s1.textContent = `
s3.appendChild(new Text("happened.push('s3');"));
happened.push("s1");
`;

var s2Ran = false;
s2.textContent = `
assert_true(s1Ran, "s1 did not run");
s2Ran = true;
`;

var s3Ran = false;
s3.textContent = `
assert_false(s1Ran, "s1 already ran");
s2.textContent = `
happened.push("s2");
`;
const df = document.createDocumentFragment();
df.appendChild(s1);
df.appendChild(s2);
df.appendChild(s3);

var df = document.createDocumentFragment();
df.appendChild(s1);
df.appendChild(s2);
df.appendChild(s3);

assert_false(s1Ran, "s1 ran");
document.body.appendChild(df);
assert_true(s2Ran, "s2 did not run");
done();
assert_array_equals(happened, []);
document.body.appendChild(df);
assert_array_equals(happened, ["s3", "s1", "s2"]);
});
</script>
48 changes: 18 additions & 30 deletions dom/nodes/Node-appendChild-three-scripts.html
Original file line number Diff line number Diff line change
@@ -1,44 +1,32 @@
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting three scripts from a div</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>
</head>
<body>
<div id="log"></div>
<script>
var s1 = document.createElement("script");
var s2 = document.createElement("script");
var s3 = document.createElement("script");
const s1 = document.createElement("script");
const s2 = document.createElement("script");
const s3 = document.createElement("script");
const happened = [];

var s1Ran = false;
s1.textContent = `
s3.appendChild(new Text("s3Ran = true;"));
assert_true(s3Ran, "s3 did not run");
s1Ran = true;
test(() => {
s1.textContent = `
s3.appendChild(new Text("happened.push('s3');"));
happened.push("s1");
`;

var s2Ran = false;
s2.textContent = `
assert_true(s1Ran, "s1 did not run");
s2Ran = true;
`;

var s3Ran = false;
s3.textContent = `
assert_false(s1Ran, "s1 already ran");
s2.textContent = `
happened.push("s2");
`;
const div = document.createElement("div");
div.appendChild(s1);
div.appendChild(s2);
div.appendChild(s3);

var div = document.createElement("div");
div.appendChild(s1);
div.appendChild(s2);
div.appendChild(s3);

assert_false(s1Ran, "s1 ran");
document.body.appendChild(div);
assert_true(s2Ran, "s2 did not run");
done();
assert_array_equals(happened, []);
document.body.appendChild(div);
assert_array_equals(happened, ["s3", "s1", "s2"]);
});
</script>

0 comments on commit 1ba9f9c

Please sign in to comment.