4 <title>Notifications: The Notification.permission property reflects the permission status.
</title>
5 <script src=
"../resources/testharness.js"></script>
6 <script src=
"../resources/testharnessreport.js"></script>
10 // Tests that the Notification.permission property reflects the current
11 // permission level of notifications for the current origin. This test
12 // requires the TestRunner.
13 // This test is doing some hacks to make sure the internal representation
14 // is correctly updated before calling Notification.permission because
15 // testRunner.setPermission() and Notification.permission might end up
16 // in a race given the synchronous aspect of the latter.
17 var notificationsPermissionsTest
= async_test("Notification.permission reflects th actual permission.");
22 testRunner
.setPermission('notifications', 'prompt', location
.origin
, location
.origin
);
23 navigator
.permissions
.query({name
:'notifications'}).then(function() {
24 // "default" indicates that no permission request has been answered.
25 assert_equals(Notification
.permission
, 'default');
27 notificationsPermissionsTest
.step(tests
[++testIndex
]);
31 testRunner
.setPermission('notifications', 'denied', location
.origin
, location
.origin
);
32 navigator
.permissions
.query({name
:'notifications'}).then(function() {
33 // "default" indicates that no permission request has been answered.
34 assert_equals(Notification
.permission
, 'denied');
36 notificationsPermissionsTest
.step(tests
[++testIndex
]);
40 testRunner
.setPermission('notifications', 'granted', location
.origin
, location
.origin
);
41 navigator
.permissions
.query({name
:'notifications'}).then(function() {
42 // "default" indicates that no permission request has been answered.
43 assert_equals(Notification
.permission
, 'granted');
45 notificationsPermissionsTest
.step(tests
[++testIndex
]);
49 notificationsPermissionsTest
.done();
53 notificationsPermissionsTest
.step(function() {
54 if (!window
.testRunner
) {
55 assert_unreached('This test requires the TestRunner for working correctly.');
58 notificationsPermissionsTest
.step(tests
[testIndex
]);