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/shared-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 shared workers that are
// already loaded.
runBfcacheTest({
funcBeforeNavigation: async () => {
globalThis.worker = new SharedWorker('../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',
'SharedWorker should still work after restored from BFCache');
}
}, 'Eligibility: shared workers');
</script>