<!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>
