Index: LayoutTests/http/tests/serviceworker/chromium/resources/windowclient-navigate.js |
diff --git a/LayoutTests/http/tests/serviceworker/chromium/resources/windowclient-navigate.js b/LayoutTests/http/tests/serviceworker/chromium/resources/windowclient-navigate.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..820ea6258b47a812b93fa8ba73377626cbeb6e73 |
--- /dev/null |
+++ b/LayoutTests/http/tests/serviceworker/chromium/resources/windowclient-navigate.js |
@@ -0,0 +1,106 @@ |
+// This helper will setup a small test framework that will use TESTS and run |
+// them sequentially and call self.postMessage('quit') when done. |
+// This helper also exposes |client|, |postMessage()|, |runNextTestOrQuit()|, |
+// |synthesizeNotificationClick()| and |initialize()|. |
+importScripts('sw-test-helpers.js'); |
+importScripts('../../../resources/get-host-info.js'); |
+ |
+function initializeClient() { |
+ synthesizeNotificationClick().then(function(e) { |
+ clients.openWindow('blank.html').then(function(c) { |
+ return c; |
+ }).then(runNextTestOrQuit); |
+ }); |
+} |
+ |
+var TESTS = [ |
+ |
+ initializeClient, |
+ |
+ function testNavigateControlledClient(client) { |
+ client.navigate('test.html').then(function(c) { |
+ self.postMessage('navigate() can navigate controlled client'); |
+ self.postMessage('navigate() result: ' + c); |
+ self.postMessage(' url: ' + c.url); |
+ self.postMessage(' visibilityState: ' + c.visibilityState); |
+ self.postMessage(' focused: ' + c.focused); |
+ self.postMessage(' frameType: ' + c.frameType); |
+ return c; |
+ }).then(runNextTestOrQuit); |
+ }, |
+ |
+ initializeClient, |
+ |
+ function testNavigateNotControlledClient(client) { |
nhiroki
2015/07/15 08:53:14
|client| ("/serviceworker/chromium/resources/blank
zino
2015/09/22 07:53:31
Done.
|
+ client.navigate('/').then(function(c) { |
+ self.postMessage('navigate() can navigate not controlled client'); |
nhiroki
2015/07/15 08:53:14
According to the spec, non-controlled clients shou
zino
2015/09/22 07:53:31
Done.
|
+ self.postMessage('navigate() result: ' + c); |
+ return c; |
+ }).then(runNextTestOrQuit); |
+ }, |
+ |
+ initializeClient, |
+ |
+ function testNavigateCrossOriginClient(client) { |
+ var cross_origin_url = get_host_info()['HTTP_REMOTE_ORIGIN'] + |
+ '/serviceworker/chromium/resources/blank.html'; |
+ client.navigate(cross_origin_url).then(function(c) { |
+ self.postMessage('navigate() can navigate to a cross origin url'); |
+ self.postMessage('navigate() result: ' + c); |
+ }).then(runNextTestOrQuit); |
+ }, |
+ |
+ initializeClient, |
+ |
+ function testNavigateInvalidURL(client) { |
+ client.navigate('http://[test].com').catch(function(e) { |
+ self.postMessage('navigate() can not navigate to an invalid url'); |
+ self.postMessage('navigate() error is ' + e.name); |
+ return client; |
+ }).then(runNextTestOrQuit); |
+ }, |
+ |
+ function testNavigateViewSource(client) { |
+ client.navigate('view-source://http://test.com').catch(function(e) { |
+ self.postMessage('navigate() can not navigate to ' + |
+ 'view-source scheme'); |
+ self.postMessage('navigate() error is ' + e.name); |
+ return client; |
+ }).then(runNextTestOrQuit); |
+ }, |
+ |
+ function testNavigateFileScheme(client) { |
+ client.navigate('file:///').catch(function(e) { |
+ self.postMessage('navigate() can not navigate to file scheme'); |
+ self.postMessage('navigate() error is ' + e.name); |
+ return client; |
+ }).then(runNextTestOrQuit); |
+ }, |
+ |
+ function testNavigateAboutBlank(client) { |
+ client.navigate('about:blank').catch(function(e) { |
+ self.postMessage('navigate() can not navigate to about:blank'); |
+ self.postMessage('navigate() error is ' + e.name); |
+ return client; |
+ }).then(runNextTestOrQuit); |
+ }, |
+ |
+ function testNavigateAboutCrash(client) { |
+ client.navigate('about:crash').catch(function(e) { |
+ self.postMessage('navigate() can not navigate to about:crash'); |
+ self.postMessage('navigate() error is ' + e.name); |
+ return client; |
+ }).then(runNextTestOrQuit); |
+ } |
+]; |
+ |
+self.onmessage = function(e) { |
+ if (e.data == 'start') { |
+ initialize().then(runNextTestOrQuit); |
+ } else { |
+ initialize().then(function() { |
+ self.postMessage('received unexpected message'); |
+ self.postMessage('quit'); |
+ }); |
+ } |
+}; |