Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Unified Diff: LayoutTests/http/tests/serviceworker/resources/serviceworkerclients-openwindow-worker.js

Issue 779133003: [WORK IN PROGRESS] ServiceWorkerClients.openWindow() [Blink] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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');

Powered by Google App Engine
This is Rietveld 408576698