blob: 33ec5b1530de8159c6ee5e2db06ac8b7df984bdf [file] [edit]
<!DOCTYPE html>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>
<body>
<script>
setup(() => assertSpeculationRulesIsSupported());
function runTest(test_file, expectation, description) {
promise_test(async t => {
// Run test in a new window for test isolation.
window.open(test_file, '_blank', 'noopener');
// Wait until the prerendered page sends the result.
const bc = new BroadcastChannel('result');
const gotMessage = new Promise(r => bc.onmessage = e => r(e.data));
const result = await gotMessage;
assert_equals(await gotMessage, expectation);
}, description);
}
// Test that a page opens a window during prerendering.
runTest(
'resources/window-open-during-prerendering.html',
'failed to open',
'window.open() should fail during prerendering');
// Test that a page opens a window in the prerenderingchange event.
runTest(
'resources/window-open-in-prerenderingchange.html',
'opened',
'window.open() should succeed in the prerenderingchange event');
</script>
</body>