OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Notifications: The close event should be dispatched asynchronously.</
title> | 4 <title>Notifications: The close event should be dispatched asynchronously.</
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 the "close" event on a Notification object will be fired asy
nchronously | 11 // Tests that the "close" event on a Notification object will be fired asy
nchronously |
12 // when it's being closed programmatically by the developer. | 12 // when it's being closed programmatically by the developer. |
13 if (window.testRunner) | 13 if (window.testRunner) { |
| 14 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); |
14 testRunner.grantWebNotificationPermission(location.origin, true); | 15 testRunner.grantWebNotificationPermission(location.origin, true); |
| 16 } |
15 | 17 |
16 async_test(function(test) { | 18 async_test(function(test) { |
17 var eventOrderCounter = 0; | 19 var eventOrderCounter = 0; |
18 var notification = new Notification('My Notification', { | 20 var notification = new Notification('My Notification', { |
19 body: 'Hello, world!', | 21 body: 'Hello, world!', |
20 icon: '/my-icon.png' | 22 icon: '/my-icon.png' |
21 }); | 23 }); |
22 | 24 |
23 notification.addEventListener('show', function() { | 25 notification.addEventListener('show', function() { |
24 assert_equals(++eventOrderCounter, 2); | 26 assert_equals(++eventOrderCounter, 2); |
25 notification.close(); | 27 notification.close(); |
26 | 28 |
27 assert_equals(++eventOrderCounter, 3); | 29 assert_equals(++eventOrderCounter, 3); |
28 }); | 30 }); |
29 | 31 |
30 notification.addEventListener('close', function() { | 32 notification.addEventListener('close', function() { |
31 assert_equals(++eventOrderCounter, 4); | 33 assert_equals(++eventOrderCounter, 4); |
32 | 34 |
33 test.done(); | 35 test.done(); |
34 }); | 36 }); |
35 | 37 |
36 assert_equals(++eventOrderCounter, 1); | 38 assert_equals(++eventOrderCounter, 1); |
37 | 39 |
38 }, 'The close event should be dispatched asynchronously.'); | 40 }, 'The close event should be dispatched asynchronously.'); |
39 | 41 |
40 </script> | 42 </script> |
41 </body> | 43 </body> |
42 </html> | 44 </html> |
OLD | NEW |