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

Unified Diff: LayoutTests/http/tests/notifications/serviceworkerregistration-get-filter.html

Issue 1056573002: Introduce layout tests for SWR.getNotifications() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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: LayoutTests/http/tests/notifications/serviceworkerregistration-get-filter.html
diff --git a/LayoutTests/http/tests/notifications/serviceworkerregistration-get-filter.html b/LayoutTests/http/tests/notifications/serviceworkerregistration-get-filter.html
new file mode 100644
index 0000000000000000000000000000000000000000..265ad4ebd99fb11ab9be21cfd73da02ee0403485
--- /dev/null
+++ b/LayoutTests/http/tests/notifications/serviceworkerregistration-get-filter.html
@@ -0,0 +1,48 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Notifications: ServiceWorkerRegistration.getNotifications() with a filter.</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, having the same filter.
+ 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',
+ tag: 'banana',
+ });
+ }).then(function() {
+ return registration.showNotification('Hello again, world!', {
+ body: 'Second notification',
+ tag: 'strawberry',
+ });
+ }).then(function() {
+ return registration.getNotifications({ tag: 'strawberry' });
+ }).then(function(notifications) {
+ assert_equals(notifications.length, 1);
+
+ assert_equals(notifications[0].title, 'Hello again, world!');
+ assert_equals(notifications[0].body, 'Second notification');
+
+ test.done();
+ }).catch(unreached_rejection(test));
+
+ }, 'ServiceWorkerRegistration.getNotifications() returns the opened notifications with the same filter.');
+ </script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698