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

Unified Diff: LayoutTests/http/tests/notifications/serviceworkerregistration-document-data-reflection.html

Issue 1095093002: Add layouttest for notification properties of persistent notification (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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-document-data-reflection.html
diff --git a/LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-reflection.html b/LayoutTests/http/tests/notifications/serviceworkerregistration-document-data-reflection.html
similarity index 54%
copy from LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-reflection.html
copy to LayoutTests/http/tests/notifications/serviceworkerregistration-document-data-reflection.html
index 23d34c282dbd2d02682e2ff1b16096bb2234f97b..1dc0ce6cc3744016e9dde0fa002ac6ce529e8ab1 100644
--- a/LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-reflection.html
+++ b/LayoutTests/http/tests/notifications/serviceworkerregistration-document-data-reflection.html
@@ -9,9 +9,8 @@
</head>
<body>
<script>
- // 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.
+ // Tests that the Persistent Notification object exposes the data property per the
+ // semantics defined by the specification.
async_test(function(test) {
var scope = 'resources/scope/' + location.pathname,
@@ -19,31 +18,20 @@
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,
- data: [
- { property: 'foobar',
- string: '\uDFFF\u0000\uDBFF',
- scalar: true },
- 12.15
- ]
};
testRunner.grantWebNotificationPermission(location.origin, true);
getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(workerInfo) {
- // (1) Tell the Service Worker to display a Web Notification.
- workerInfo.port.postMessage({
- command: 'show',
- title: scope,
- options: options
- });
+ var assertNotificationDataReflects = function(value) {
+ // (1) Display a Web Notification from the document.
+ options.data = value;
+ workerInfo.port.postMessage({
+ command: 'show',
+ title: scope,
+ options: options
+ });
+ }
workerInfo.port.addEventListener('message', function(event) {
if (typeof event.data != 'object' || !event.data.command) {
@@ -60,23 +48,28 @@
}
// (3) Listen for confirmation from the Service Worker that the
- // notification has been clicked on. Make sure that all properties
+ // notification has been clicked on. Make sure that data properties
// set on the Notification object are as expected.
- assert_equals(event.data.command, 'click', 'The notification was expected to be clicked.');
+ if (typeof options.data === 'object')
+ assert_object_equals(event.data.notification.data, data, 'The data field must be the same.');
+ else
+ assert_equals(event.data.notification.data, options.data, 'The data field must be the same.');
Peter Beverloo 2015/04/21 12:26:36 Does this test pass? The chronology is rather odd
Sanghyun Park 2015/04/21 13:38:34 Oops, I had mistake. I'll re-make this.
+ });
+ assertNotificationDataReflects(true); // Check Boolean type
+ assertNotificationDataReflects(1024); // Check Number type
+ assertNotificationDataReflects(Number.NaN); // Check Number.NaN type
+ assertNotificationDataReflects('any data'); // Check String type
- Object.keys(options).forEach(function(key) {
- if (key == 'data')
- return; // Check "data" separately to avoid stringifying it.
+ var cars = new Array('Saab', 'Volvo', 'BMW');
+ assertNotificationDataReflects(cars); // Check Array type
- assert_equals(event.data.notification[key], options[key], 'The ' + key + ' field must be the same.');
- });
+ var obj = { first: 'first', second: 'second'};
+ assertNotificationDataReflects(obj); // Check Object
- assert_object_equals(event.data.notification.data, options.data, 'The data field must be the same.');
-
- test.done();
- });
+ test.done();
}).catch(unreached_rejection(test));
+
}, 'Clicking on a notification displayed by a Service Worker the notificationclick event.');
</script>
</body>

Powered by Google App Engine
This is Rietveld 408576698