Index: third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-document-direction.html |
diff --git a/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-document-direction.html b/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-document-direction.html |
index 71fe2a3cec5349d88f64b435683346887d79911c..95455320e3a4e51af538d23776e140425271490b 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-document-direction.html |
+++ b/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-document-direction.html |
@@ -14,36 +14,28 @@ |
// This test requires the test runner. |
async_test(function(test) { |
- var scope = 'resources/spec/' + location.pathname, |
- script = 'resources/instrumentation-service-worker.js'; |
+ var scope = 'resources/spec/' + location.pathname; |
+ var script = 'instrumentation-service-worker.js'; |
+ var port; |
testRunner.setPermission('notifications', 'granted', location.origin, location.origin); |
- var workerInfo = null; |
getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(info) { |
- workerInfo = info; |
+ port = info.port; |
// (1) Display a Web Notification from the document. |
- return workerInfo.registration.showNotification(scope, { |
+ return info.registration.showNotification(scope, { |
dir: 'rtl' |
}); |
}).then(function() { |
// (2) Simulate a click on the notification that has been displayed. |
- testRunner.simulateWebNotificationClick(scope, -1 /* action_index */); |
+ return simulateNotificationClick(scope, -1 /* action_index */, port); |
+ }).then(function(data) { |
+ // (3) Verify that the click event was received by the Service Worker, |
+ // and that the correct direction was passed along. |
+ assert_equals(data.notification.dir, 'rtl'); |
- workerInfo.port.addEventListener('message', function(event) { |
- if (typeof event.data != 'object' || !event.data.command) { |
- assert_unreached('Received an invalid message from the Service Worker.'); |
- return; |
- } |
- |
- // (3) Verify that the click event was received by the Service Worker, |
- // and that the correct direction was passed along. |
- assert_equals(event.data.command, 'click'); |
- assert_equals(event.data.notification.dir, 'rtl'); |
- |
- test.done(); |
- }); |
+ test.done(); |
}).catch(unreached_rejection(test)); |
}, 'Clicking on a notification displayed through showNotification() fires a Service Worker event with the correct notification direction'); |