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.setPermission('notifications', 'granted', location.origin,
location.origin); |
15 testRunner.grantWebNotificationPermission(location.origin, true); | |
16 } | |
17 | 15 |
18 async_test(function(test) { | 16 async_test(function(test) { |
19 var eventOrderCounter = 0; | 17 var eventOrderCounter = 0; |
20 var notification = new Notification('My Notification', { | 18 var notification = new Notification('My Notification', { |
21 body: 'Hello, world!', | 19 body: 'Hello, world!', |
22 icon: '/my-icon.png' | 20 icon: '/my-icon.png' |
23 }); | 21 }); |
24 | 22 |
25 notification.addEventListener('show', function() { | 23 notification.addEventListener('show', function() { |
26 assert_equals(++eventOrderCounter, 2); | 24 assert_equals(++eventOrderCounter, 2); |
27 notification.close(); | 25 notification.close(); |
28 | 26 |
29 assert_equals(++eventOrderCounter, 3); | 27 assert_equals(++eventOrderCounter, 3); |
30 }); | 28 }); |
31 | 29 |
32 notification.addEventListener('close', function() { | 30 notification.addEventListener('close', function() { |
33 assert_equals(++eventOrderCounter, 4); | 31 assert_equals(++eventOrderCounter, 4); |
34 | 32 |
35 test.done(); | 33 test.done(); |
36 }); | 34 }); |
37 | 35 |
38 assert_equals(++eventOrderCounter, 1); | 36 assert_equals(++eventOrderCounter, 1); |
39 | 37 |
40 }, 'The close event should be dispatched asynchronously.'); | 38 }, 'The close event should be dispatched asynchronously.'); |
41 | 39 |
42 </script> | 40 </script> |
43 </body> | 41 </body> |
44 </html> | 42 </html> |
OLD | NEW |