OLD | NEW |
1 // Supports test-runner control messages being send over |messagePort|, which en
able | 1 // Supports test-runner control messages being send over |messagePort|, which en
able |
2 // workers to have limited access to TestRunner methods. | 2 // workers to have limited access to TestRunner methods. |
3 function supportTestRunnerMessagesOnPort(messagePort) | 3 function supportTestRunnerMessagesOnPort(messagePort) |
4 { | 4 { |
5 if (!window.testRunner) | 5 if (!window.testRunner) |
6 return; | 6 return; |
7 | 7 |
8 messagePort.addEventListener('message', function(message) { | 8 messagePort.addEventListener('message', function(message) { |
9 if (message.data.type == 'simulateWebNotificationClick') | 9 if (message.data.type == 'simulateWebNotificationClick') |
10 testRunner.simulateWebNotificationClick(message.data.title); | 10 testRunner.simulateWebNotificationClick(message.data.title, -1 /* ac
tion_index */); |
11 }); | 11 }); |
12 } | 12 } |
13 | 13 |
14 // Starts |script| as a dedicated worker and executes the testharness tests defi
ned | 14 // Starts |script| as a dedicated worker and executes the testharness tests defi
ned |
15 // within it. The Notification-related testRunner methods will be made available
. | 15 // within it. The Notification-related testRunner methods will be made available
. |
16 function dedicatedWorkerTest(script) | 16 function dedicatedWorkerTest(script) |
17 { | 17 { |
18 var worker = new Worker(script); | 18 var worker = new Worker(script); |
19 supportTestRunnerMessagesOnPort(worker); | 19 supportTestRunnerMessagesOnPort(worker); |
20 | 20 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 messageChannel.port1.addEventListener('message', function(event) { | 59 messageChannel.port1.addEventListener('message', function(event) { |
60 if (event.data == 'ready') | 60 if (event.data == 'ready') |
61 resolve({ registration: registration, port: messageChannel.p
ort1 }); | 61 resolve({ registration: registration, port: messageChannel.p
ort1 }); |
62 }); | 62 }); |
63 | 63 |
64 registration.active.postMessage(messageChannel.port2, [messageChanne
l.port2]); | 64 registration.active.postMessage(messageChannel.port2, [messageChanne
l.port2]); |
65 messageChannel.port1.start(); | 65 messageChannel.port1.start(); |
66 }); | 66 }); |
67 }); | 67 }); |
68 } | 68 } |
OLD | NEW |