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