OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Service Worker: clients.openWindow() tests (using testRunner)</title> | 2 <title>Service Worker: clients.openWindow() tests (using testRunner)</title> |
3 <script src="../../resources/testharness.js"></script> | 3 <script src="../../resources/testharness.js"></script> |
4 <script src="../../resources/testharnessreport.js"></script> | 4 <script src="../../resources/testharnessreport.js"></script> |
5 <script src="../resources/test-helpers.js"></script> | 5 <script src="../resources/test-helpers.js"></script> |
6 <script> | 6 <script> |
7 // This test is using testRunner to grant itself the notification permission and | 7 // This test is using testRunner to grant itself the notification permission and |
8 // to simulate a click on a notification. A couple of changes would allow it to | 8 // to simulate a click on a notification. A couple of changes would allow it to |
9 // be run as a manual test by other browser vendors. | 9 // be run as a manual test by other browser vendors. |
10 if (window.testRunner) | 10 if (window.testRunner) |
(...skipping 11 matching lines...) Expand all Loading... |
22 .then(function(frame) { | 22 .then(function(frame) { |
23 var w = frame.contentWindow; | 23 var w = frame.contentWindow; |
24 w.onmessage = t.step_func(onMessage); | 24 w.onmessage = t.step_func(onMessage); |
25 w.navigator.serviceWorker.controller.postMessage('start'); | 25 w.navigator.serviceWorker.controller.postMessage('start'); |
26 }) | 26 }) |
27 .catch(unreached_rejection(t)); | 27 .catch(unreached_rejection(t)); |
28 | 28 |
29 var result = []; | 29 var result = []; |
30 var expected = ['openWindow() can\'t open a window without a user interactio
n', | 30 var expected = ['openWindow() can\'t open a window without a user interactio
n', |
31 'openWindow() error is InvalidAccessError', | 31 'openWindow() error is InvalidAccessError', |
32 'openWindow() can\'t open cross origin windows', | 32 'openWindow() can open cross origin windows', |
33 'openWindow() error is SecurityError', | 33 'openWindow() result: null', |
34 'openWindow() can open not controlled windows', | 34 'openWindow() can open not controlled windows', |
35 'openWindow() result: null', | 35 'openWindow() result: null', |
36 'openWindow() can open controlled windows', | 36 'openWindow() can open controlled windows', |
37 'openWindow() result: [object WindowClient]', | 37 'openWindow() result: [object WindowClient]', |
38 ' url: ' + location.origin + '/serviceworker/chromium/resour
ces/blank.html', | 38 ' url: ' + location.origin + '/serviceworker/chromium/resour
ces/blank.html', |
39 ' visibilityState: visible', | 39 ' visibilityState: visible', |
40 ' focused: true', | 40 ' focused: true', |
41 ' frameType: top-level']; | 41 ' frameType: top-level', |
| 42 'openWindow() can open about:blank', |
| 43 'openWindow() result: null', |
| 44 'openWindow() can open about:crash', |
| 45 'openWindow() result: null', |
| 46 'openWindow() can not open view-source scheme', |
| 47 'openWindow() can not open file scheme', |
| 48 'openWindow() error is: SecurityError', |
| 49 ]; |
42 | 50 |
43 // LayoutTests on Mac do not open focused windows. | 51 // LayoutTests on Mac do not open focused windows. |
44 var isMac = navigator.platform.indexOf('Mac') == 0; | 52 var isMac = navigator.platform.indexOf('Mac') == 0; |
45 if (isMac) | 53 if (isMac) |
46 expected[10] = ' focused: false'; | 54 expected[10] = ' focused: false'; |
47 | 55 |
48 function onMessage(e) { | 56 function onMessage(e) { |
49 var message = e.data; | 57 var message = e.data; |
50 | 58 |
51 if (typeof(message) === 'object') { | 59 if (typeof(message) === 'object') { |
52 if (message.type !== 'click') | 60 if (message.type !== 'click') |
53 return; | 61 return; |
54 if (window.testRunner) | 62 if (window.testRunner) |
55 testRunner.simulateWebNotificationClick(message.title); | 63 testRunner.simulateWebNotificationClick(message.title); |
56 return; | 64 return; |
57 } | 65 } |
58 | 66 |
59 if (message === 'quit') { | 67 if (message === 'quit') { |
60 assert_array_equals(result, expected, | 68 assert_array_equals(result, expected, |
61 'Worker should post back expected messages.'); | 69 'Worker should post back expected messages.'); |
62 service_worker_unregister_and_done(t, scope); | 70 service_worker_unregister_and_done(t, scope); |
63 } else { | 71 } else { |
64 result.push(message); | 72 result.push(message); |
65 } | 73 } |
66 } | 74 } |
67 }); | 75 }); |
68 </script> | 76 </script> |
OLD | NEW |