Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk committed Apr 2, 2020
1 parent 72b2112 commit 43076fa
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 182 deletions.
33 changes: 14 additions & 19 deletions dom/nodes/Node-appendChild-script-and-iframe-from-fragment.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting script and iframe 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>
<div id="log"></div>
</head>
<body>
<script>
var iframe = document.createElement("iframe");
iframe.src = "data:text/html,"
let happened = [];
const iframe = document.createElement("iframe");
test(() => {
iframe.src = "data:text/html,"

var script = document.createElement("script");
var scriptRan = false;
script.textContent = `
assert_not_equals(iframe.contentWindow, null, "iframe does not have a content window");
scriptRan = true;
const script = document.createElement("script");
script.textContent = `
happened.push(iframe.contentWindow === null);
`;

var df = document.createDocumentFragment();
df.appendChild(script);
df.appendChild(iframe);
const df = document.createDocumentFragment();
df.appendChild(script);
df.appendChild(iframe);

assert_false(scriptRan, "script ran");
document.body.appendChild(df);
assert_true(scriptRan, "script has not run");
done();
assert_array_equals(happened, []);
document.body.appendChild(df);
assert_array_equals(happened, [false])
});
</script>
34 changes: 15 additions & 19 deletions dom/nodes/Node-appendChild-script-and-iframe.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting script and iframe 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>
<div id="log"></div>
</head>
<body>
<script>
var iframe = document.createElement("iframe");
iframe.src = "data:text/html,"
const happened = [];
const iframe = document.createElement("iframe");

var script = document.createElement("script");
var scriptRan = false;
script.textContent = `
assert_not_equals(iframe.contentWindow, null, "iframe does not have a content window");
scriptRan = true;
test(() => {
iframe.src = "data:text/html,"

const script = document.createElement("script");
script.textContent = `
happened.push(iframe.contentWindow === null);
`;

var div = document.createElement("div");
div.appendChild(script);
div.appendChild(iframe);
const div = document.createElement("div");
div.appendChild(script);
div.appendChild(iframe);

assert_false(scriptRan, "script ran");
document.body.appendChild(div);
assert_true(scriptRan, "script has not run");
done();
assert_array_equals(happened, []);
document.body.appendChild(div);
assert_array_equals(happened, [false])
});
</script>
39 changes: 14 additions & 25 deletions dom/nodes/Node-appendChild-script-and-source-from-fragment.html
Original file line number Diff line number Diff line change
@@ -1,37 +1,26 @@
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting script and source 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>
<div id="log"></div>
</head>
<body>
<video id="media"></video>
<script>
var media = document.getElementById("media");

var source = document.createElement("source");

var script = document.createElement("script");
var scriptRan = false;
script.textContent = `
assert_equals(
media.networkState,
HTMLMediaElement.NETWORK_NO_SOURCE,
"resource selection did not start",
);
scriptRan = true;
const happened = [];
const media = document.getElementById("media");
test(() => {
const source = document.createElement("source");
const script = document.createElement("script");
script.textContent = `
happened.push(media.networkState);
`;

var df = document.createDocumentFragment();
df.appendChild(script);
df.appendChild(source);
const df = document.createDocumentFragment();
df.appendChild(script);
df.appendChild(source);

assert_false(scriptRan, "script ran");
media.appendChild(df);
assert_true(scriptRan, "script has not run");
done();
assert_array_equals(happened, []);
media.appendChild(df);
assert_array_equals(happened, [HTMLMediaElement.NETWORK_NO_SOURCE]);
});
</script>
42 changes: 17 additions & 25 deletions dom/nodes/Node-appendChild-script-and-style-from-fragment.html
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting a script and a style 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>
<body></body>
<div id="log"></div>
<script>
var style = document.createElement("style");
var styleSheet = null;
style.appendChild(new Text("body {}"));

var script = document.createElement("script");
var scriptRan = false;
script.textContent = `
assert_equals(style.sheet, null, "style sheet is created");
const happened = []
const style = document.createElement("style");
let styleSheet = null;
test(() => {
style.appendChild(new Text("body {}"));
const script = document.createElement("script");
script.textContent = `
happened.push(style.sheet === null);
style.appendChild(new Text("body {}"));
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");
happened.push(style.sheet.cssRules.length);
styleSheet = style.sheet;
scriptRan = true;
`;

var df = document.createDocumentFragment();
df.appendChild(script);
df.appendChild(style);
const df = document.createDocumentFragment();
df.appendChild(script);
df.appendChild(style);

assert_false(scriptRan, "script ran");
document.body.appendChild(df);
assert_true(scriptRan, "script did not run");
assert_not_equals(style.sheet, styleSheet, "style sheet was created only once");
done();
assert_array_equals(happened, []);
document.body.appendChild(df);
assert_array_equals(happened, [true, 2]);
assert_not_equals(style.sheet, styleSheet, "style sheet was created only once");
});
</script>
40 changes: 16 additions & 24 deletions dom/nodes/Node-appendChild-script-and-style.html
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting a script and a style where the script modifies the style</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>
<script>
var style = document.createElement("style");
var styleSheet = null;
const happened = [];
const style = document.createElement("style");
let styleSheet = null;
test(() => {
style.appendChild(new Text("body {}"));

var script = document.createElement("script");
var scriptRan = false;
script.textContent = `
assert_equals(style.sheet, null, "style sheet is created");
const script = document.createElement("script");
script.textContent = `
happened.push(style.sheet === null);
style.appendChild(new Text("body {}"));
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");
happened.push(style.sheet.cssRules.length);
styleSheet = style.sheet;
scriptRan = true;
`;

var div = document.createElement("div");
div.appendChild(script);
div.appendChild(style);
const div = document.createElement("div");
div.appendChild(script);
div.appendChild(style);

assert_false(scriptRan, "script ran");
document.body.appendChild(div);
assert_true(scriptRan, "script did not run");
assert_not_equals(style.sheet, styleSheet, "style sheet was created only once");
done();
assert_array_equals(happened, []);
document.body.appendChild(div);
assert_array_equals(happened, [true, 2]);
assert_not_equals(style.sheet, styleSheet, "style sheet was created only once");
});
</script>
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting script and stylesheet link 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">
<title>Node.appendChild: inserting script and stylesheet link from a fragment</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id="log"></div>
</head>
<body>
<script>
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = "data:text/css,"
const happened = [];
const link = document.createElement("link");
test(() => {
link.rel = "stylesheet";
link.href = "data:text/css,"

var script = document.createElement("script");
var scriptRan = false;
script.textContent = `
assert_not_equals(link.sheet, null, "link does not have a stylesheet");
scriptRan = true;
const script = document.createElement("script");
script.textContent = `
happened.push(link.sheet === null);
`;

var df = document.createDocumentFragment();
df.appendChild(script);
df.appendChild(link);
const df = document.createDocumentFragment();
df.appendChild(script);
df.appendChild(link);

assert_false(scriptRan, "script ran");
document.body.appendChild(df);
assert_true(scriptRan, "script has not run");
done();
assert_array_equals(happened, []);
document.body.appendChild(df);
assert_array_equals(happened, [true]);
});
</script>
35 changes: 15 additions & 20 deletions dom/nodes/Node-appendChild-script-and-stylesheet-link.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting script and stylesheet link 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>
<div id="log"></div>
</head>
<body>
<script>
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = "data:text/css,"
const happened = [];
const link = document.createElement("link");
test(() => {
link.rel = "stylesheet";
link.href = "data:text/css,"

var script = document.createElement("script");
var scriptRan = false;
script.textContent = `
assert_not_equals(link.sheet, null, "link does not have a stylesheet");
scriptRan = true;
const script = document.createElement("script");
script.textContent = `
happened.push(link.sheet === null);
`;

var div = document.createElement("div");
div.appendChild(script);
div.appendChild(link);
const div = document.createElement("div");
div.appendChild(script);
div.appendChild(link);

assert_false(scriptRan, "script ran");
document.body.appendChild(div);
assert_true(scriptRan, "script has not run");
done();
assert_array_equals(happened, []);
document.body.appendChild(div);
assert_array_equals(happened, [true]);
});
</script>
Loading

0 comments on commit 43076fa

Please sign in to comment.