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

Unified Diff: LayoutTests/http/tests/serviceworker/chromium/resources/clients-openwindow.js

Issue 879403005: [ServiceWorker] Tests for Clients.openWindow(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@window_interaction_tests
Patch Set: cleanup and add test helper Created 5 years, 10 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/clients-openwindow.js
diff --git a/LayoutTests/http/tests/serviceworker/chromium/resources/clients-openwindow.js b/LayoutTests/http/tests/serviceworker/chromium/resources/clients-openwindow.js
new file mode 100644
index 0000000000000000000000000000000000000000..9beaf6be44e01ac2c9dc3daf41758775f5f445ac
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/chromium/resources/clients-openwindow.js
@@ -0,0 +1,56 @@
+// This helper will setup a small test framework that will use TESTS and run
+// them iteratively and call self.postMessage('quit') when done.
+// This helper also exposes |client|, |postMessage()|, |runNextTestOrQuit()|,
+// |synthesizeNotificationClick()| and |initialize()|.
+importScripts('sw-test-helpers.js');
+
+var TESTS = [
+ function testWithNoNotificationClick() {
+ clients.openWindow('/').catch(function(e) {
+ self.postMessage('openWindow() can\'t open a window without a user interaction');
+ self.postMessage('openWindow() error is ' + e.name);
+ }).then(runNextTestOrQuit);
+ },
+
+ function testOpenCrossOriginWindow() {
+ synthesizeNotificationClick().then(function(e) {
+ clients.openWindow('https://test.com/').catch(function(e) {
+ self.postMessage('openWindow() can\'t open cross origin windows');
+ self.postMessage('openWindow() error is ' + e.name);
+ }).then(runNextTestOrQuit);
+ });
+ },
+
+ function testOpenNotControlledWindow() {
+ synthesizeNotificationClick().then(function(e) {
+ clients.openWindow('/').then(function(c) {
+ self.postMessage('openWindow() can open not controlled windows');
+ self.postMessage('openWindow() result: ' + c);
+ }).then(runNextTestOrQuit);
+ });
+ },
+
+ function testOpenControlledWindow() {
+ synthesizeNotificationClick().then(function(e) {
+ clients.openWindow('blank.html').then(function(c) {
+ self.postMessage('openWindow() can open controlled windows');
+ self.postMessage('openWindow() result: ' + c);
+ self.postMessage(' url: ' + c.url);
+ self.postMessage(' visibilityState: ' + c.visibilityState);
+ self.postMessage(' focused: ' + c.focused);
+ self.postMessage(' frameType: ' + c.frameType);
+ }).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