Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / notifications / request-permission-detached-context.html
blob7857c214a10ac20af5409e9881c188445aa7f2a3
1 <!doctype html>
2 <html>
3 <head>
4 <title>Notifications: Requesting notification permission in a detached context should not crash.</title>
5 <script src="../resources/testharness.js"></script>
6 <script src="../resources/testharnessreport.js"></script>
7 <script src="resources/test-helpers.js"></script>
8 </head>
9 <body>
10 <script>
11 // Tests that notifications created in a different context do not crash when said
12 // context gets detached, and events are still being fired on it.
13 if (window.testRunner) {
14 testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
15 testRunner.setCanOpenWindows();
18 async_test(function (test) {
19 var win = window.open('resources/window-permission-detached-context.html'),
20 notificationObj = null;
22 window.addEventListener('message', function (event) {
23 if (event.data == 'opened') {
24 assert_own_property(win, 'Notification');
25 notificationObj = win.Notification;
26 win.close();
28 } else if (event.data == 'closed') {
29 assert_equals(notificationObj.permission, 'granted');
30 notificationObj.requestPermission(function () {});
32 test.done();
33 } else {
34 assert_unreached('Unrecognized message from the opened window.');
36 });
38 }, 'Requesting notification permission in a detached context should not crash.');
39 </script>
40 </body>
41 </html>