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 importScripts('../../../resources/get-host-info.js'); |
6 | 7 |
7 var TESTS = [ | 8 var TESTS = [ |
8 function testWithNoNotificationClick() { | 9 function testWithNoNotificationClick() { |
9 clients.openWindow('/').catch(function(e) { | 10 clients.openWindow('/').catch(function(e) { |
10 self.postMessage('openWindow() can\'t open a window without a user i
nteraction'); | 11 self.postMessage('openWindow() can\'t open a window without a user i
nteraction'); |
11 self.postMessage('openWindow() error is ' + e.name); | 12 self.postMessage('openWindow() error is ' + e.name); |
12 }).then(runNextTestOrQuit); | 13 }).then(runNextTestOrQuit); |
13 }, | 14 }, |
14 | 15 |
15 function testOpenCrossOriginWindow() { | 16 function testOpenCrossOriginWindow() { |
16 synthesizeNotificationClick().then(function(e) { | 17 synthesizeNotificationClick().then(function(e) { |
17 clients.openWindow('https://test.com/').then(function(c) { | 18 var cross_origin_url = |
| 19 get_host_info()['HTTP_REMOTE_ORIGIN'] + |
| 20 '/serviceworker/chromium/resources/blank.html'; |
| 21 clients.openWindow(cross_origin_url).then(function(c) { |
18 self.postMessage('openWindow() can open cross origin windows'); | 22 self.postMessage('openWindow() can open cross origin windows'); |
19 self.postMessage('openWindow() result: ' + c); | 23 self.postMessage('openWindow() result: ' + c); |
20 }).then(runNextTestOrQuit); | 24 }).then(runNextTestOrQuit); |
21 }); | 25 }); |
22 }, | 26 }, |
23 | 27 |
24 function testOpenNotControlledWindow() { | 28 function testOpenNotControlledWindow() { |
25 synthesizeNotificationClick().then(function(e) { | 29 synthesizeNotificationClick().then(function(e) { |
26 clients.openWindow('/').then(function(c) { | 30 clients.openWindow('/').then(function(c) { |
27 self.postMessage('openWindow() can open not controlled windows')
; | 31 self.postMessage('openWindow() can open not controlled windows')
; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 self.onmessage = function(e) { | 95 self.onmessage = function(e) { |
92 if (e.data == 'start') { | 96 if (e.data == 'start') { |
93 initialize().then(runNextTestOrQuit); | 97 initialize().then(runNextTestOrQuit); |
94 } else { | 98 } else { |
95 initialize().then(function() { | 99 initialize().then(function() { |
96 self.postMessage('received unexpected message'); | 100 self.postMessage('received unexpected message'); |
97 self.postMessage('quit'); | 101 self.postMessage('quit'); |
98 }); | 102 }); |
99 } | 103 } |
100 }; | 104 }; |
OLD | NEW |