From 3c892388071150586916f043c96de63a626c111d Mon Sep 17 00:00:00 2001 From: Catalin Badea Date: Tue, 7 Apr 2015 16:25:08 +0300 Subject: [PATCH] Bug 1130686 - Add test for service worker client.focus. r=nsm --- .../serviceworkers/client_focus_worker.js | 15 +++ dom/workers/test/serviceworkers/mochitest.ini | 3 + .../sw_clients/focus_stealing_client.html | 33 +++++++ .../serviceworkers/test_client_focus.html | 94 +++++++++++++++++++ 4 files changed, 145 insertions(+) create mode 100644 dom/workers/test/serviceworkers/client_focus_worker.js create mode 100644 dom/workers/test/serviceworkers/sw_clients/focus_stealing_client.html create mode 100644 dom/workers/test/serviceworkers/test_client_focus.html diff --git a/dom/workers/test/serviceworkers/client_focus_worker.js b/dom/workers/test/serviceworkers/client_focus_worker.js new file mode 100644 index 000000000000..944ebf224b04 --- /dev/null +++ b/dom/workers/test/serviceworkers/client_focus_worker.js @@ -0,0 +1,15 @@ +onmessage = function(e) { + if (!e.source) { + dump("ERROR: message doesn't have a source."); + } + + // The client should be a window client + if (e.source instanceof WindowClient) { + // this will dispatch a focus event on the client + e.source.focus().then(function(client) { + client.postMessage(client.focused); + }); + } else { + dump("ERROR: client should be a WindowClient"); + } +}; diff --git a/dom/workers/test/serviceworkers/mochitest.ini b/dom/workers/test/serviceworkers/mochitest.ini index 702106c373ed..21007a1a0d2a 100644 --- a/dom/workers/test/serviceworkers/mochitest.ini +++ b/dom/workers/test/serviceworkers/mochitest.ini @@ -17,6 +17,7 @@ support-files = workerUpdate/update.html sw_clients/simple.html sw_clients/service_worker_controlled.html + sw_clients/focus_stealing_client.html match_all_worker.js match_all_advanced_worker.js worker_unregister.js @@ -63,6 +64,7 @@ support-files = redirect_serviceworker.sjs importscript.sjs importscript_worker.js + client_focus_worker.js [test_unregister.html] [test_installation_simple.html] @@ -89,3 +91,4 @@ skip-if = true # Bug 1136780 [test_sandbox_intercept.html] [test_request_context.html] [test_importscript.html] +[test_client_focus.html] diff --git a/dom/workers/test/serviceworkers/sw_clients/focus_stealing_client.html b/dom/workers/test/serviceworkers/sw_clients/focus_stealing_client.html new file mode 100644 index 000000000000..e0831ae02ad8 --- /dev/null +++ b/dom/workers/test/serviceworkers/sw_clients/focus_stealing_client.html @@ -0,0 +1,33 @@ + + + + + Bug 1130686 - Test service worker client.focus: client + + + + +/ +

+ +

+
+
+
+
+
diff --git a/dom/workers/test/serviceworkers/test_client_focus.html b/dom/workers/test/serviceworkers/test_client_focus.html
new file mode 100644
index 000000000000..81a3c73ea781
--- /dev/null
+++ b/dom/workers/test/serviceworkers/test_client_focus.html
@@ -0,0 +1,94 @@
+
+
+
+
+  Bug 1130686 - Test service worker client.focus 
+  
+  
+
+
+
+

+
+

+
+
+
+
+