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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-get-from-service-worker.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-get-from-service-worker.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-get-from-service-worker.html b/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-get-from-service-worker.html
index c8e7742de65d8b8aba72487ed6ca733e331656bf..f813359fc172c8de84d41bfca110f37e61b652c0 100644
--- a/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-get-from-service-worker.html
+++ b/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-get-from-service-worker.html
@@ -13,38 +13,29 @@
// an array of the notifications which were previously displayed by the
// Service Worker.
async_test(function(test) {
- var scope = 'resources/scope/' + location.pathname,
- script = 'resources/instrumentation-service-worker.js';
+ var scope = 'resources/scope/' + location.pathname;
+ var script = 'instrumentation-service-worker.js';
+ var port;
+ var registration;
testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
- var info = null;
- getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(workerInfo) {
- info = workerInfo;
+ getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(info) {
+ port = info.port;
+ registration = info.registration;
// (1) Tell the Service Worker to display a new Notification and wait for it
// to have been displayed to the user.
- info.port.postMessage({
+ return sendCommand(port, {
command: 'show',
title: scope,
options: { body: 'Hello, world!' }
});
-
- return new Promise(function(resolve) {
- info.port.addEventListener('message', function(event) {
- if (typeof event.data != 'object' || !event.data.command) {
- assert_unreached('Invalid message from the Service Worker.');
- return;
- }
-
- assert_equals(event.data.command, 'show');
- resolve();
- });
- });
- }).then(function() {
+ }).then(function(data) {
+ assert_true(data.success);
// (2) Get a list of all notifications in the document.
- return info.registration.getNotifications();
+ return registration.getNotifications();
}).then(function(notifications) {
// (3) Verify that there's only one notification: the one we just showed.
assert_equals(notifications.length, 1);

Powered by Google App Engine
This is Rietveld 408576698