Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / push_messaging / push-messaging-detached-no-crash.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../resources/js-test.js"></script>
5 </head>
6 <body>
7 <script>
8 description("Accessing navigator.push on a closed window.");
9
10 var jsTestIsAsync = true;
11
12 var win;
13 var nav;
14
15 function processMessage(event) {
16     if (event.data == 'opened') {
17         nav = win.navigator;
18         win.close();
19         win = null;
20     } else if (event.data == 'closed') {
21         nav.push.register('senderId').then(function successCallback() {
22             testFailed('Success callback invoked unexpectedly.');
23             finishJSTest();
24         }, function(e) {
25             error = e;
26             shouldBeEqualToString('error.message', 'Document is detached from window.');
27             finishJSTest();
28         });
29     }
30 }
31
32 if (window.testRunner) {
33     testRunner.dumpAsText();
34     testRunner.setCanOpenWindows();
35 }
36 win = window.open('resources/push-messaging-detached-no-crash-new-window.html');
37 window.addEventListener("message", processMessage, false);
38 </script>
39 </body>
40 </html>