OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Service Worker: notificationclick can open new WindowClient</title> | 2 <title>Service Worker: notificationclick can open new WindowClient</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 if (window.testRunner) | 7 if (window.testRunner) |
8 testRunner.setPermission('notifications', 'granted', location.origin, locati
on.origin); | 8 testRunner.setPermission('notifications', 'granted', location.origin, locati
on.origin); |
9 | 9 |
10 var t = async_test('notificationclick can open new WindowClient'); | 10 var t = async_test('notificationclick can open new WindowClient'); |
11 t.step(function() { | 11 t.step(function() { |
12 var scope = 'resources/blank.html' | 12 var scope = 'resources/blank.html' |
13 service_worker_unregister_and_register( | 13 service_worker_unregister_and_register( |
14 t, 'resources/notificationclick-can-openwindow.js', scope) | 14 t, 'resources/notificationclick-can-openwindow.js', scope) |
15 .then(function(registration) { | 15 .then(function(registration) { |
16 return wait_for_state(t, registration.installing, 'activated'); | 16 return wait_for_state(t, registration.installing, 'activated'); |
17 }) | 17 }) |
18 .then(function() { return with_iframe(scope); }) | 18 .then(function() { return with_iframe(scope); }) |
19 .then(function(frame) { | 19 .then(function(frame) { |
20 var w = frame.contentWindow; | 20 var w = frame.contentWindow; |
21 w.onmessage = t.step_func(onMessage); | 21 w.navigator.serviceWorker.onmessage = t.step_func(onMessage); |
22 w.navigator.serviceWorker.controller.postMessage('start'); | 22 w.navigator.serviceWorker.controller.postMessage('start'); |
23 }) | 23 }) |
24 .catch(unreached_rejection(t)); | 24 .catch(unreached_rejection(t)); |
25 | 25 |
26 var result = []; | 26 var result = []; |
27 var expected = ['openWindow() outside of a notificationclick event failed', | 27 var expected = ['openWindow() outside of a notificationclick event failed', |
28 'openWindow() in notificationclick outside of waitUntil but
in stack succeeded', | 28 'openWindow() in notificationclick outside of waitUntil but
in stack succeeded', |
29 'openWindow() in notificationclick outside of waitUntil not
in stack failed', | 29 'openWindow() in notificationclick outside of waitUntil not
in stack failed', |
30 'openWindow() in notificationclick\'s waitUntil suceeded', | 30 'openWindow() in notificationclick\'s waitUntil suceeded', |
31 'openWindow() called twice failed', | 31 'openWindow() called twice failed', |
(...skipping 14 matching lines...) Expand all Loading... |
46 if (message === 'quit') { | 46 if (message === 'quit') { |
47 assert_array_equals(result, expected, | 47 assert_array_equals(result, expected, |
48 'Worker should post back expected messages.'); | 48 'Worker should post back expected messages.'); |
49 service_worker_unregister_and_done(t, scope); | 49 service_worker_unregister_and_done(t, scope); |
50 } else { | 50 } else { |
51 result.push(message); | 51 result.push(message); |
52 } | 52 } |
53 } | 53 } |
54 }); | 54 }); |
55 </script> | 55 </script> |
OLD | NEW |