Skip to content

Commit

Permalink
rewrite first four files to work again
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk committed Dec 9, 2019
1 parent 005ed5e commit 6e91fd9
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 88 deletions.
37 changes: 15 additions & 22 deletions dom/nodes/Node-appendChild-script-and-button-from-div.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting script and button 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>
<form id="form"></form>
<script>
var form = document.getElementById("form");

var script = document.createElement("script");
var scriptRan = false;
script.textContent = `
assert_equals(button.form, form, "button does not have a form owner");
scriptRan = true;
let button = null;
let buttonForm = null;
test(() => {
const form = document.getElementById("form");
const script = document.createElement("script");
script.textContent = `
buttonForm = button.form;
`;

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

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


assert_false(scriptRan, "script ran");
form.appendChild(div);
assert_true(scriptRan, "script has not run");
done();
button = document.createElement("button");
const div = document.createElement("div");
div.appendChild(script);
div.appendChild(button);
assert_equals(buttonForm, null);
form.appendChild(div);
assert_equals(buttonForm, form);
});
</script>
40 changes: 18 additions & 22 deletions dom/nodes/Node-appendChild-script-and-custom-from-fragment.html
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting script and custom element from a DocumentFragment</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>
<script>
var script = document.createElement("script");
var scriptRan = false;
script.textContent = `
customElements.define("custom-element", CustomElement);
assert_true(customConstructed, "custom element was not constructed");
scriptRan = true;
`;

var custom = document.createElement("custom-element");
var customConstructed = false;
let customConstructed = false;
let isCustomConstructed = false;
class CustomElement extends HTMLElement {
constructor() {
super();
customConstructed = true;
}
}

var df = document.createDocumentFragment();
df.appendChild(script);
df.appendChild(custom);

assert_false(scriptRan, "script ran");
document.head.appendChild(df);
assert_true(scriptRan, "script has not run");
done();
test(() => {
const script = document.createElement("script");
script.textContent = `
customElements.define("custom-element", CustomElement);
isCustomConstructed = customConstructed;
`;
const custom = document.createElement("custom-element");
const df = document.createDocumentFragment();
df.appendChild(script);
df.appendChild(custom);
assert_false(customConstructed);
assert_false(isCustomConstructed);
document.head.appendChild(df);
assert_true(customConstructed);
assert_true(isCustomConstructed);
});
</script>
Original file line number Diff line number Diff line change
@@ -1,39 +1,34 @@
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting script and default-style meta 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>
<link rel="stylesheet" href="data:text/css,">
<link rel="alternate stylesheet" title="alternative" href="data:text/css,%23div{display:none}">
</head>
<body>
<div id="log"></div>
<div id="div">hello</div>
<script>
var div = document.getElementById("div");

var meta = document.createElement("meta");
meta.httpEquiv = "default-style";
meta.content = "alternative";

var script = document.createElement("script");
var scriptRan = false;
script.textContent = `
assert_equals(getComputedStyle(div).display, "none", "div is still visible");
let scriptRan = false;
let computedStyle = null;
test(() => {
const div = document.getElementById("div");
const meta = document.createElement("meta");
meta.httpEquiv = "default-style";
meta.content = "alternative";
const script = document.createElement("script");
script.textContent = `
computedStyle = getComputedStyle(div).display;
scriptRan = true;
`;

var df = document.createDocumentFragment();
df.appendChild(script);
df.appendChild(meta);

assert_equals(getComputedStyle(div).display, "block", "div is not a block");
assert_false(scriptRan, "script ran");
document.head.appendChild(df);
assert_true(scriptRan, "script has not run");
assert_equals(getComputedStyle(div).display, "none", "div is still visible after insertion");
done();
const df = document.createDocumentFragment();
df.appendChild(script);
df.appendChild(meta);
assert_equals(getComputedStyle(div).display, "block", "div is not a block");
assert_false(scriptRan, "script ran");
document.head.appendChild(df);
assert_true(scriptRan, "script has not run");
assert_equals(computedStyle, "none", "div is still visible");
assert_equals(getComputedStyle(div).display, "none", "div is still visible after insertion");
});
</script>
38 changes: 19 additions & 19 deletions dom/nodes/Node-appendChild-script-and-div-from-fragment.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting script and div from a DocumentFragment</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>
<script>
var script = document.createElement("script");
var div = document.createElement("div");

var scriptRan = false;
script.textContent = `
assert_equals(div.parentNode, script.parentNode, "div does not have same parent as script");
scriptRan = true;
let script = null;
let scriptParent = null;
let div = null;
let divParent = null;
test(() => {
script = document.createElement("script");
div = document.createElement("div");
script.textContent = `
divParent = div.parentNode;
scriptParent = script.parentNode;
`;

var df = document.createDocumentFragment();
df.appendChild(script);
df.appendChild(div);

assert_false(scriptRan, "script ran");
document.head.appendChild(df);
assert_true(scriptRan, "script did not run");
done();
const df = document.createDocumentFragment();
df.appendChild(script);
df.appendChild(div);
assert_equals(divParent, null);
assert_equals(scriptParent, null);
document.head.appendChild(df);
assert_equals(divParent, scriptParent);
assert_equals(divParent, document.head);
});
</script>

0 comments on commit 6e91fd9

Please sign in to comment.