http/tests/notifications/show.html is flaky
[WebKit-https.git] / LayoutTests / http / tests / notifications / show.html
1 <!DOCTYPE html>
2 <script src="/resources/js-test-pre.js"></script>
3 <script src="/resources/notifications-test-pre.js"></script>
4 <p id="description"></p>
5 <div id="console"></div>
6 <script>
7 if (window.testRunner)
8         testRunner.waitUntilDone();
9
10 description("This test looks for the dispatch of the onshow event handler.");
11
12 var n = null;
13 function part1() {
14         shouldBeEqualToString("Notification.permission", "default");
15
16         n = new Notification("title 1");
17         n.onshow = function() {
18                 testFailed("onshow event handler should not be called");
19                 setTimeout(part2, 0);
20         };
21         n.onerror = function() {
22                 testPassed("onerror event handler was called");
23                 setTimeout(part2, 0);
24         };
25 }
26
27 function part2() {
28         debug("Granting permission to " + testURL);
29         testRunner.grantWebNotificationPermission(testURL);
30         shouldBeEqualToString("Notification.permission", "granted");
31
32         n = new Notification("title 2");
33         n.onshow = function() {
34                 testPassed("onshow event handler was called");
35                 setTimeout(part3, 0);
36         };
37         n.onerror = function() {
38                 testFailed("onerror event handler should not be called");
39                 setTimeout(part3, 0);
40         };
41 }
42
43 function part3() {
44         debug("Denying permission to " + testURL);
45         testRunner.denyWebNotificationPermission(testURL);
46         shouldBeEqualToString("Notification.permission", "denied");
47
48         n = new Notification("title 3");
49         n.onshow = function() {
50                 testFailed("onshow event handler should not be called");
51                 setTimeout(part4, 0);
52         };
53         n.onerror = function() {
54                 testPassed("onerror event handler was called");
55                 setTimeout(part4, 0);
56         };
57 }
58
59 function part4() {
60         debug("Resetting all permissions");
61         testRunner.removeAllWebNotificationPermissions();
62         shouldBeEqualToString("Notification.permission", "default");
63         testCompleted();
64 }
65
66 part1();
67 </script>