| Index: LayoutTests/http/tests/serviceworker/resources/serviceworkerclients-openwindow-worker.js
|
| diff --git a/LayoutTests/http/tests/serviceworker/resources/serviceworkerclients-openwindow-worker.js b/LayoutTests/http/tests/serviceworker/resources/serviceworkerclients-openwindow-worker.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a186ef76e47df84d7aeec98a7ee6bb191980d437
|
| --- /dev/null
|
| +++ b/LayoutTests/http/tests/serviceworker/resources/serviceworkerclients-openwindow-worker.js
|
| @@ -0,0 +1,57 @@
|
| +importScripts('worker-testharness.js');
|
| +importScripts('/resources/testharness-helpers.js');
|
| +
|
| +var active = new Promise(function(resolve, reject) {
|
| + self.addEventListener('activate', function() {
|
| + resolve();
|
| + });
|
| +});
|
| +
|
| +promise_test(function(t) {
|
| + self.clients.openWindow('http://example.com/')
|
| + .then(
|
| + t.unreached_func('openWindow() should not fulfill for off-origin URL'),
|
| + function(reason) {
|
| + assert_equals(reason.name, 'SecurityError',
|
| + 'openWindow() should reject off-origin URL');
|
| + });
|
| +}, 'ServiceWorkerClients.openWindow with off-origin URL');
|
| +
|
| +promise_test(function(t) {
|
| + self.clients.openWindow('http://[')
|
| + .then(
|
| + t.unreached_func('openWindow() should not fulfill for invalid URL'),
|
| + function(reason) {
|
| + assert_equals(reason.name, 'SyntaxError',
|
| + 'openWindow() should reject invalid URL');
|
| + });
|
| +}, 'ServiceWorkerClients.openWindow with invalid URL');
|
| +
|
| +promise_test(function(t) {
|
| + return active
|
| + .then(function() {
|
| + // FIXME: Should this reject?
|
| + return self.clients.openWindow('/out-of-scope');
|
| + })
|
| + .then(
|
| + t.unreached_func('openWindow() should not resolve if open fails'),
|
| + function(reason) {
|
| + // FIXME: Update when specified.
|
| + assert_equals(reason.name, 'SecurityError',
|
| + 'Failed open should resolve with SecurityError');
|
| + });
|
| +}, 'ServiceWorkerClients.openWindow() with failed open');
|
| +
|
| +promise_test(function(t) {
|
| + var client_url = 'simple.html';
|
| + return active
|
| + .then(function() {
|
| + return self.clients.openWindow('simple.html');
|
| + })
|
| + .then(function(client) {
|
| + assert_equals(client.url, String(new URL(client_url, self.location)),
|
| + 'client.url should match URL passed to openWindow()');
|
| + assert_equals(client.frameType, 'top-level',
|
| + 'client.frameType should be top-level');
|
| + });
|
| +}, 'ServiceWorkerClients.openWindow() with successful open');
|
|
|