Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Unified Diff: LayoutTests/http/tests/notifications/permission-document.html

Issue 1097383006: Notifications: use testRunner.setPermission() in addition of grantWebNotificationPermission. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cleanup
Patch Set: fix expectations Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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>

Powered by Google App Engine
This is Rietveld 408576698