summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/browsing-the-web/back-forward-cache/eligibility/dedicated-worker.html
blob: b08588a8bd5cab7ef132d8b25b14881b560d32d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!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>