| Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/foreign-fetch-helpers.js
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/foreign-fetch-helpers.js b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/foreign-fetch-helpers.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..42ba7d00d3a199c9ae0c28d96feb3d02f010160c
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/foreign-fetch-helpers.js
|
| @@ -0,0 +1,20 @@
|
| +// Common helper functions for foreign fetch tests.
|
| +
|
| +// Installs a service worker on a different origin. Both |worker| and |scope|
|
| +// are resolved relative to the /serviceworker/resources/ directory on a
|
| +// remote origin.
|
| +function install_cross_origin_worker(t, worker, scope) {
|
| + return with_iframe(get_host_info().HTTPS_REMOTE_ORIGIN +
|
| + '/serviceworker/resources/install-worker-helper.html')
|
| + .then(frame => new Promise((resolve, reject) => {
|
| + var channel = new MessageChannel();
|
| + frame.contentWindow.postMessage({worker: worker,
|
| + options: {scope: scope},
|
| + port: channel.port1},
|
| + '*', [channel.port1]);
|
| + channel.port2.onmessage = reply => {
|
| + if (reply.data == 'success') resolve();
|
| + else reject(reply.data);
|
| + };
|
| + }));
|
| +}
|
|
|