4 <title>Notifications: ServiceWorkerRegistration.showNotification() shows notification with correct notification direction.
</title>
5 <script src=
"../resources/testharness.js"></script>
6 <script src=
"../resources/testharnessreport.js"></script>
7 <script src=
"../serviceworker/resources/test-helpers.js"></script>
8 <script src=
"resources/test-helpers.js"></script>
12 // Tests that the showNotification() function resolves a promise, and that the
13 // notificationclick event gets fired with the correct notification direction.
14 // This test requires the test runner.
16 async_test(function(test
) {
17 var scope
= 'resources/spec/' + location
.pathname
,
18 script
= 'resources/instrumentation-service-worker.js';
20 testRunner
.setPermission('notifications', 'granted', location
.origin
, location
.origin
);
22 var workerInfo
= null;
23 getActiveServiceWorkerWithMessagePort(test
, script
, scope
).then(function(info
) {
26 // (1) Display a Web Notification from the document.
27 return workerInfo
.registration
.showNotification(scope
, {
31 // (2) Simulate a click on the notification that has been displayed.
32 testRunner
.simulateWebNotificationClick(scope
);
34 workerInfo
.port
.addEventListener('message', function(event
) {
35 if (typeof event
.data
!= 'object' || !event
.data
.command
) {
36 assert_unreached('Received an invalid message from the Service Worker.');
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');
47 }).catch(unreached_rejection(test
));
49 }, 'Clicking on a notification displayed through showNotification() fires a Service Worker event with the correct notification direction');