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

Unified Diff: LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-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, 7 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-data-reflection.html
diff --git a/LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-reflection.html b/LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-data-reflection.html
similarity index 59%
copy from LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-reflection.html
copy to LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-data-reflection.html
index 577c4c5eacffbc6a52e53e91c626e9b24c06eb87..b168099f2036b37305a28cfdf889c752f8646b04 100644
--- a/LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-reflection.html
+++ b/LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-data-reflection.html
@@ -1,7 +1,7 @@
<!doctype html>
<html>
<head>
- <title>Notifications: Property reflection in the "notificationclick" event.</title>
+ <title>Notifications: data 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>
@@ -10,40 +10,38 @@
<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.
+ // Service Worker accurately reflects the data attributes of several type
+ // with which the notification was created (for this test --) in the document.
async_test(function(test) {
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,
- data: [
- { property: 'foobar',
- string: '\uDFFF\u0000\uDBFF',
- scalar: true },
- 12.15
- ]
- };
+ // Set notification's data of several type to a structured clone of options's data.
+ var notificationDataList = new Array(
+ true, // Check Boolean type
+ 1024, // Check Number type
+ Number.NaN, // Check Number.NaN type
+ 'any data', // Check String type
+ new Array('Saab', 'Volve', 'BMW'), // Check Array type
+ { first: 'first', second: 'second' } // Check object
+ );
testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(workerInfo) {
// (1) Tell the Service Worker to display a Web Notification.
- workerInfo.port.postMessage({
- command: 'show',
+ var assertNotificationDataReflects = function(pos) {
+ workerInfo.port.postMessage({
+ command: 'show',
- title: scope,
- options: options
- });
+ title: scope,
+ options: {
+ title: scope,
+ tag: pos,
+ data: notificationDataList[pos]
+ }
+ });
+ };
workerInfo.port.addEventListener('message', function(event) {
if (typeof event.data != 'object' || !event.data.command) {
@@ -64,17 +62,17 @@
// set on the Notification object are as expected.
assert_equals(event.data.command, 'click', 'The notification was expected to be clicked.');
- Object.keys(options).forEach(function(key) {
- if (key == 'data')
- return; // Check "data" separately to avoid stringifying it.
+ var pos = event.data.notification.tag;
- assert_equals(event.data.notification[key], options[key], 'The ' + key + ' field must be the same.');
- });
+ assert_object_equals(event.data.notification.data, notificationDataList[pos], 'The data field must be the same.');
- assert_object_equals(event.data.notification.data, options.data, 'The data field must be the same.');
-
- test.done();
+ if (pos < notificationDataList.length)
+ assertNotificationDataReflects(++pos);
+ else
+ test.done();
});
+
+ assertNotificationDataReflects(0);
Peter Beverloo 2015/05/14 16:13:36 How long does it take to run this test? I'm a bit
Sanghyun Park 2015/05/15 08:52:34 Results of the tests done, it takes less than one
}).catch(unreached_rejection(test));
}, 'Clicking on a notification displayed by a Service Worker the notificationclick event.');

Powered by Google App Engine
This is Rietveld 408576698