Index: third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-get.html |
diff --git a/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-get.html b/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-get.html |
index 29fd74cf7c09ced17a3cbabf201a3b7e0062c21d..a46fcf6eb1cdf9857720f07da3fadc780cc0b836 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-get.html |
+++ b/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-get.html |
@@ -14,7 +14,7 @@ |
// the same Service Worker registration id. |
async_test(function(test) { |
var scope = 'resources/scope/' + location.pathname, |
- script = 'resources/instrumentation-service-worker.js'; |
+ script = 'instrumentation-service-worker.js'; |
testRunner.setPermission('notifications', 'granted', location.origin, location.origin); |
@@ -32,37 +32,27 @@ |
}); |
}).then(function() { |
// (2) Request the Service Worker to give us all notifications. |
- info.port.postMessage({ |
- command: 'get' |
- }); |
- |
- info.port.addEventListener('message', function(event) { |
- if (typeof event.data != 'object' || !event.data.command) { |
- assert_unreached('Invalid message from the Service Worker.'); |
- return; |
- } |
+ return sendCommand(info.port, { command: 'get' }); |
+ }).then(function(data) { |
+ // (3) Confirm that the Service Worker was able to read both of them. |
+ assert_true(data.success); |
- // (3) Confirm that the Service Worker was able to read both of them. |
- assert_equals(event.data.command, 'get'); |
- assert_true(event.data.success); |
+ var notifications = data.notifications; |
- var notifications = event.data.notifications; |
+ assert_equals(notifications.length, 2); |
- assert_equals(notifications.length, 2); |
+ // We don't want to make any promises about the order of the |
+ // returned notifications in |notifications|. |
+ var firstIndex = notifications[0].title == 'Hello, world!' ? 0 : 1; |
+ var secondIndex = firstIndex ? 0 : 1; |
- // We don't want to make any promises about the order of the |
- // returned notifications in |notifications|. |
- var firstIndex = notifications[0].title == 'Hello, world!' ? 0 : 1; |
- var secondIndex = firstIndex ? 0 : 1; |
+ assert_equals(notifications[firstIndex].title, 'Hello, world!'); |
+ assert_equals(notifications[firstIndex].body, 'First notification'); |
- assert_equals(notifications[firstIndex].title, 'Hello, world!'); |
- assert_equals(notifications[firstIndex].body, 'First notification'); |
+ assert_equals(notifications[secondIndex].title, 'Hello again, world!'); |
+ assert_equals(notifications[secondIndex].body, 'Second notification'); |
- assert_equals(notifications[secondIndex].title, 'Hello again, world!'); |
- assert_equals(notifications[secondIndex].body, 'Second notification'); |
- |
- test.done(); |
- }); |
+ test.done(); |
}).catch(unreached_rejection(test)); |
}, 'ServiceWorkerRegistration.getNotifications() returns the opened notifications within a Service Worker.'); |