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

Unified Diff: LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-reflection.html

Issue 965463003: Remove an old constructor from WebNotificationData, add a layout test. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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/serviceworker-notificationclick-event-reflection.html
diff --git a/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-click.html b/LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-reflection.html
similarity index 56%
copy from LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-click.html
copy to LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-reflection.html
index c3ddb73bf42f527ce652cc186ccc81536daba6d0..7f5fb86af852a90fea877b8a81db6442d05331bc 100644
--- a/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-click.html
+++ b/LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-reflection.html
@@ -1,7 +1,7 @@
<!doctype html>
<html>
<head>
- <title>Notifications: ServiceWorkerRegistration.showNotification().</title>
+ <title>Notifications: Property reflection in the "notificationclick" event.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../serviceworker/resources/test-helpers.js"></script>
@@ -9,14 +9,26 @@
</head>
<body>
<script>
- // Tests that the showNotification() function when used in a Service Worker
- // resolves a promise, and that the notificationclick event gets fired when
- // we simulate a click on it. This test requires the test runner.
+ // Tests that the notification available in the "notificationclick" event in the
+ // Service Worker accurately reflects the attributes with which the notification
+ // was created (for this test --) in the document.
async_test(function(test) {
- var scope = 'resources/scope/serviceworkerregistration-service-worker-click',
+ var scope = 'resources/scope/' + location.pathname,
script = 'resources/instrumentation-service-worker.js';
+ var options = {
+ title: scope,
+ dir: 'rtl',
+ lang: 'nl-NL',
+ body: 'Hello, world!',
+ tag: 'tag',
+ // FIXME: Relative URLs for the icon attribute currently get reflected as
+ // an absolute URL, which should probably be the given relative URL.
+ icon: 'https://example/icon.png',
+ silent: true
+ };
+
testRunner.grantWebNotificationPermission(location.origin, true);
getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(workerInfo) {
// (1) Tell the Service Worker to display a Web Notification.
@@ -24,7 +36,7 @@
command: 'show',
title: scope,
- options: { body: 'Hello, world!' }
+ options: options
});
workerInfo.port.addEventListener('message', function(event) {
@@ -42,15 +54,15 @@
}
// (3) Listen for confirmation from the Service Worker that the
- // notification has been clicked on.
- if (event.data.command == 'click') {
- assert_equals(event.data.notification.title, scope, 'The right notification must have been clicked.');
+ // notification has been clicked on. Make sure that all properties
+ // set on the Notification object are as expected.
+ assert_equals(event.data.command, 'click', 'The notification was expected to be clicked.');
- test.done();
- return;
- }
+ Object.keys(options).forEach(function(key) {
+ assert_equals(event.data.notification[key], options[key], 'The ' + key + ' field must be the same.');
+ });
- assert_unreached('Unexpected message from the Service Worker: ' + event.data.command);
+ test.done();
});
}).catch(unreached_rejection(test));

Powered by Google App Engine
This is Rietveld 408576698