-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
4 changed files
with
42 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>document.interactive, document.contentLoaded, and document.loaded when document.open() happens inside DOMContentLoaded</title> | ||
<title>document.parsed, document.contentLoaded, and document.loaded when document.open() happens inside DOMContentLoaded</title> | ||
<link rel="author" title="Domenic Denicola" href="mailto:[email protected]"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-interactive"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-parsed"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-contentloaded"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-loaded"> | ||
<script src="/resources/testharness.js"></script> | ||
|
@@ -16,19 +16,19 @@ | |
"use strict"; | ||
|
||
async_test(t => { | ||
let contentDoc, interactiveBefore, contentLoadedBefore, loadedBefore; | ||
let contentDoc, parsedBefore, contentLoadedBefore, loadedBefore; | ||
const fulfilled1 = []; | ||
const fulfilled2 = []; | ||
|
||
window.onload = t.step_func(() => { | ||
contentDoc = frames[0].document; | ||
|
||
interactiveBefore = contentDoc.interactive; | ||
parsedBefore = contentDoc.parsed; | ||
contentLoadedBefore = contentDoc.contentLoaded; | ||
loadedBefore = contentDoc.loaded; | ||
|
||
contentDoc.interactive.then(() => { | ||
fulfilled1.push("interactive"); | ||
contentDoc.parsed.then(() => { | ||
fulfilled1.push("parsed"); | ||
}); | ||
contentDoc.contentLoaded.then(() => { | ||
fulfilled1.push("contentLoaded"); | ||
|
@@ -38,27 +38,27 @@ | |
}); | ||
|
||
contentDoc.addEventListener("DOMContentLoaded", t.step_func(() => { | ||
assert_equals(contentDoc.interactive, interactiveBefore, | ||
"document.interactive must not have changed by the time a DOMContentLoaded handler fires"); | ||
assert_equals(contentDoc.parsed, parsedBefore, | ||
"document.parsed must not have changed by the time a DOMContentLoaded handler fires"); | ||
assert_equals(contentDoc.contentLoaded, contentLoadedBefore, | ||
"document.contentLoaded must not have changed by the time a DOMContentLoaded handler fires"); | ||
assert_equals(contentDoc.loaded, loadedBefore, | ||
"document.loaded must not have changed by the time a DOMContentLoaded handler fires"); | ||
|
||
assert_array_equals(fulfilled1, ["interactive"], | ||
"Only interactive must have been fulfilled by the time the DOMContentLoaded handler fires"); | ||
assert_array_equals(fulfilled1, ["parsed"], | ||
"Only parsed must have been fulfilled by the time the DOMContentLoaded handler fires"); | ||
|
||
contentDoc.open(); | ||
|
||
assert_equals(contentDoc.readyState, "loading", "After document.open(), readyState must be loading"); | ||
|
||
assert_not_equals(contentDoc.interactive, interactiveBefore, "document.open() must reset document.interactive"); | ||
assert_not_equals(contentDoc.parsed, parsedBefore, "document.open() must reset document.parsed"); | ||
assert_not_equals(contentDoc.contentLoaded, contentLoadedBefore, | ||
"document.open() must reset document.contentLoaded"); | ||
assert_not_equals(contentDoc.loaded, loadedBefore, "document.open() must reset document.loaded"); | ||
|
||
contentDoc.interactive.then(() => { | ||
fulfilled2.push("interactive"); | ||
contentDoc.parsed.then(() => { | ||
fulfilled2.push("parsed"); | ||
}); | ||
contentDoc.contentLoaded.then(() => { | ||
fulfilled2.push("contentLoaded"); | ||
|
@@ -68,8 +68,8 @@ | |
}); | ||
|
||
t.step_timeout(() => { | ||
assert_array_equals(fulfilled1, ["interactive", "contentLoaded"], | ||
"Of the original promises, 10 ms after document.open(), interactive and contentLoaded must have fulfilled"); | ||
assert_array_equals(fulfilled1, ["parsed", "contentLoaded"], | ||
"Of the original promises, 10 ms after document.open(), parsed and contentLoaded must have fulfilled"); | ||
assert_array_equals(fulfilled2, [], "None of the new promises should be fulfilled 10 ms after document.open()"); | ||
|
||
contentDoc.close(); | ||
|
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,8 +1,8 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>document.interactive, document.contentLoaded, and document.loaded with document.open()</title> | ||
<title>document.parsed, document.contentLoaded, and document.loaded with document.open()</title> | ||
<link rel="author" title="Domenic Denicola" href="mailto:[email protected]"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-interactive"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-parsed"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-contentloaded"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-loaded"> | ||
<script src="/resources/testharness.js"></script> | ||
|
@@ -20,31 +20,31 @@ | |
} | ||
|
||
promise_test(() => { | ||
let contentDoc, interactiveBefore, contentLoadedBefore, loadedBefore; | ||
let contentDoc, parsedBefore, contentLoadedBefore, loadedBefore; | ||
const fulfilled = []; | ||
|
||
return loadPromise.then(() => { | ||
contentDoc = frames[0].document; | ||
|
||
interactiveBefore = contentDoc.interactive; | ||
parsedBefore = contentDoc.parsed; | ||
contentLoadedBefore = contentDoc.contentLoaded; | ||
loadedBefore = contentDoc.loaded; | ||
|
||
// Sanity check: they all work | ||
return Promise.all([interactiveBefore, contentLoadedBefore, loadedBefore]); | ||
return Promise.all([parsedBefore, contentLoadedBefore, loadedBefore]); | ||
}) | ||
.then(() => { | ||
contentDoc.open(); | ||
|
||
assert_equals(contentDoc.readyState, "loading", "After document.open(), readyState must be loading"); | ||
|
||
assert_not_equals(contentDoc.interactive, interactiveBefore, "document.open() must reset document.interactive"); | ||
assert_not_equals(contentDoc.parsed, parsedBefore, "document.open() must reset document.parsed"); | ||
assert_not_equals(contentDoc.contentLoaded, contentLoadedBefore, | ||
"document.open() must reset document.contentLoaded"); | ||
assert_not_equals(contentDoc.loaded, loadedBefore, "document.open() must reset document.loaded"); | ||
|
||
contentDoc.interactive.then(() => { | ||
fulfilled.push("interactive"); | ||
contentDoc.parsed.then(() => { | ||
fulfilled.push("parsed"); | ||
}); | ||
contentDoc.contentLoaded.then(() => { | ||
fulfilled.push("contentLoaded"); | ||
|
@@ -60,7 +60,7 @@ | |
|
||
contentDoc.close(); | ||
|
||
return Promise.all([contentDoc.interactive, contentDoc.contentLoaded, contentDoc.loaded]); | ||
return Promise.all([contentDoc.parsed, contentDoc.contentLoaded, contentDoc.loaded]); | ||
}); | ||
}); | ||
</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,8 +1,8 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>document.interactive, document.contentLoaded, and document.loaded</title> | ||
<title>document.parsed, document.contentLoaded, and document.loaded</title> | ||
<link rel="author" title="Domenic Denicola" href="mailto:[email protected]"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-interactive"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-parsed"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-contentloaded"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-loaded"> | ||
<script src="/resources/testharness.js"></script> | ||
|
@@ -15,11 +15,11 @@ | |
let onLoadFired = false; | ||
const readyStateChanges = []; | ||
|
||
let interactiveFulfilled = false; | ||
let parsedFulfilled = false; | ||
let contentLoadedFulfilled = false; | ||
let loadedFulfilled = false; | ||
|
||
let interactiveAssertions, contentLoadedAssertions, loadedAssertions; | ||
let parsedAssertions, contentLoadedAssertions, loadedAssertions; | ||
|
||
test(() => { | ||
document.addEventListener("readystatechange", () => { | ||
|
@@ -44,14 +44,14 @@ | |
// - *After* the callback runs, we perform a microtask checkpoint | ||
// - The microtask checkpoint calls onFulfilled | ||
|
||
interactiveAssertions = document.interactive.then(value => { | ||
interactiveFulfilled = true; | ||
parsedAssertions = document.parsed.then(value => { | ||
parsedFulfilled = true; | ||
|
||
assert_equals(value, undefined, "The document.interactive promise must fulfill with undefined"); | ||
assert_array_equals(readyStateChanges, ["interactive"], | ||
"Inside the document.interactive fulfillment handler, the readystatechange event must have fired once already"); | ||
assert_equals(value, undefined, "The document.parsed promise must fulfill with undefined"); | ||
assert_array_equals(readyStateChanges, ["parsed"], | ||
"Inside the document.parsed fulfillment handler, the readystatechange event must have fired once already"); | ||
assert_equals(document.readyState, "interactive", | ||
"Inside the document.interactive fulfillment handler, readyState must be interactive"); | ||
"Inside the document.parsed fulfillment handler, readyState must be interactive"); | ||
}); | ||
|
||
contentLoadedAssertions = document.contentLoaded.then(value => { | ||
|
@@ -60,12 +60,12 @@ | |
assert_equals(value, undefined, "The document.contentLoaded promise must fulfill with undefined"); | ||
assert_equals(document.readyState, "interactive", | ||
"Inside the document.contentLoaded fulfillment handler, readyState must be interactive"); | ||
assert_equals(interactiveFulfilled, true, | ||
"Inside the document.contentLoaded fulfillment handler, document.interactive must have already fulfilled"); | ||
assert_equals(parsedFulfilled, true, | ||
"Inside the document.contentLoaded fulfillment handler, document.parsed must have already fulfilled"); | ||
assert_equals(onDomContentLoadedFired, true, | ||
"Inside the document.contentLoaded fulfillment handler, DOMContentLoaded must have already fired"); | ||
assert_array_equals(readyStateChanges, ["interactive"], | ||
"Inside the document.interactive fulfillment handler, the readystatechange event must have fired exactly once"); | ||
"Inside the document.contentLoaded fulfillment handler, the readystatechange event must have fired exactly once"); | ||
}); | ||
|
||
loadedAssertions = document.loaded.then(value => { | ||
|
@@ -74,20 +74,20 @@ | |
assert_equals(value, undefined, "The document.loaded promise must fulfill with undefined"); | ||
assert_equals(document.readyState, "complete", | ||
"Inside the document.loaded fulfillment handler, readyState must be complete"); | ||
assert_equals(interactiveFulfilled, true, | ||
"Inside the document.loaded fulfillment handler, document.interactive must have already fulfilled"); | ||
assert_equals(parsedFulfilled, true, | ||
"Inside the document.loaded fulfillment handler, document.parsed must have already fulfilled"); | ||
assert_equals(contentLoadedFulfilled, true, | ||
"Inside the document.loaded fulfillment handler, document.contentLoaded must have already fulfilled"); | ||
assert_equals(onDomContentLoadedFired, true, | ||
"Inside the document.loaded fulfillment handler, DOMContentLoaded must have already fired"); | ||
assert_equals(onLoadFired, false, | ||
"Inside the document.loaded fulfillment handler, load must not have already fired"); | ||
assert_array_equals(readyStateChanges, ["interactive", "complete"], | ||
"Inside the document.interactive fulfillment handler, the readystatechange event must have fired exactly twice"); | ||
"Inside the document.loaded fulfillment handler, the readystatechange event must have fired exactly twice"); | ||
}); | ||
}, "Setup code"); | ||
|
||
promise_test(() => interactiveAssertions, "document.interactive"); | ||
promise_test(() => parsedAssertions, "document.parsed"); | ||
promise_test(() => contentLoadedAssertions, "document.contentLoaded"); | ||
promise_test(() => loadedAssertions, "document.loaded"); | ||
</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