Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't fire load event from within Stop().
This matches what the spec says, and what blink does. Differential Revision: https://phabricator.services.mozilla.com/D73994 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1620679 gecko-commit: 9cec607a0ea7d4e3188ce44320e1c49f21a7f0b6 gecko-integration-branch: autoland gecko-reviewers: smaug
- Loading branch information
1 parent
51e3a46
commit 546986f
Showing
3 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
html/browsers/browsing-the-web/navigating-across-documents/abort-document-load-1.html
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!doctype html> | ||
<script> | ||
parent.postMessage(document.readyState, "*"); | ||
let f = document.createElement("iframe"); | ||
f.onload = function() { | ||
parent.postMessage("stop", "*"); | ||
window.stop(); | ||
}; | ||
document.documentElement.appendChild(f); | ||
|
||
window.addEventListener("load", (event) => { | ||
parent.postMessage("load", "*"); | ||
}); | ||
window.addEventListener("error", (event) => { | ||
parent.postMessage("error", "*"); | ||
}); | ||
window.addEventListener("abort", (event) => { | ||
parent.postMessage("abort", "*"); | ||
}); | ||
window.addEventListener("pageshow", (event) => { | ||
parent.postMessage("pageshow", "*"); | ||
}); | ||
window.addEventListener("DOMContentLoaded", (event) => { | ||
parent.postMessage("DOMContentLoaded", "*"); | ||
}); | ||
document.addEventListener("readystatechange", (event) => { | ||
if (document.readyState === "complete") { | ||
parent.postMessage("complete", "*"); | ||
} | ||
}); | ||
|
||
</script> |
32 changes: 32 additions & 0 deletions
32
html/browsers/browsing-the-web/navigating-across-documents/abort-document-load-2.html
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!doctype html> | ||
<script> | ||
parent.postMessage(document.readyState, "*"); | ||
|
||
window.addEventListener("load", (event) => { | ||
parent.postMessage("load", "*"); | ||
}); | ||
window.addEventListener("error", (event) => { | ||
parent.postMessage("error", "*"); | ||
}); | ||
window.addEventListener("abort", (event) => { | ||
parent.postMessage("abort", "*"); | ||
}); | ||
window.addEventListener("pageshow", (event) => { | ||
parent.postMessage("pageshow", "*"); | ||
}); | ||
window.addEventListener("DOMContentLoaded", (event) => { | ||
parent.postMessage("DOMContentLoaded", "*"); | ||
}); | ||
document.addEventListener("readystatechange", (event) => { | ||
if (document.readyState === "complete") { | ||
parent.postMessage("complete", "*"); | ||
} | ||
}); | ||
|
||
window.setTimeout(function() { | ||
parent.postMessage("stop", "*"); | ||
window.stop(); | ||
}, 100); | ||
|
||
</script> | ||
<link rel="stylesheet" href="/common/slow.py"></link> |
30 changes: 30 additions & 0 deletions
30
html/browsers/browsing-the-web/navigating-across-documents/abort-document-load.html
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!doctype html> | ||
<title>Aborting a Document load</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#aborting-a-document-load"> | ||
<div id="log"></div> | ||
<script> | ||
var events = []; | ||
onmessage = function(e) { | ||
events.push(e.data); | ||
}; | ||
async_test(test => { | ||
test.step_timeout(() => { | ||
const frame = document.querySelector('iframe'); | ||
const child = frame.contentWindow; | ||
assert_equals(child.document.readyState, 'complete', 'readyState is complete'); | ||
assert_array_equals(events, ["loading", "DOMContentLoaded", "stop", "complete"], 'no load event was fired'); | ||
events = []; | ||
frame.src = "abort-document-load-2.html"; | ||
|
||
test.step_timeout(() => { | ||
const child = frame.contentWindow; | ||
assert_equals(child.document.readyState, 'complete', 'readyState is complete'); | ||
assert_array_equals(events, ["loading", "DOMContentLoaded", "stop", "complete"], 'no load event was fired'); | ||
test.done(); | ||
}, 1000); | ||
}, 1000); | ||
}); | ||
</script> | ||
<iframe src="abort-document-load-1.html"></iframe> |