Index: LayoutTests/fast/notifications/resources/worker-tools.js |
diff --git a/LayoutTests/fast/notifications/resources/worker-tools.js b/LayoutTests/fast/notifications/resources/worker-tools.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..28c5d14007d07dde5c5d27c03c60e93939f3d2c7 |
--- /dev/null |
+++ b/LayoutTests/fast/notifications/resources/worker-tools.js |
@@ -0,0 +1,33 @@ |
+function startWorkerTest(script, type) |
+{ |
+ var worker, messagePort; |
+ |
+ switch (type) { |
+ case 'dedicated': |
+ worker = startWorker(script, false); |
+ messagePort = worker; |
+ break; |
+ case 'shared': |
+ worker = startWorker(script, true); |
+ messagePort = worker.port; |
+ break; |
+ case 'service': |
+ testFailed('Service Worker-based tests have not been implemented yet.'); |
+ return; |
+ } |
+ |
+ messagePort.addEventListener('message', function(event) { |
+ if (event.data.length < 5 || event.data.charAt(4) == ':') |
+ return; // this is a js-test.js message. |
+ |
+ if (!window.testRunner) |
+ return; // the test-runner is needed to provide automation. |
+ |
+ var chunks = event.data.split('::'); |
+ switch (chunks[0]) { |
+ case 'simulateClick': |
+ testRunner.simulateWebNotificationClick(chunks[1]); |
+ break; |
+ } |
+ }); |
+} |