| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Notifications: Calling openWindow() in a Service Worker should not cr
ash.</title> | 4 <title>Notifications: Calling openWindow() in a Service Worker should not cr
ash.</title> |
| 5 <script src="../resources/testharness.js"></script> | 5 <script src="../resources/testharness.js"></script> |
| 6 <script src="../resources/testharnessreport.js"></script> | 6 <script src="../resources/testharnessreport.js"></script> |
| 7 <script src="../serviceworker/resources/test-helpers.js"></script> | 7 <script src="../serviceworker/resources/test-helpers.js"></script> |
| 8 <script src="resources/test-helpers.js"></script> | 8 <script src="resources/test-helpers.js"></script> |
| 9 </head> | 9 </head> |
| 10 <body> | 10 <body> |
| 11 <script> | 11 <script> |
| 12 // Tests that calling openWindow() in a Service Worker in response to a | 12 // Tests that calling openWindow() in a Service Worker in response to a |
| 13 // notificationclick event does not cause the browser to crash. | 13 // notificationclick event does not cause the browser to crash. |
| 14 | 14 |
| 15 async_test(function(test) { | 15 async_test(function(test) { |
| 16 var scope = 'resources/scope/' + location.pathname, | 16 var scope = 'resources/scope/' + location.pathname, |
| 17 script = 'resources/instrumentation-service-worker.js', | 17 script = 'resources/instrumentation-service-worker.js', |
| 18 workerInfo = null; | 18 workerInfo = null; |
| 19 | 19 |
| 20 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); | 20 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); |
| 21 testRunner.grantWebNotificationPermission(location.origin, true); | |
| 22 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(info) { | 21 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(info) { |
| 23 workerInfo = info; | 22 workerInfo = info; |
| 24 | 23 |
| 25 // (1) Display a persistent notification with an OPENWINDOW trigge
r. | 24 // (1) Display a persistent notification with an OPENWINDOW trigge
r. |
| 26 return workerInfo.registration.showNotification(scope, { | 25 return workerInfo.registration.showNotification(scope, { |
| 27 body: 'ACTION:OPENWINDOW' | 26 body: 'ACTION:OPENWINDOW' |
| 28 }); | 27 }); |
| 29 }).then(function() { | 28 }).then(function() { |
| 30 // (2) Simulate a click on the notification, invokes the Service W
orker event. | 29 // (2) Simulate a click on the notification, invokes the Service W
orker event. |
| 31 testRunner.simulateWebNotificationClick(scope); | 30 testRunner.simulateWebNotificationClick(scope); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 42 assert_equals(event.data.notification.title, scope); | 41 assert_equals(event.data.notification.title, scope); |
| 43 | 42 |
| 44 test.done(); | 43 test.done(); |
| 45 }); | 44 }); |
| 46 }).catch(unreached_rejection(test)); | 45 }).catch(unreached_rejection(test)); |
| 47 | 46 |
| 48 }, 'Opening a window in a Service Worker should not trigger a DCHECK.'); | 47 }, 'Opening a window in a Service Worker should not trigger a DCHECK.'); |
| 49 </script> | 48 </script> |
| 50 </body> | 49 </body> |
| 51 </html> | 50 </html> |
| OLD | NEW |