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

Side by Side Diff: LayoutTests/http/tests/notifications/serviceworkerregistration-document-not-activated.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 unified diff | Download patch
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Notifications: ServiceWorkerRegistration.showNotification().</title> 4 <title>Notifications: ServiceWorkerRegistration.showNotification().</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 <script src="../serviceworker/resources/test-helpers.js"></script> 7 <script src="../serviceworker/resources/test-helpers.js"></script>
8 </head> 8 </head>
9 <body> 9 <body>
10 <script> 10 <script>
11 // Tests that the showNotification() function rejects the returned promise with a 11 // Tests that the showNotification() function rejects the returned promise with a
12 // TypeError when the Service Worker is not activated yet. 12 // TypeError when the Service Worker is not activated yet.
13 async_test(function(test) { 13 async_test(function(test) {
14 var scope = 'resources/scope/service-worker-show-notification-not-acti vated', 14 var scope = 'resources/scope/service-worker-show-notification-not-acti vated',
15 workerUrl = 'resources/empty-worker.js'; 15 workerUrl = 'resources/empty-worker.js';
16 16
17 if (window.testRunner) 17 if (window.testRunner) {
18 testRunner.setPermission('notifications', 'denied', location.origi n, location.origin);
18 testRunner.grantWebNotificationPermission(location.origin, false); 19 testRunner.grantWebNotificationPermission(location.origin, false);
20 }
19 21
20 service_worker_unregister_and_register(test, workerUrl, scope).then(fu nction(registration) { 22 service_worker_unregister_and_register(test, workerUrl, scope).then(fu nction(registration) {
21 assert_inherits(registration, 'showNotification', 'showNotificatio n() must be exposed.'); 23 assert_inherits(registration, 'showNotification', 'showNotificatio n() must be exposed.');
22 registration.showNotification('Title', { 24 registration.showNotification('Title', {
23 body: 'Hello, world!', 25 body: 'Hello, world!',
24 icon: '/icon.png' 26 icon: '/icon.png'
25 }).then(function() { 27 }).then(function() {
26 assert_unreached('showNotification() is expected to reject.'); 28 assert_unreached('showNotification() is expected to reject.');
27 }).catch(function(error) { 29 }).catch(function(error) {
28 assert_equals(error.name, 'TypeError'); 30 assert_equals(error.name, 'TypeError');
29 assert_equals(error.message, 'No active registration available on the ServiceWorkerRegistration.'); 31 assert_equals(error.message, 'No active registration available on the ServiceWorkerRegistration.');
30 test.done(); 32 test.done();
31 }); 33 });
32 34
33 }).catch(unreached_rejection(test)); 35 }).catch(unreached_rejection(test));
34 36
35 }, 'showNotification() must reject if there is no active registration on t he ServiceWorkerRegistration.'); 37 }, 'showNotification() must reject if there is no active registration on t he ServiceWorkerRegistration.');
36 38
37 </script> 39 </script>
38 </body> 40 </body>
39 </html> 41 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698