Index: LayoutTests/http/tests/notifications/serviceworkerregistration-get-close.html |
diff --git a/LayoutTests/http/tests/notifications/serviceworkerregistration-get-close.html b/LayoutTests/http/tests/notifications/serviceworkerregistration-get-close.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6f70d9982ed17fb4153505bd07b85306a9097ed7 |
--- /dev/null |
+++ b/LayoutTests/http/tests/notifications/serviceworkerregistration-get-close.html |
@@ -0,0 +1,45 @@ |
+<!doctype html> |
+<html> |
+ <head> |
+ <title>Notifications: ServiceWorkerRegistration.getNotifications() and closing notifications.</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, and that closing |
+ // one of them reflects when getting the notifications again. |
+ 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.getNotifications(); |
+ }).then(function(notifications) { |
+ assert_equals(notifications.length, 1); |
+ assert_equals(notifications[0].title, 'Hello, world!'); |
+ |
+ notifications[0].close(); |
+ |
+ return registration.getNotifications(); |
+ }).then(function(notifications) { |
+ assert_equals(notifications.length, 0); |
+ test.done(); |
+ }).catch(unreached_rejection(test)); |
+ |
+ }, 'ServiceWorkerRegistration.getNotifications() reflects closing notifications.'); |
+ </script> |
+ </body> |
+</html> |