OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Notifications: Creating notifications should succeed when permission
has been granted.</title> | 4 <title>Notifications: Creating notifications should succeed when permission
has been granted.</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 </head> | 7 </head> |
8 <body> | 8 <body> |
9 <script> | 9 <script> |
10 // Tests that Notification.requestPermission() returns "granted" when | 10 // Tests that Notification.requestPermission() returns "granted" when |
11 // permission has been granted, causing creation of notifications to | 11 // permission has been granted, causing creation of notifications to |
12 // succeed. When running this test manually, accept permission | 12 // succeed. When running this test manually, accept permission |
13 // for displaying notifications prior to running the test. | 13 // for displaying notifications prior to running the test. |
14 if (window.testRunner) | 14 if (window.testRunner) |
15 testRunner.clearWebNotificationPermissions(); | 15 testRunner.clearWebNotificationPermissions(); |
16 | 16 |
17 async_test(function (test) { | 17 async_test(function (test) { |
| 18 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); |
18 testRunner.grantWebNotificationPermission(location.origin, true); | 19 testRunner.grantWebNotificationPermission(location.origin, true); |
19 Notification.requestPermission(function (status) { | 20 Notification.requestPermission(function (status) { |
20 assert_equals(status, 'granted'); | 21 assert_equals(status, 'granted'); |
21 | 22 |
22 var notification = new Notification('My Notification'); | 23 var notification = new Notification('My Notification'); |
23 notification.addEventListener('show', function() { | 24 notification.addEventListener('show', function() { |
24 test.done(); | 25 test.done(); |
25 }); | 26 }); |
26 | 27 |
27 notification.addEventListener('error', function() { | 28 notification.addEventListener('error', function() { |
28 assert_unreached('The notification is expected to be shown.'); | 29 assert_unreached('The notification is expected to be shown.'); |
29 }); | 30 }); |
30 }); | 31 }); |
31 | 32 |
32 }, 'Notification creation succeeds when permission has been granted.'); | 33 }, 'Notification creation succeeds when permission has been granted.'); |
33 </script> | 34 </script> |
34 </body> | 35 </body> |
35 </html> | 36 </html> |
OLD | NEW |