1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
<!doctype html>
<title>DeferAllScript: document.write()</title>
<html>
<head>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
const t1 = async_test("document.write()");
const t2 = async_test("document.write(),close()");
const t3 = async_test("document.open(),write()");
const t4 = async_test("document.open(),write(),close()");
function finish() {
const expected = ["Inline1", "Sync2", "Async1", "Sync1",
"EndOfBody", "DOMContentLoaded", "WindowLoad"];
t1.step_func_done(() => {
assert_array_equals(
document.getElementById("document-write").contentWindow.result,
expected,
"Execution order");
})();
t2.step_func_done(() => {
assert_array_equals(
document.getElementById("document-write-close").contentWindow.result,
expected,
"Execution order");
})();
t3.step_func_done(() => {
assert_array_equals(
document.getElementById("document-open-write").contentWindow.result,
expected,
"Execution order");
})();
t4.step_func_done(() => {
assert_array_equals(
document.getElementById(
"document-open-write-close").contentWindow.result,
expected,
"Execution order");
})();
// For cases where documents are kept open, call `document.close()` here
// to finish the test harness.
for (const iframe of document.querySelectorAll("iframe")) {
iframe.contentDocument.close();
}
}
// For cases where documents are kept open (that should never occur in
// non-intervention cases), schedule `finish()` because Window load events
// might be not fired.
setTimeout(finish, 5000);
</script>
</head>
<body onload="finish()">
<iframe id="document-write"
src="resources/document-write-iframe.sub.html?script=document-write.js"></iframe>
<iframe id="document-write-close"
src="resources/document-write-iframe.sub.html?script=document-write-close.js"></iframe>
<iframe id="document-open-write"
src="resources/document-write-iframe.sub.html?script=document-open-write.js"></iframe>
<iframe id="document-open-write-close"
src="resources/document-write-iframe.sub.html?script=document-open-write-close.js"></iframe>
</body>
</html>
|