Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / notifications / request-permission-granted.html
blob0a30970974c59b5dc94241123d9366d78031e675
1 <!doctype html>
2 <html>
3 <head>
4 <title>Notifications: Creating notifications should succeed when permission has been granted.</title>
5 <script src="../resources/testharness.js"></script>
6 <script src="../resources/testharnessreport.js"></script>
7 </head>
8 <body>
9 <script>
10 // Tests that Notification.requestPermission() returns "granted" when
11 // permission has been granted, causing creation of notifications to
12 // succeed. When running this test manually, accept permission
13 // for displaying notifications prior to running the test.
14 async_test(function (test) {
15 testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
16 Notification.requestPermission(function (status) {
17 assert_equals(status, 'granted');
19 var notification = new Notification('My Notification');
20 notification.addEventListener('show', function() {
21 test.done();
22 });
24 notification.addEventListener('error', function() {
25 assert_unreached('The notification is expected to be shown.');
26 });
27 });
29 }, 'Notification creation succeeds when permission has been granted.');
30 </script>
31 </body>
32 </html>