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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-no-permission.html

Issue 1907443007: Use promises in notifications tests and enable controlling the page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Address peter's comments. Created 4 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 <script src="resources/test-helpers.js"></script> 8 <script src="resources/test-helpers.js"></script>
9 </head> 9 </head>
10 <body> 10 <body>
11 <script> 11 <script>
12 // Tests that the showNotification() function when used in a Service Worke r 12 // Tests that the showNotification() function when used in a Service Worke r
13 // rejects when no permission has been granted. This test requires the tes t runner. 13 // rejects when no permission has been granted. This test requires the tes t runner.
14 14
15 async_test(function(test) { 15 async_test(function(test) {
16 var scope = 'resources/scope/serviceworkerregistration-service-worker- click', 16 var scope = 'resources/scope/serviceworkerregistration-service-worker- click',
17 script = 'resources/instrumentation-service-worker.js'; 17 script = 'instrumentation-service-worker.js';
18 18
19 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(workerInfo) { 19 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(info) {
20 // (1) Tell the Service Worker to display a Web Notification. 20 // (1) Tell the Service Worker to display a Web Notification.
21 workerInfo.port.postMessage({ 21 return sendCommand(info.port, {
22 command: 'show', 22 command: 'show',
23 23
24 title: 'My Notification', 24 title: 'My Notification',
25 options: { body: 'Hello, world!' } 25 options: { body: 'Hello, world!' }
26 }); 26 });
27 }).then(function(data) {
28 // (2) Confirm that the service worker could not display the notif ication due to a
29 // permission error.
30 assert_false(data.success);
31 assert_equals(data.message, 'No notification permission has been g ranted for this origin.');
27 32
28 workerInfo.port.addEventListener('message', function(event) { 33 test.done();
29 if (typeof event.data != 'object' || !event.data.command) {
30 assert_unreached('Invalid message from the Service Worker. ');
31 return;
32 }
33
34 // (2) Listen for confirmation from the Service Worker that th e
35 // notification could not be displayed because of a permission error.
36 assert_equals(event.data.command, 'show');
37
38 assert_false(event.data.success);
39 assert_equals(event.data.message, 'No notification permission has been granted for this origin.');
40
41 test.done();
42 });
43 }).catch(unreached_rejection(test)); 34 }).catch(unreached_rejection(test));
44 35
45 }, 'showNotification() must reject if no Web Notification permission has b een granted.'); 36 }, 'showNotification() must reject if no Web Notification permission has b een granted.');
46 </script> 37 </script>
47 </body> 38 </body>
48 </html> 39 </html>
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-image-slow-404.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698