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

Side by Side Diff: LayoutTests/http/tests/serviceworker/chromium/resources/windowclient-navigate.js

Issue 1211253007: ServiceWorker: Add LayoutTest for WindowClient.navigate(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
(Empty)
1 // This helper will setup a small test framework that will use TESTS and run
2 // them sequentially and call self.postMessage('quit') when done.
3 // This helper also exposes |client|, |postMessage()|, |runNextTestOrQuit()|,
4 // |synthesizeNotificationClick()| and |initialize()|.
5 importScripts('sw-test-helpers.js');
6
7 function initializeClient() {
8 synthesizeNotificationClick().then(function(e) {
9 clients.openWindow('blank.html').then(function(c) {
10 return c;
11 }).then(runNextTestOrQuit);
12 });
13 }
14
15 var TESTS = [
16
17 initializeClient,
18
19 function testNavigateControlledClient(client) {
20 synthesizeNotificationClick().then(function(e) {
21 client.navigate('test.html').then(function(c) {
22 self.postMessage('navigate() can navigate controlled client');
23 self.postMessage('navigate() result: ' + c);
24 self.postMessage(' url: ' + c.url);
25 self.postMessage(' visibilityState: ' + c.visibilityState);
26 self.postMessage(' focused: ' + c.focused);
27 self.postMessage(' frameType: ' + c.frameType);
28 return c;
29 }).then(runNextTestOrQuit);
30 });
31 },
32
33 initializeClient,
34
35 function testNavigateNotControlledClient(client) {
36 synthesizeNotificationClick().then(function(e) {
37 client.navigate('/').then(function(c) {
38 self.postMessage('navigate() can navigate not controlled client' );
nhiroki 2015/07/10 08:38:57 Could you wrap this line at line 80? Our style gui
39 self.postMessage('navigate() result: ' + c);
40 return c;
41 }).then(runNextTestOrQuit);
42 });
43 },
44
45 initializeClient,
46
47 function testNavigateCrossOriginClient(client) {
48 synthesizeNotificationClick().then(function(e) {
49 client.navigate('https://test.com/').then(function(c) {
nhiroki 2015/07/10 08:38:57 "https://test.com/" is a real domain. Could you ch
50 self.postMessage('navigate() can navigate cross origin client');
nhiroki 2015/07/10 08:38:57 "can navigate to a cross origin URL" ?
51 self.postMessage('navigate() result: ' + c);
52 }).then(runNextTestOrQuit);
53 });
54 },
55
56 initializeClient,
57
58 function testWithNoNotificationClick(client) {
59 client.navigate('test.html').catch(function(e) {
60 self.postMessage('navigate() can not navigate without a user interac tion');
nhiroki 2015/07/10 08:38:57 I think that the spec doesn't require a user inter
61 self.postMessage('navigate() error is ' + e.name);
62 return client;
63 }).then(runNextTestOrQuit);
64 },
65
66 function testNavigateInvalidURL(client) {
67 synthesizeNotificationClick().then(function() {
68 client.navigate('http://[test].com').catch(function(e) {
69 self.postMessage('navigate() can not navigate an invalid url');
nhiroki 2015/07/10 08:38:57 "navigate to an invalid url"
70 self.postMessage('navigate() error is ' + e.name);
71 return client;
72 }).then(runNextTestOrQuit);
73 });
74 },
75
76 function testNavigateViewSource(client) {
77 synthesizeNotificationClick().then(function() {
78 client.navigate('view-source://http://test.com').catch(function(e) {
79 self.postMessage('navigate() can not navigate view-source scheme ');
nhiroki 2015/07/10 08:38:57 ditto.
80 self.postMessage('navigate() error is ' + e.name);
81 return client;
82 }).then(runNextTestOrQuit);
83 });
84 },
85
86 function testNavigateFileScheme(client) {
87 synthesizeNotificationClick().then(function() {
88 client.navigate('file:///').catch(function(e) {
89 self.postMessage('navigate() can not navigate file scheme');
nhiroki 2015/07/10 08:38:57 ditto.
90 self.postMessage('navigate() error is ' + e.name);
91 return client;
92 }).then(runNextTestOrQuit);
93 });
94 },
95
96 function testNavigateAboutBlank(client) {
97 synthesizeNotificationClick().then(function(e) {
98 client.navigate('about:blank').catch(function(e) {
99 self.postMessage('navigate() can not navigate about:blank');
nhiroki 2015/07/10 08:38:57 ditto.
100 self.postMessage('navigate() error is ' + e.name);
101 return client;
102 }).then(runNextTestOrQuit);
103 });
104 },
105
106 function testNavigateAboutCrash(client) {
107 synthesizeNotificationClick().then(function(e) {
108 client.navigate('about:crash').catch(function(e) {
109 self.postMessage('navigate() can not navigate about:crash');
nhiroki 2015/07/10 08:38:57 ditto.
110 self.postMessage('navigate() error is ' + e.name);
111 return client;
112 }).then(runNextTestOrQuit);
113 });
114 }
115 ];
116
117 self.onmessage = function(e) {
118 if (e.data == 'start') {
119 initialize().then(runNextTestOrQuit);
120 } else {
121 initialize().then(function() {
122 self.postMessage('received unexpected message');
123 self.postMessage('quit');
124 });
125 }
126 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698