| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Notifications: Requesting notification permission in a detached conte
xt should not crash.</title> | 4 <title>Notifications: Requesting notification permission in a detached conte
xt should not crash.</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="resources/test-helpers.js"></script> | 7 <script src="resources/test-helpers.js"></script> |
| 8 </head> | 8 </head> |
| 9 <body> | 9 <body> |
| 10 <script> | 10 <script> |
| 11 // Tests that notifications created in a different context do not crash wh
en said | 11 // Tests that notifications created in a different context do not crash wh
en said |
| 12 // context gets detached, and events are still being fired on it. | 12 // context gets detached, and events are still being fired on it. |
| 13 if (window.testRunner) { | 13 if (window.testRunner) { |
| 14 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); | 14 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); |
| 15 testRunner.grantWebNotificationPermission(location.origin, true); | |
| 16 testRunner.setCanOpenWindows(); | 15 testRunner.setCanOpenWindows(); |
| 17 } | 16 } |
| 18 | 17 |
| 19 async_test(function (test) { | 18 async_test(function (test) { |
| 20 var win = window.open('resources/window-permission-detached-context.ht
ml'), | 19 var win = window.open('resources/window-permission-detached-context.ht
ml'), |
| 21 notificationObj = null; | 20 notificationObj = null; |
| 22 | 21 |
| 23 window.addEventListener('message', function (event) { | 22 window.addEventListener('message', function (event) { |
| 24 if (event.data == 'opened') { | 23 if (event.data == 'opened') { |
| 25 assert_own_property(win, 'Notification'); | 24 assert_own_property(win, 'Notification'); |
| 26 notificationObj = win.Notification; | 25 notificationObj = win.Notification; |
| 27 win.close(); | 26 win.close(); |
| 28 | 27 |
| 29 } else if (event.data == 'closed') { | 28 } else if (event.data == 'closed') { |
| 30 assert_equals(notificationObj.permission, 'granted'); | 29 assert_equals(notificationObj.permission, 'granted'); |
| 31 notificationObj.requestPermission(function () {}); | 30 notificationObj.requestPermission(function () {}); |
| 32 | 31 |
| 33 test.done(); | 32 test.done(); |
| 34 } else { | 33 } else { |
| 35 assert_unreached('Unrecognized message from the opened window.
'); | 34 assert_unreached('Unrecognized message from the opened window.
'); |
| 36 } | 35 } |
| 37 }); | 36 }); |
| 38 | 37 |
| 39 }, 'Requesting notification permission in a detached context should not cr
ash.'); | 38 }, 'Requesting notification permission in a detached context should not cr
ash.'); |
| 40 </script> | 39 </script> |
| 41 </body> | 40 </body> |
| 42 </html> | 41 </html> |
| OLD | NEW |