Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/browsers/browsing-the-web/back-forward-cache/eligibility/dedicated-worker.html - WPT Dashboard Interop Dashboard
<!doctype html>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
<script src="/common/dispatcher/dispatcher.js"></script>
<script src="../resources/helper.sub.js"></script>
<script>
// Check whether the page is BFCached when there are dedicated workers that are
// already loaded.
runBfcacheTest({
funcBeforeNavigation: async () => {
globalThis.worker = new Worker('../resources/echo-worker.js');
// Make sure the worker starts before navigation.
await WorkerHelper.pingWorker(globalThis.worker);
},
funcAfterAssertion: async (pageA) => {
// Confirm that the worker is still there.
assert_equals(
await pageA.execute_script(() => WorkerHelper.pingWorker(globalThis.worker)),
'PASS',
'Worker should still work after restored from BFCache');
}
}, 'Eligibility: dedicated workers');
</script>