| Index: LayoutTests/http/tests/notifications/serviceworkerregistration-get.html
|
| diff --git a/LayoutTests/http/tests/notifications/serviceworkerregistration-get.html b/LayoutTests/http/tests/notifications/serviceworkerregistration-get.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..04462b1d4f1db4be0cf1ebe365976711e273763b
|
| --- /dev/null
|
| +++ b/LayoutTests/http/tests/notifications/serviceworkerregistration-get.html
|
| @@ -0,0 +1,54 @@
|
| +<!doctype html>
|
| +<html>
|
| + <head>
|
| + <title>Notifications: ServiceWorkerRegistration.getNotifications().</title>
|
| + <script src="../resources/testharness.js"></script>
|
| + <script src="../resources/testharnessreport.js"></script>
|
| + <script src="../serviceworker/resources/test-helpers.js"></script>
|
| + <script src="resources/test-helpers.js"></script>
|
| + </head>
|
| + <body>
|
| + <script>
|
| + // Tests that the getNotifications() function when used in a document returns
|
| + // an array of the notifications which were previously displayed using the
|
| + // same Service Worker registration id.
|
| + async_test(function(test) {
|
| + var scope = 'resources/scope/' + location.pathname,
|
| + script = 'resources/instrumentation-service-worker.js';
|
| +
|
| + testRunner.grantWebNotificationPermission(location.origin, true);
|
| +
|
| + var registration = null;
|
| + getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(workerInfo) {
|
| + registration = workerInfo.registration;
|
| +
|
| + return registration.showNotification('Hello, world!', {
|
| + body: 'First notification'
|
| + });
|
| + }).then(function() {
|
| + return registration.showNotification('Hello again, world!', {
|
| + body: 'Second notification'
|
| + });
|
| + }).then(function() {
|
| + return registration.getNotifications();
|
| + }).then(function(notifications) {
|
| + 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;
|
| +
|
| + 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');
|
| +
|
| + test.done();
|
| + }).catch(unreached_rejection(test));
|
| +
|
| + }, 'ServiceWorkerRegistration.getNotifications() returns the opened notifications.');
|
| + </script>
|
| + </body>
|
| +</html>
|
|
|