summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fs/script-tests/FileSystemBaseHandle-postMessage-workers.js
blob: dbd8e5754d21d6c48dd20efbe881df495a8fcc81 (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
26
27
28
29
30
31
32
33
34
35
'use strict';

// This script depends on the following scripts:
//    /fs/resources/messaging-helpers.js
//    /fs/resources/messaging-blob-helpers.js
//    /fs/resources/messaging-serialize-helpers.js
//    /fs/resources/test-helpers.js
//    /service-workers/service-worker/resources/test-helpers.sub.js

directory_test(async (t, root_dir) => {
  const dedicated_worker =
      create_dedicated_worker(t, kDedicatedWorkerMessageTarget);
  await do_post_message_test(
      t, root_dir, /*receiver=*/ dedicated_worker,
      /*target=*/ dedicated_worker);
}, 'Send and receive messages using a dedicated worker.');

directory_test(async (t, root_dir) => {
  const scope = `${kServiceWorkerMessageTarget}?post-message-with-file-handle`;
  const registration =
      await create_service_worker(t, kServiceWorkerMessageTarget, scope);
  await do_post_message_test(
      t, root_dir, /*receiver=*/ navigator.serviceWorker,
      /*target=*/ registration.installing);
}, 'Send and receive messages using a service worker.');

if (self.SharedWorker !== undefined) {
  directory_test(async (t, root_dir) => {
    const shared_worker = new SharedWorker(kSharedWorkerMessageTarget);
    shared_worker.port.start();
    await do_post_message_test(
        t, root_dir, /*receiver=*/ shared_worker.port,
        /*target=*/ shared_worker.port);
  }, 'Send and receive messages using a shared worker.');
}