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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 importScripts('worker-testharness.js');
2 importScripts('/resources/testharness-helpers.js');
3
4 var active = new Promise(function(resolve, reject) {
5 self.addEventListener('activate', function() {
6 resolve();
7 });
8 });
9
10 promise_test(function(t) {
11 self.clients.openWindow('http://example.com/')
12 .then(
13 t.unreached_func('openWindow() should not fulfill for off-origin URL'),
14 function(reason) {
15 assert_equals(reason.name, 'SecurityError',
16 'openWindow() should reject off-origin URL');
17 });
18 }, 'ServiceWorkerClients.openWindow with off-origin URL');
19
20 promise_test(function(t) {
21 self.clients.openWindow('http://[')
22 .then(
23 t.unreached_func('openWindow() should not fulfill for invalid URL'),
24 function(reason) {
25 assert_equals(reason.name, 'SyntaxError',
26 'openWindow() should reject invalid URL');
27 });
28 }, 'ServiceWorkerClients.openWindow with invalid URL');
29
30 promise_test(function(t) {
31 return active
32 .then(function() {
33 // FIXME: Should this reject?
34 return self.clients.openWindow('/out-of-scope');
35 })
36 .then(
37 t.unreached_func('openWindow() should not resolve if open fails'),
38 function(reason) {
39 // FIXME: Update when specified.
40 assert_equals(reason.name, 'SecurityError',
41 'Failed open should resolve with SecurityError');
42 });
43 }, 'ServiceWorkerClients.openWindow() with failed open');
44
45 promise_test(function(t) {
46 var client_url = 'simple.html';
47 return active
48 .then(function() {
49 return self.clients.openWindow('simple.html');
50 })
51 .then(function(client) {
52 assert_equals(client.url, String(new URL(client_url, self.location)),
53 'client.url should match URL passed to openWindow()');
54 assert_equals(client.frameType, 'top-level',
55 'client.frameType should be top-level');
56 });
57 }, 'ServiceWorkerClients.openWindow() with successful open');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698