Index: LayoutTests/http/tests/notifications/permission-document.html |
diff --git a/LayoutTests/http/tests/notifications/permission-document.html b/LayoutTests/http/tests/notifications/permission-document.html |
index af9e2f24e172e2cb70a26fdc5e64b1e99fa21c01..7c1ecdf69ccf2816a6d55f9062fe4d28e666edb4 100644 |
--- a/LayoutTests/http/tests/notifications/permission-document.html |
+++ b/LayoutTests/http/tests/notifications/permission-document.html |
@@ -10,27 +10,64 @@ |
// Tests that the Notification.permission property reflects the current |
// permission level of notifications for the current origin. This test |
// requires the TestRunner. |
- if (window.testRunner) |
+ // This test is doing some hacks to make sure the internal representation |
+ // is correctly updated before calling Notification.permission because |
+ // testRunner.setPermission() and Notification.permission might end up |
+ // in a race given the synchronous aspect of the latter. |
+ if (window.testRunner) { |
+ testRunner.setPermission('notifications', 'granted', location.origin, location.origin); |
testRunner.grantWebNotificationPermission(location.origin, true); |
+ } |
- test(function () { |
- if (!window.testRunner) { |
- assert_unreached('This test requires the TestRunner for working correctly.'); |
- return; |
- } |
+ var notificationsPermissionsTest = async_test("Notification.permission reflects th actual permission."); |
+ var testIndex = 0; |
+ var tests = [ |
+ function() { |
+ testRunner.setPermission('notifications', 'prompt', location.origin, location.origin); |
testRunner.clearWebNotificationPermissions(); |
- // "default" indicates that no permission request has been answered. |
- assert_equals(Notification.permission, "default"); |
+ navigator.permissions.query({name:'notifications'}).then(function() { |
+ // "default" indicates that no permission request has been answered. |
+ assert_equals(Notification.permission, 'default'); |
+ notificationsPermissionsTest.step(tests[++testIndex]); |
+ }); |
+ }, |
+ function() { |
+ testRunner.setPermission('notifications', 'denied', location.origin, location.origin); |
testRunner.grantWebNotificationPermission(location.origin, false); |
- assert_equals(Notification.permission, "denied"); |
+ navigator.permissions.query({name:'notifications'}).then(function() { |
+ // "default" indicates that no permission request has been answered. |
+ assert_equals(Notification.permission, 'denied'); |
+ |
+ notificationsPermissionsTest.step(tests[++testIndex]); |
+ }); |
+ }, |
+ function () { |
+ testRunner.setPermission('notifications', 'granted', location.origin, location.origin); |
testRunner.grantWebNotificationPermission(location.origin, true); |
- assert_equals(Notification.permission, "granted"); |
- }, 'Notification.permission reflects the actual permission level.'); |
+ navigator.permissions.query({name:'notifications'}).then(function() { |
+ // "default" indicates that no permission request has been answered. |
+ assert_equals(Notification.permission, 'granted'); |
+ |
+ notificationsPermissionsTest.step(tests[++testIndex]); |
+ }); |
+ }, |
+ function () { |
+ notificationsPermissionsTest.done(); |
+ } |
+ ]; |
+ |
+ notificationsPermissionsTest.step(function() { |
+ if (!window.testRunner) { |
+ assert_unreached('This test requires the TestRunner for working correctly.'); |
+ return; |
+ } |
+ notificationsPermissionsTest.step(tests[testIndex]); |
+ }); |
</script> |
</body> |
-</html> |
+</html> |