-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
51 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 18 additions & 30 deletions
48
dom/nodes/Node-appendChild-three-scripts-from-fragment.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |