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

Unified 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 side-by-side diff with in-line comments
Download patch
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');

Powered by Google App Engine
This is Rietveld 408576698