mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision 60220357131c65146444da1f54624d5b54d0975d
This commit is contained in:
parent
c45192614c
commit
775b784f79
2144 changed files with 58115 additions and 29658 deletions
|
@ -0,0 +1,20 @@
|
|||
<!doctype html>
|
||||
<title>Replacement of window object after document.open</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe></iframe>
|
||||
<script>
|
||||
var t = async_test();
|
||||
|
||||
onload = t.step_func(function() {
|
||||
var iframe = document.getElementsByTagName("iframe")[0];
|
||||
iframe.contentWindow.state = 1;
|
||||
var handle = iframe.contentWindow;
|
||||
iframe.contentDocument.open();
|
||||
assert_false("state" in iframe.contentWindow, "Variables are not preserved after document.open");
|
||||
assert_equals(iframe.contentWindow.state, undefined, "Variables are not preserved after document.open");
|
||||
assert_equals(iframe.contentWindow, handle);
|
||||
t.done();
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,12 @@
|
|||
<!doctype html>
|
||||
<title>document.open during parsing</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
test(function() {
|
||||
var log = document.getElementById("log");
|
||||
document.open()
|
||||
assert_equals(document.getElementById("log"), log)
|
||||
})
|
||||
</script>
|
|
@ -0,0 +1 @@
|
|||
<!doctype html>
|
|
@ -0,0 +1,19 @@
|
|||
<!doctype html>
|
||||
<title>Reuse of document object after document.open</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="004-1.html"></iframe>
|
||||
<script>
|
||||
var t = async_test();
|
||||
var iframe;
|
||||
onload = t.step_func(function() {
|
||||
var iframe = document.getElementsByTagName("iframe")[0];
|
||||
var handle = iframe.contentDocument;
|
||||
iframe.contentDocument.test_state = 1;
|
||||
iframe.contentDocument.open();
|
||||
assert_equals(iframe.contentDocument.test_state, 1);
|
||||
assert_equals(iframe.contentDocument, handle);
|
||||
t.done();
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,16 @@
|
|||
<!doctype html>
|
||||
<title>Cancelling timeout after document.open</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="004-1.html"></iframe>
|
||||
<script>
|
||||
var t = async_test();
|
||||
var iframe;
|
||||
onload = t.step_func(function() {
|
||||
var iframe = document.getElementsByTagName("iframe")[0];
|
||||
iframe.contentWindow.setTimeout(t.step_func(function() {assert_unreached()}), 100);
|
||||
iframe.contentDocument.open()
|
||||
setTimeout(function() {t.done();}, 200);
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,19 @@
|
|||
<!doctype html>
|
||||
<title>Cancelling error after document.open</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="004-1.html"></iframe>
|
||||
<script>
|
||||
var t = async_test();
|
||||
var iframe;
|
||||
onload = t.step_func(function() {
|
||||
var iframe = document.getElementsByTagName("iframe")[0];
|
||||
var img = iframe.contentDocument.createElement("img");
|
||||
img.onerror = t.step_func(function() {assert_unreached()})
|
||||
img.src = "missing";
|
||||
iframe.contentDocument.body.appendChild(img);
|
||||
iframe.contentDocument.open()
|
||||
setTimeout(function() {t.done();}, 500);
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,19 @@
|
|||
<!doctype html>
|
||||
<title>Unregistering event handlers after document.open</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="004-1.html"></iframe>
|
||||
<script>
|
||||
var t = async_test();
|
||||
var iframe;
|
||||
onload = t.step_func(function() {
|
||||
var iframe = document.getElementsByTagName("iframe")[0];
|
||||
iframe.contentDocument.onclick = t.step_func(function() {assert_unreached()})
|
||||
iframe.contentDocument.open();
|
||||
var e = iframe.contentDocument.createEvent("mouseevents")
|
||||
e.initEvent("click", false, false);
|
||||
iframe.contentDocument.dispatchEvent(e);
|
||||
setTimeout(function() {t.done();}, 500);
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,20 @@
|
|||
<!doctype html>
|
||||
<title>Replacement of document prototype object after document.open</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="004-1.html"></iframe>
|
||||
<script>
|
||||
var t = async_test();
|
||||
var iframe;
|
||||
onload = t.step_func(function() {
|
||||
var iframe = document.getElementsByTagName("iframe")[0];
|
||||
var handle = Object.getPrototypeOf(iframe.contentDocument);
|
||||
handle.test_state = 1;
|
||||
iframe.contentDocument.open();
|
||||
var new_handle = Object.getPrototypeOf(iframe.contentDocument);
|
||||
assert_equals(new_handle.test_state, undefined);
|
||||
assert_not_equals(new_handle, handle);
|
||||
t.done();
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,34 @@
|
|||
<!doctype html>
|
||||
<title>document.open replacing singleton</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="004-1.html"></iframe>
|
||||
<script>
|
||||
var iframe = document.getElementsByTagName("iframe")[0];
|
||||
var steps;
|
||||
iframe.onload = function() {
|
||||
steps = ["window", "location", "history", "navigator", "applicationCache", "sessionStorage", "localStorage", "locationbar"].map(
|
||||
function(x) {
|
||||
var t = async_test(document.title + " " + x);
|
||||
var handle = iframe.contentWindow[x];
|
||||
handle.test_state = 1;
|
||||
return t.step_func(
|
||||
function() {
|
||||
var new_handle = iframe.contentWindow[x];
|
||||
assert_equals(new_handle.test_state, undefined);
|
||||
if (x !== "window") {
|
||||
assert_not_equals(new_handle, handle);
|
||||
} else {
|
||||
assert_equals(new_handle, handle);
|
||||
}
|
||||
t.done();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
onload = function() {
|
||||
iframe.contentDocument.open();
|
||||
steps.forEach(function(x) {x()});
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,2 @@
|
|||
<!doctype html>
|
||||
010-1
|
|
@ -0,0 +1,5 @@
|
|||
<!doctype html>
|
||||
010-2
|
||||
<script>
|
||||
onload = function() {history.back()}
|
||||
</script>
|
|
@ -0,0 +1,22 @@
|
|||
<!doctype html>
|
||||
<title>Salvagability of document.opened document</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="010-1.html"></iframe>
|
||||
<script>
|
||||
var iframe;
|
||||
var t = async_test();
|
||||
onload = t.step_func(function() {
|
||||
iframe = document.getElementsByTagName("iframe")[0];
|
||||
iframe.contentDocument.open();
|
||||
iframe.contentDocument.close();
|
||||
|
||||
iframe.contentWindow.setTimeout(t.step_func(function() {t.done();}), 500);
|
||||
|
||||
onload = null;
|
||||
|
||||
iframe.src = "010-2.html"
|
||||
setTimeout(t.step_func(function() {assert_unreached()}), 1000)
|
||||
})
|
||||
</script>
|
|
@ -0,0 +1,5 @@
|
|||
<script>
|
||||
document.open()
|
||||
setTimeout(parent.t.step_func(function() {parent.t.done()}), 0);
|
||||
document.close();
|
||||
</script>
|
|
@ -0,0 +1,9 @@
|
|||
<!doctype html>
|
||||
<title>Timeout after document.open</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var t = async_test();
|
||||
</script>
|
||||
<iframe src="011-1.html"></iframe>
|
|
@ -0,0 +1,7 @@
|
|||
<script>
|
||||
onload = parent.t.step_func(function() {
|
||||
document.open()
|
||||
setTimeout(parent.t.step_func(function() {parent.t.done()}), 0);
|
||||
document.close();
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,9 @@
|
|||
<!doctype html>
|
||||
<title>Timeout after document.open in load event</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var t = async_test();
|
||||
</script>
|
||||
<iframe src="012-1.html"></iframe>
|
|
@ -0,0 +1,7 @@
|
|||
<script>
|
||||
addEventListener("DOMContentLoaded", parent.t.step_func(function() {
|
||||
document.open()
|
||||
setTimeout(parent.t.step_func(function() {parent.t.done()}), 0);
|
||||
document.close();
|
||||
}), false);
|
||||
</script>
|
|
@ -0,0 +1,9 @@
|
|||
<!doctype html>
|
||||
<title>Timeout after document.open in DOMContentLoaded event</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var t = async_test();
|
||||
</script>
|
||||
<iframe src="013-1.html"></iframe>
|
|
@ -0,0 +1,9 @@
|
|||
<script>
|
||||
onload = parent.t.step_func(function() {
|
||||
setTimeout(parent.t.step_func(function() {
|
||||
document.open()
|
||||
setTimeout(parent.t.step_func(function() {parent.t.done()}), 0);
|
||||
document.close();
|
||||
}), 100)
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,9 @@
|
|||
<!doctype html>
|
||||
<title>Timeout after document.open after document is completely loaded</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var t = async_test();
|
||||
</script>
|
||||
<iframe src="014-1.html"></iframe>
|
|
@ -0,0 +1,17 @@
|
|||
<script>
|
||||
onload = function() {
|
||||
window.test_prop = 1;
|
||||
parent.tests[0].step(function() {parent.assert_equals(test_prop, 1)});
|
||||
document.open();
|
||||
document.write("<script>test_prop = 2;<\/script>");
|
||||
document.close();
|
||||
parent.tests[0].step(function() {parent.assert_equals(test_prop, 1)});
|
||||
parent.tests[1].step(function() {parent.assert_equals(window.test_prop, 2)});
|
||||
parent.tests[2].step(function() {parent.assert_equals(get_this(), window)});
|
||||
parent.tests_done();
|
||||
};
|
||||
|
||||
function get_this() {
|
||||
return this;
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,14 @@
|
|||
<!doctype html>
|
||||
<title>Window vs global scope after document.open</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var tests = [async_test("global scope unchanged"),
|
||||
async_test("window object changed"),
|
||||
async_test("this is the window object")];
|
||||
function tests_done() {
|
||||
tests.forEach(function(t) {t.done()});
|
||||
}
|
||||
</script>
|
||||
<iframe src="015-1.html"></iframe>
|
|
@ -0,0 +1,39 @@
|
|||
<script>
|
||||
window.test_prop = 1;
|
||||
</script>
|
||||
<script>
|
||||
onload = function() {
|
||||
document.open();
|
||||
document.write("<script>test_prop = 2; timeout_fired=false;<\/script>");
|
||||
document.close();
|
||||
|
||||
setTimeout(function() {
|
||||
parent.tests[0].step(function() {
|
||||
parent.assert_equals(test_prop, 1, "Global scope from original window timeout");
|
||||
parent.assert_equals(window.test_prop, 2, "Window property from original window timeout")
|
||||
});
|
||||
parent.tests[1].step(function() {
|
||||
var t = get_this();
|
||||
parent.assert_equals(t.test_prop, 2, "Window property from original window timeout");
|
||||
parent.assert_equals(t, window, "Global scope from original window timeout");
|
||||
});
|
||||
}, 0);
|
||||
|
||||
window.setTimeout(function() {
|
||||
parent.tests[2].step(function() {
|
||||
parent.assert_equals(test_prop, 1, "Global scope from original window timeout");
|
||||
parent.assert_equals(window.test_prop, 2, "Window property from original window timeout")
|
||||
});
|
||||
parent.tests[3].step(function() {
|
||||
var t = get_this();
|
||||
parent.assert_equals(t.test_prop, 2, "Window property from original window timeout");
|
||||
parent.assert_equals(t, window, "Global scope from original window timeout");
|
||||
});
|
||||
parent.tests_done();
|
||||
}, 100);
|
||||
};
|
||||
|
||||
function get_this() {
|
||||
return this;
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,15 @@
|
|||
<!doctype html>
|
||||
<title>setTimeout document.open</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var tests = [async_test("Timeout on original window, scope"),
|
||||
async_test("Timeout on original window, this object"),
|
||||
async_test("Timeout on new window, scope"),
|
||||
async_test("Timeout on new window, this object")];
|
||||
function tests_done() {
|
||||
tests.forEach(function(t) {t.done()});
|
||||
}
|
||||
</script>
|
||||
<iframe src="016-1.html"></iframe>
|
|
@ -0,0 +1,28 @@
|
|||
// document.open() bails out early if there is an **active parser** with
|
||||
// non-zero script nesting level. window.stop() aborts the current parser and
|
||||
// makes it no longer active, and should allow document.open() to work.
|
||||
// For more details, see https://bugzilla.mozilla.org/show_bug.cgi?id=1475000.
|
||||
|
||||
window.handlers = {};
|
||||
|
||||
async_test(t => {
|
||||
const frame = document.body.appendChild(document.createElement("iframe"));
|
||||
frame.src = "resources/aborted-parser-frame.html";
|
||||
window.handlers.afterOpen = t.step_func_done(() => {
|
||||
const openCalled = frame.contentDocument.childNodes.length === 0;
|
||||
frame.remove();
|
||||
assert_true(openCalled, "child document should be empty");
|
||||
});
|
||||
}, "document.open() after parser is aborted");
|
||||
|
||||
// Note: This test should pass even if window.close() is not there, as
|
||||
// document.open() is not executed synchronously in an inline script.
|
||||
async_test(t => {
|
||||
const frame = document.body.appendChild(document.createElement("iframe"));
|
||||
frame.src = "resources/aborted-parser-async-frame.html";
|
||||
window.handlers.afterOpenAsync = t.step_func_done(() => {
|
||||
const openCalled = frame.contentDocument.childNodes.length === 0;
|
||||
frame.remove();
|
||||
assert_true(openCalled, "child document should be empty");
|
||||
});
|
||||
}, "async document.open() after parser is aborted");
|
|
@ -0,0 +1,39 @@
|
|||
// The document open steps have:
|
||||
//
|
||||
// 2. If document's throw-on-dynamic-markup-insertion counter is greater than
|
||||
// 0, then throw an "InvalidStateError" DOMException.
|
||||
//
|
||||
// The throw-on-dynamic-markup-insertion counter is only incremented when the
|
||||
// parser creates a custom element, not when createElement is called. Test for
|
||||
// this.
|
||||
//
|
||||
// See: https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#document-open-steps
|
||||
|
||||
const noError = Symbol("no error");
|
||||
let err = noError;
|
||||
|
||||
class CustomElement extends HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
try {
|
||||
document.open();
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
customElements.define("custom-element", CustomElement);
|
||||
|
||||
test(t => {
|
||||
err = noError;
|
||||
document.createElement("custom-element");
|
||||
assert_equals(err, noError);
|
||||
}, "document.open() works in custom element constructor for createElement()");
|
||||
|
||||
test(t => {
|
||||
err = noError;
|
||||
document.write("<custom-element></custom-element>");
|
||||
assert_throws("InvalidStateError", () => {
|
||||
throw err;
|
||||
});
|
||||
}, "document.open() is forbidden in custom element constructor when creating element from parser");
|
|
@ -0,0 +1,19 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>document.open in XHTML</title>
|
||||
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#opening-the-input-stream"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
test(function() {
|
||||
assert_throws("INVALID_STATE_ERR", function() {
|
||||
document.open();
|
||||
}, "document.open in XHTML should throw an INVALID_STATE_ERR ");
|
||||
}, "document.open in XHTML");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<title>document.open with three arguments</title>
|
||||
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-open">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
function open() {
|
||||
assert_unreached("The call should be redirected to the real window.open")
|
||||
}
|
||||
test(function(t) {
|
||||
var w;
|
||||
t.add_cleanup(function() {try {w.close()} catch(e) {}});
|
||||
w = document.open("/resources/testharness.js", "", "");
|
||||
assert_true(w instanceof w.Window, "Expected a window");
|
||||
}, "document.open should redirect to window.open when called with three arguments");
|
||||
|
||||
test(function() {
|
||||
var parser = new DOMParser();
|
||||
var doc = parser.parseFromString("", "text/html");
|
||||
assert_equals(doc.defaultView, null);
|
||||
assert_throws("INVALID_ACCESS_ERR", function() {
|
||||
doc.open("/resources/testharness.js", "", "");
|
||||
});
|
||||
}, "document.open should throw when it has no window and is called with three arguments");
|
||||
</script>
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<script>
|
||||
onload = function() {
|
||||
document.open();
|
||||
document.close();
|
||||
parent.report(window.setTimeout === setTimeout, false, "setTimeout");
|
||||
parent.report(window === this, true, "this");
|
||||
parent.done();
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<title>document.open and singleton replacement</title>
|
||||
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-open">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var t = async_test();
|
||||
function report(actual, expected, message) {
|
||||
t.step(function() {
|
||||
assert_equals(actual, expected, message);
|
||||
});
|
||||
}
|
||||
function done() {
|
||||
t.done();
|
||||
}
|
||||
</script>
|
||||
<iframe src=document.open-03-frame.html></iframe>
|
|
@ -0,0 +1,12 @@
|
|||
async_test(t => {
|
||||
const frame = document.body.appendChild(document.createElement("iframe"));
|
||||
frame.src = "resources/encoding-frame.html";
|
||||
frame.onload = t.step_func_done(t => {
|
||||
// Using toLowerCase() to avoid an Edge bug
|
||||
assert_equals(frame.contentDocument.characterSet.toLowerCase(), "shift_jis", "precondition");
|
||||
frame.contentDocument.open();
|
||||
assert_equals(frame.contentDocument.characterSet.toLowerCase(), "shift_jis", "actual test");
|
||||
frame.contentDocument.close();
|
||||
assert_equals(frame.contentDocument.characterSet.toLowerCase(), "shift_jis", "might as well");
|
||||
});
|
||||
}, "doucment.open() and the document's encoding");
|
|
@ -0,0 +1,42 @@
|
|||
test(t => {
|
||||
const frame = document.body.appendChild(document.createElement("iframe")),
|
||||
body = frame.contentDocument.body;
|
||||
t.add_cleanup(() => frame.remove());
|
||||
frame.contentDocument.addEventListener("x", t.unreached_func("document event listener not removed"));
|
||||
body.addEventListener("x", t.unreached_func("body event listener not removed"));
|
||||
frame.contentDocument.open();
|
||||
frame.contentDocument.dispatchEvent(new Event("x"));
|
||||
body.dispatchEvent(new Event("x"));
|
||||
frame.contentDocument.close();
|
||||
}, "Event listeners are to be removed");
|
||||
|
||||
test(t => {
|
||||
const frame = document.body.appendChild(document.createElement("iframe"));
|
||||
t.add_cleanup(() => frame.remove());
|
||||
let once = false;
|
||||
frame.contentDocument.addEventListener("x", () => {
|
||||
frame.contentDocument.open();
|
||||
once = true;
|
||||
});
|
||||
frame.contentDocument.addEventListener("x", t.unreached_func("second event listener not removed"));
|
||||
frame.contentDocument.dispatchEvent(new Event("x"));
|
||||
assert_true(once);
|
||||
frame.contentDocument.close();
|
||||
}, "Event listeners are to be removed with immediate effect");
|
||||
|
||||
test(t => {
|
||||
const frame = document.body.appendChild(document.createElement("iframe")),
|
||||
shadow = frame.contentDocument.body.attachShadow({ mode: "closed" }),
|
||||
shadowChild = shadow.appendChild(document.createElement("div")),
|
||||
shadowShadow = shadowChild.attachShadow({ mode: "open" }),
|
||||
nodes = [shadow, shadowChild, shadowShadow];
|
||||
t.add_cleanup(() => frame.remove());
|
||||
nodes.forEach(node => {
|
||||
node.addEventListener("x", t.unreached_func(node + "'s event listener not removed"));
|
||||
});
|
||||
frame.contentDocument.open();
|
||||
nodes.forEach(node => {
|
||||
node.dispatchEvent(new Event("x"));
|
||||
});
|
||||
frame.contentDocument.close();
|
||||
}, "Event listeners are to be removed from shadow trees as well");
|
|
@ -0,0 +1,22 @@
|
|||
// In an ideal world this test would eventually be obsolete due to mutation events disappearing. Or
|
||||
// would have to change to account for mutation events not firing synchronously. Neither seems
|
||||
// realistic to the author though.
|
||||
|
||||
test(t => {
|
||||
const frame = document.body.appendChild(document.createElement("iframe"));
|
||||
frame.contentWindow.addEventListener("DOMNodeInserted", t.unreached_func());
|
||||
frame.contentWindow.addEventListener("DOMNodeInserted", t.unreached_func(), true);
|
||||
frame.contentWindow.addEventListener("DOMNodeInsertedIntoDocument", t.unreached_func(), true);
|
||||
frame.contentWindow.addEventListener("DOMNodeRemoved", t.unreached_func());
|
||||
frame.contentWindow.addEventListener("DOMNodeRemoved", t.unreached_func(), true);
|
||||
frame.contentWindow.addEventListener("DOMNodeRemovedFromDocument", t.unreached_func(), true);
|
||||
frame.contentWindow.addEventListener("DOMSubtreeModified", t.unreached_func());
|
||||
frame.contentWindow.addEventListener("DOMSubtreeModified", t.unreached_func(), true);
|
||||
assert_equals(frame.contentDocument.documentElement.localName, "html");
|
||||
frame.contentDocument.open();
|
||||
assert_equals(frame.contentDocument.documentElement, null);
|
||||
frame.contentDocument.write("<div>heya</div>");
|
||||
frame.contentDocument.close();
|
||||
assert_equals(frame.contentDocument.documentElement.localName, "html");
|
||||
frame.remove();
|
||||
}, "document.open(), the HTML parser, and mutation events");
|
|
@ -0,0 +1,9 @@
|
|||
<!doctype html>
|
||||
<p>Text</p>
|
||||
<script>
|
||||
window.stop();
|
||||
parent.step_timeout(() => {
|
||||
document.open();
|
||||
parent.handlers.afterOpenAsync();
|
||||
}, 10);
|
||||
</script>
|
|
@ -0,0 +1,7 @@
|
|||
<!doctype html>
|
||||
<p>Text</p>
|
||||
<script>
|
||||
window.stop();
|
||||
document.open();
|
||||
parent.handlers.afterOpen();
|
||||
</script>
|
|
@ -0,0 +1,3 @@
|
|||
<!doctype html>
|
||||
<meta charset=ms932>
|
||||
<p>Encoded in Shift_JIS.</p>
|
|
@ -0,0 +1 @@
|
|||
Some text.
|
|
@ -0,0 +1,23 @@
|
|||
["replace",
|
||||
"NOBODY",
|
||||
"@ FD ;",
|
||||
"it does not matter, you see \f",
|
||||
"text/plain",
|
||||
"text/xml",
|
||||
"application/octet-stream",
|
||||
"\0"].forEach(type => {
|
||||
async_test(t => {
|
||||
const frame = document.createElement("iframe");
|
||||
frame.src = "type-argument-plaintext-subframe.txt";
|
||||
document.body.appendChild(frame);
|
||||
t.add_cleanup(() => frame.remove());
|
||||
frame.onload = t.step_func_done(() => {
|
||||
frame.contentDocument.open(type);
|
||||
frame.contentDocument.write("<B>heya</b>");
|
||||
frame.contentDocument.close();
|
||||
assert_equals(frame.contentDocument.body.firstChild.localName, "b");
|
||||
assert_equals(frame.contentDocument.body.textContent, "heya");
|
||||
assert_equals(frame.contentDocument.contentType, "text/plain");
|
||||
});
|
||||
}, "document.open() on plaintext document with type set to: " + type + " (type argument is supposed to be ignored)");
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
["replace",
|
||||
"NOBODY",
|
||||
"@ FD ;",
|
||||
"it does not matter, you see \f",
|
||||
"text/plain",
|
||||
"text/xml",
|
||||
"application/octet-stream",
|
||||
"\0"].forEach(type => {
|
||||
async_test(t => {
|
||||
const frame = document.body.appendChild(document.createElement("iframe"));
|
||||
t.add_cleanup(() => frame.remove());
|
||||
frame.contentDocument.open(type);
|
||||
frame.contentDocument.write("<B>heya</b>");
|
||||
frame.contentDocument.close();
|
||||
assert_equals(frame.contentDocument.body.firstChild.localName, "b");
|
||||
assert_equals(frame.contentDocument.body.textContent, "heya");
|
||||
assert_equals(frame.contentDocument.contentType, "text/html");
|
||||
t.done();
|
||||
}, "document.open() with type set to: " + type + " (type argument is supposed to be ignored)");
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue