Commit 85d3e9e1 authored by Olli Pettay's avatar Olli Pettay
Browse files

Bug 1548274 - try to make dom/ipc/tests/browser_cancel_content_js.js a bit less racy r=squib

Differential Revision: https://phabricator.services.mozilla.com/D77445
parent d93dd3cc
......@@ -16,7 +16,7 @@ skip-if = !fission || !crashreporter || verify
[browser_memory_distribution_telemetry.js]
skip-if = true || !e10s # This is an e10s only probe, but the test is currently broken. See Bug 1449991
[browser_cancel_content_js.js]
skip-if = !e10s || (os == "win" && os_version == "10.0" && bits == 64 && debug) # This is an e10s only probe. Bug 1548274 - added disable on Windows10.
skip-if = !e10s
[browser_ElapsedTime.js]
support-files = elapsed_time.sjs
skip-if = (debug && os == "linux" && os_version == "18.04") || (!debug && os == "win") #Bug 1591344
......@@ -11,14 +11,12 @@ const TEST_PAGE =
const NEXT_PAGE = "https://example.org/";
const JS_URI = "javascript:void(document.title = 'foo')";
function sleep(ms) {
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
return new Promise(resolve => setTimeout(resolve, ms));
}
async function test_navigation(nextPage, cancelContentJSPref, shouldCancel) {
await SpecialPowers.pushPrefEnv({
set: [["dom.ipc.cancel_content_js_when_navigating", cancelContentJSPref]],
set: [
["dom.ipc.cancel_content_js_when_navigating", cancelContentJSPref],
["dom.max_script_run_time", 20],
],
});
let tab = await BrowserTestUtils.openNewForegroundTab({
gBrowser,
......@@ -33,9 +31,10 @@ async function test_navigation(nextPage, cancelContentJSPref, shouldCancel) {
});
});
// Wait for the test page's long-running JS loop to start; it happens ~500ms
// after load.
await sleep(1000);
// Wait for the test page's long-running JS loop to start.
await ContentTask.spawn(tab.linkedBrowser, [], function() {
content.dispatchEvent(new content.Event("StartLongLoop"));
});
info(
`navigating to ${nextPage} with cancel content JS ${
......
......@@ -6,11 +6,13 @@
<body>
Try to go to another page.
<script>
setTimeout(function() {
const start = Date.now();
while (Date.now() - start < 5000);
window.dispatchEvent(new CustomEvent("LongLoopEnded"));
}, 500);
addEventListener("StartLongLoop", function() {
setTimeout(() => {
const start = Date.now();
while (Date.now() - start < 7500);
window.dispatchEvent(new CustomEvent("LongLoopEnded"));
});
});
</script>
</body>
</html>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment