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

Unified 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 side-by-side diff with in-line comments
Download patch
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..d329e1b41292e21890d4c55219bb84a1ba4b1010
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/chromium/resources/windowclient-navigate.js
@@ -0,0 +1,126 @@
+// 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');
+
+function initializeClient() {
+ synthesizeNotificationClick().then(function(e) {
+ clients.openWindow('blank.html').then(function(c) {
+ return c;
+ }).then(runNextTestOrQuit);
+ });
+}
+
+var TESTS = [
+
+ initializeClient,
+
+ function testNavigateControlledClient(client) {
+ synthesizeNotificationClick().then(function(e) {
+ 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) {
+ synthesizeNotificationClick().then(function(e) {
+ client.navigate('/').then(function(c) {
+ 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
+ self.postMessage('navigate() result: ' + c);
+ return c;
+ }).then(runNextTestOrQuit);
+ });
+ },
+
+ initializeClient,
+
+ function testNavigateCrossOriginClient(client) {
+ synthesizeNotificationClick().then(function(e) {
+ 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
+ self.postMessage('navigate() can navigate cross origin client');
nhiroki 2015/07/10 08:38:57 "can navigate to a cross origin URL" ?
+ self.postMessage('navigate() result: ' + c);
+ }).then(runNextTestOrQuit);
+ });
+ },
+
+ initializeClient,
+
+ function testWithNoNotificationClick(client) {
+ client.navigate('test.html').catch(function(e) {
+ self.postMessage('navigate() can not navigate without a user interaction');
nhiroki 2015/07/10 08:38:57 I think that the spec doesn't require a user inter
+ self.postMessage('navigate() error is ' + e.name);
+ return client;
+ }).then(runNextTestOrQuit);
+ },
+
+ function testNavigateInvalidURL(client) {
+ synthesizeNotificationClick().then(function() {
+ client.navigate('http://[test].com').catch(function(e) {
+ self.postMessage('navigate() can not navigate an invalid url');
nhiroki 2015/07/10 08:38:57 "navigate to an invalid url"
+ self.postMessage('navigate() error is ' + e.name);
+ return client;
+ }).then(runNextTestOrQuit);
+ });
+ },
+
+ function testNavigateViewSource(client) {
+ synthesizeNotificationClick().then(function() {
+ client.navigate('view-source://http://test.com').catch(function(e) {
+ self.postMessage('navigate() can not navigate view-source scheme');
nhiroki 2015/07/10 08:38:57 ditto.
+ self.postMessage('navigate() error is ' + e.name);
+ return client;
+ }).then(runNextTestOrQuit);
+ });
+ },
+
+ function testNavigateFileScheme(client) {
+ synthesizeNotificationClick().then(function() {
+ client.navigate('file:///').catch(function(e) {
+ self.postMessage('navigate() can not navigate file scheme');
nhiroki 2015/07/10 08:38:57 ditto.
+ self.postMessage('navigate() error is ' + e.name);
+ return client;
+ }).then(runNextTestOrQuit);
+ });
+ },
+
+ function testNavigateAboutBlank(client) {
+ synthesizeNotificationClick().then(function(e) {
+ client.navigate('about:blank').catch(function(e) {
+ self.postMessage('navigate() can not navigate about:blank');
nhiroki 2015/07/10 08:38:57 ditto.
+ self.postMessage('navigate() error is ' + e.name);
+ return client;
+ }).then(runNextTestOrQuit);
+ });
+ },
+
+ function testNavigateAboutCrash(client) {
+ synthesizeNotificationClick().then(function(e) {
+ client.navigate('about:crash').catch(function(e) {
+ self.postMessage('navigate() can not navigate about:crash');
nhiroki 2015/07/10 08:38:57 ditto.
+ 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');
+ });
+ }
+};

Powered by Google App Engine
This is Rietveld 408576698