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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-document-direction.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() shows not ification with correct notification direction.</title> 4 <title>Notifications: ServiceWorkerRegistration.showNotification() shows not ification with correct notification direction.</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 resolves a promise, and that the 12 // Tests that the showNotification() function resolves a promise, and that the
13 // notificationclick event gets fired with the correct notification direct ion. 13 // notificationclick event gets fired with the correct notification direct ion.
14 // This test requires the test runner. 14 // This test requires the test runner.
15 15
16 async_test(function(test) { 16 async_test(function(test) {
17 var scope = 'resources/spec/' + location.pathname, 17 var scope = 'resources/spec/' + location.pathname;
18 script = 'resources/instrumentation-service-worker.js'; 18 var script = 'instrumentation-service-worker.js';
19 var port;
19 20
20 testRunner.setPermission('notifications', 'granted', location.origin, location.origin); 21 testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
21 22
22 var workerInfo = null;
23 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(info) { 23 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(info) {
24 workerInfo = info; 24 port = info.port;
25 25
26 // (1) Display a Web Notification from the document. 26 // (1) Display a Web Notification from the document.
27 return workerInfo.registration.showNotification(scope, { 27 return info.registration.showNotification(scope, {
28 dir: 'rtl' 28 dir: 'rtl'
29 }); 29 });
30 }).then(function() { 30 }).then(function() {
31 // (2) Simulate a click on the notification that has been displaye d. 31 // (2) Simulate a click on the notification that has been displaye d.
32 testRunner.simulateWebNotificationClick(scope, -1 /* action_index */); 32 return simulateNotificationClick(scope, -1 /* action_index */, por t);
33 }).then(function(data) {
34 // (3) Verify that the click event was received by the Service Wor ker,
35 // and that the correct direction was passed along.
36 assert_equals(data.notification.dir, 'rtl');
33 37
34 workerInfo.port.addEventListener('message', function(event) { 38 test.done();
35 if (typeof event.data != 'object' || !event.data.command) {
36 assert_unreached('Received an invalid message from the Ser vice Worker.');
37 return;
38 }
39
40 // (3) Verify that the click event was received by the Service Worker,
41 // and that the correct direction was passed along.
42 assert_equals(event.data.command, 'click');
43 assert_equals(event.data.notification.dir, 'rtl');
44
45 test.done();
46 });
47 }).catch(unreached_rejection(test)); 39 }).catch(unreached_rejection(test));
48 40
49 }, 'Clicking on a notification displayed through showNotification() fires a Service Worker event with the correct notification direction'); 41 }, 'Clicking on a notification displayed through showNotification() fires a Service Worker event with the correct notification direction');
50 </script> 42 </script>
51 </body> 43 </body>
52 </html> 44 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698