OLD | NEW |
1 // This helper will setup a small test framework that will use TESTS and run | 1 // This helper will setup a small test framework that will use TESTS and run |
2 // them iteratively and call self.postMessage('quit') when done. | 2 // them sequentially and call self.postMessage('quit') when done. |
3 // This helper also exposes |client|, |postMessage()|, |runNextTestOrQuit()|, | 3 // This helper also exposes |client|, |postMessage()|, |runNextTestOrQuit()|, |
4 // |synthesizeNotificationClick()| and |initialize()|. | 4 // |synthesizeNotificationClick()| and |initialize()|. |
5 importScripts('sw-test-helpers.js'); | 5 importScripts('sw-test-helpers.js'); |
6 | 6 |
7 var TESTS = [ | 7 var TESTS = [ |
8 function testWithNoNotificationClick() { | 8 function testWithNoNotificationClick() { |
9 clients.openWindow('/foo.html').catch(function() { | 9 clients.openWindow('/foo.html').catch(function() { |
10 self.postMessage('openWindow() outside of a notificationclick event
failed'); | 10 self.postMessage('openWindow() outside of a notificationclick event
failed'); |
11 }).then(runNextTestOrQuit); | 11 }).then(runNextTestOrQuit); |
12 }, | 12 }, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 e.waitUntil(client.focus().then(function() { | 73 e.waitUntil(client.focus().then(function() { |
74 clients.openWindow().catch(function() { | 74 clients.openWindow().catch(function() { |
75 self.postMessage('openWindow() failed because a window was f
ocused before'); | 75 self.postMessage('openWindow() failed because a window was f
ocused before'); |
76 }).then(runNextTestOrQuit); | 76 }).then(runNextTestOrQuit); |
77 })); | 77 })); |
78 }); | 78 }); |
79 }, | 79 }, |
80 ]; | 80 ]; |
81 | 81 |
82 self.onmessage = function(e) { | 82 self.onmessage = function(e) { |
83 if (e.data == "start") { | 83 if (e.data == 'start') { |
84 initialize().then(runNextTestOrQuit); | 84 initialize().then(runNextTestOrQuit); |
85 } else { | 85 } else { |
86 initialize().then(function() { | 86 initialize().then(function() { |
87 self.postMessage('received unexpected message'); | 87 self.postMessage('received unexpected message'); |
88 self.postMessage('quit'); | 88 self.postMessage('quit'); |
89 }); | 89 }); |
90 } | 90 } |
91 } | 91 }; |
OLD | NEW |