| 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 importScripts('../../../resources/get-host-info.js'); |
| 7 | 7 |
| 8 var TESTS = [ | 8 var TESTS = [ |
| 9 function testWithNoNotificationClick() { | 9 function testWithNoNotificationClick() { |
| 10 clients.openWindow('/').catch(function(e) { | 10 clients.openWindow('/').catch(function(e) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 self.postMessage(' url: ' + c.url); | 42 self.postMessage(' url: ' + c.url); |
| 43 self.postMessage(' visibilityState: ' + c.visibilityState); | 43 self.postMessage(' visibilityState: ' + c.visibilityState); |
| 44 self.postMessage(' focused: ' + c.focused); | 44 self.postMessage(' focused: ' + c.focused); |
| 45 self.postMessage(' frameType: ' + c.frameType); | 45 self.postMessage(' frameType: ' + c.frameType); |
| 46 }).then(runNextTestOrQuit); | 46 }).then(runNextTestOrQuit); |
| 47 }); | 47 }); |
| 48 }, | 48 }, |
| 49 | 49 |
| 50 function testOpenAboutBlank() { | 50 function testOpenAboutBlank() { |
| 51 synthesizeNotificationClick().then(function(e) { | 51 synthesizeNotificationClick().then(function(e) { |
| 52 clients.openWindow('about:blank').then(function(c) { | 52 clients.openWindow('about:blank').catch(function(error) { |
| 53 self.postMessage('openWindow() can open about:blank'); | 53 self.postMessage('openWindow() can open about:blank'); |
| 54 self.postMessage('openWindow() result: ' + c); | 54 self.postMessage('openWindow() error is: ' + error.name); |
| 55 }).then(runNextTestOrQuit); | 55 }).then(runNextTestOrQuit); |
| 56 }); | 56 }); |
| 57 }, | 57 }, |
| 58 | 58 |
| 59 function testOpenAboutCrash() { | 59 function testOpenAboutCrash() { |
| 60 synthesizeNotificationClick().then(function(e) { | 60 synthesizeNotificationClick().then(function(e) { |
| 61 clients.openWindow('about:crash').then(function(c) { | 61 clients.openWindow('about:crash').catch(function(error) { |
| 62 self.postMessage('openWindow() can open about:crash'); | 62 self.postMessage('openWindow() can open about:crash'); |
| 63 self.postMessage('openWindow() result: ' + c); | 63 self.postMessage('openWindow() error is: ' + error.name); |
| 64 }).then(runNextTestOrQuit); | 64 }).then(runNextTestOrQuit); |
| 65 }); | 65 }); |
| 66 }, | 66 }, |
| 67 | 67 |
| 68 function testOpenInvalidURL() { | 68 function testOpenInvalidURL() { |
| 69 synthesizeNotificationClick().then(function(e) { | 69 synthesizeNotificationClick().then(function(e) { |
| 70 clients.openWindow('http://[test].com').catch(function(error) { | 70 clients.openWindow('http://[test].com').catch(function(error) { |
| 71 self.postMessage('openWindow() can not open an invalid url'); | 71 self.postMessage('openWindow() can not open an invalid url'); |
| 72 self.postMessage('openWindow() error is: ' + error.name); | 72 self.postMessage('openWindow() error is: ' + error.name); |
| 73 }).then(runNextTestOrQuit); | 73 }).then(runNextTestOrQuit); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 96 self.onmessage = function(e) { | 96 self.onmessage = function(e) { |
| 97 if (e.data == 'start') { | 97 if (e.data == 'start') { |
| 98 initialize().then(runNextTestOrQuit); | 98 initialize().then(runNextTestOrQuit); |
| 99 } else { | 99 } else { |
| 100 initialize().then(function() { | 100 initialize().then(function() { |
| 101 self.postMessage('received unexpected message'); | 101 self.postMessage('received unexpected message'); |
| 102 self.postMessage('quit'); | 102 self.postMessage('quit'); |
| 103 }); | 103 }); |
| 104 } | 104 } |
| 105 }; | 105 }; |
| OLD | NEW |