mirror of
https://github.com/servo/servo.git
synced 2025-06-28 19:13:41 +01:00
91 lines
3.7 KiB
JavaScript
91 lines
3.7 KiB
JavaScript
'use strict';
|
|
|
|
// This script depends on the following scripts:
|
|
// /native-file-system/resources/messaging-helpers.js
|
|
// /native-file-system/resources/messaging-blob-helpers.js
|
|
// /native-file-system/resources/messaging-serialize-helpers.js
|
|
// /native-file-system/resources/test-helpers.js
|
|
// /service-workers/service-worker/resources/test-helpers.sub.js
|
|
|
|
directory_test(async (t, root_dir) => {
|
|
const iframe = await add_iframe(t, { src: kDocumentMessageTarget });
|
|
await do_post_message_test(
|
|
t, root_dir, /*receiver=*/self, /*target=*/iframe.contentWindow,
|
|
/*target_origin=*/'*');
|
|
}, 'Send and receive messages using a same origin iframe.');
|
|
|
|
directory_test(async (t, root_dir) => {
|
|
const iframe = await add_iframe(t, {
|
|
src: kDocumentMessageTarget,
|
|
sandbox: 'allow-scripts allow-same-origin'
|
|
});
|
|
await do_post_message_test(
|
|
t, root_dir, /*receiver=*/self, /*target=*/iframe.contentWindow,
|
|
/*target_origin=*/'*');
|
|
}, 'Send and receive messages using a sandboxed same origin iframe.');
|
|
|
|
directory_test(async (t, root_dir) => {
|
|
const blob_url = await create_message_target_blob_url(t);
|
|
const iframe = await add_iframe(t, { src: blob_url });
|
|
await do_post_message_test(
|
|
t, root_dir, /*receiver=*/self, /*target=*/iframe.contentWindow,
|
|
/*target_origin=*/'*');
|
|
}, 'Send and receive messages using a blob iframe.');
|
|
|
|
directory_test(async (t, root_dir) => {
|
|
const iframe_html = await create_message_target_html_without_subresources(t);
|
|
const iframe = await add_iframe(t, { srcdoc: iframe_html });
|
|
await do_post_message_test(
|
|
t, root_dir, /*receiver=*/self, /*target=*/iframe.contentWindow,
|
|
/*target_origin=*/'*');
|
|
}, 'Send and receive messages using an iframe srcdoc.');
|
|
|
|
directory_test(async (t, root_dir) => {
|
|
const child_window = await open_window(t, kDocumentMessageTarget);
|
|
await do_post_message_test(
|
|
t, root_dir, /*receiver=*/self, /*target=*/child_window,
|
|
/*target_origin=*/'*');
|
|
}, 'Send and receive messages using a same origin window.');
|
|
|
|
directory_test(async (t, root_dir) => {
|
|
const blob_url = await create_message_target_blob_url(t);
|
|
const child_window = await open_window(t, blob_url);
|
|
await do_post_message_test(
|
|
t, root_dir, /*receiver=*/self, /*target=*/child_window,
|
|
/*target_origin=*/'*');
|
|
}, 'Send and receive messages using a blob window.');
|
|
|
|
directory_test(async (t, root_dir) => {
|
|
const url = `${kDocumentMessageTarget}?pipe=header(Content-Security-Policy` +
|
|
', sandbox allow-scripts allow-same-origin)';
|
|
const child_window = await open_window(t, url);
|
|
await do_post_message_test(
|
|
t, root_dir, /*receiver=*/self, /*target=*/child_window,
|
|
/*target_origin=*/'*');
|
|
}, 'Send and receive messages using a sandboxed same origin window.');
|
|
|
|
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.');
|
|
}
|