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 sequentially 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('/').catch(function(e) { | 9 clients.openWindow('/').catch(function(e) { |
10 self.postMessage('openWindow() can\'t open a window without a user i
nteraction'); | 10 self.postMessage('openWindow() can\'t open a window without a user i
nteraction'); |
11 self.postMessage('openWindow() error is ' + e.name); | 11 self.postMessage('openWindow() error is ' + e.name); |
12 }).then(runNextTestOrQuit); | 12 }).then(runNextTestOrQuit); |
13 }, | 13 }, |
14 | 14 |
15 function testOpenCrossOriginWindow() { | 15 function testOpenCrossOriginWindow() { |
16 synthesizeNotificationClick().then(function(e) { | 16 synthesizeNotificationClick().then(function(e) { |
17 clients.openWindow('https://test.com/').catch(function(e) { | 17 clients.openWindow('https://test.com/').then(function(c) { |
18 self.postMessage('openWindow() can\'t open cross origin windows'
); | 18 self.postMessage('openWindow() can open cross origin windows'); |
19 self.postMessage('openWindow() error is ' + e.name); | 19 self.postMessage('openWindow() result: ' + c); |
20 }).then(runNextTestOrQuit); | 20 }).then(runNextTestOrQuit); |
21 }); | 21 }); |
22 }, | 22 }, |
23 | 23 |
24 function testOpenNotControlledWindow() { | 24 function testOpenNotControlledWindow() { |
25 synthesizeNotificationClick().then(function(e) { | 25 synthesizeNotificationClick().then(function(e) { |
26 clients.openWindow('/').then(function(c) { | 26 clients.openWindow('/').then(function(c) { |
27 self.postMessage('openWindow() can open not controlled windows')
; | 27 self.postMessage('openWindow() can open not controlled windows')
; |
28 self.postMessage('openWindow() result: ' + c); | 28 self.postMessage('openWindow() result: ' + c); |
29 }).then(runNextTestOrQuit); | 29 }).then(runNextTestOrQuit); |
(...skipping 17 matching lines...) Expand all Loading... |
47 self.onmessage = function(e) { | 47 self.onmessage = function(e) { |
48 if (e.data == 'start') { | 48 if (e.data == 'start') { |
49 initialize().then(runNextTestOrQuit); | 49 initialize().then(runNextTestOrQuit); |
50 } else { | 50 } else { |
51 initialize().then(function() { | 51 initialize().then(function() { |
52 self.postMessage('received unexpected message'); | 52 self.postMessage('received unexpected message'); |
53 self.postMessage('quit'); | 53 self.postMessage('quit'); |
54 }); | 54 }); |
55 } | 55 } |
56 }; | 56 }; |
OLD | NEW |