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

Unified Diff: LayoutTests/http/tests/notifications/notification-properties.html

Issue 1263043002: Add NotificationOptions.actions so websites can provide buttons (blink) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Tweak SW test Created 5 years, 5 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/notification-properties.html
diff --git a/LayoutTests/http/tests/notifications/notification-properties.html b/LayoutTests/http/tests/notifications/notification-properties.html
index 01f10f9edfb7c8b8641f58a7174c25903001e1f4..0a23769a106b6a2bee5bed36f32b399a1f0151ac 100644
--- a/LayoutTests/http/tests/notifications/notification-properties.html
+++ b/LayoutTests/http/tests/notifications/notification-properties.html
@@ -20,8 +20,15 @@
tag: "notification",
icon: "http://localhost/my_icon.png",
silent: true,
- data: "my data"
+ data: "my data",
+ actions: []
};
+ // Deliberately add more actions than are supported.
+ for (var i = 0; i < 2 * Notification.maxActions; i++) {
+ options.actions.push({
+ title: "Action " + i
+ });
+ }
var notification = new Notification("My Notification", options);
@@ -33,6 +40,17 @@
assert_equals(notification.icon, options.icon);
assert_true(notification.silent);
assert_equals(notification.data, options.data);
+ // Only the first maxActions actions should be reflected.
+ assert_object_equals(notification.actions, options.actions.slice(0, Notification.maxActions));
+
+ // Notification.actions should be immutable.
+ notification.actions.push({ title: "Foo" });
+ notification.actions.foo = "bar";
+ if (notification.actions.length) {
+ notification.actions[0].title = "Changed";
+ notification.actions[0].foo = "bar";
+ }
+ assert_object_equals(notification.actions, options.actions.slice(0, Notification.maxActions));
var emptyNotification = new Notification("My Notification");
@@ -45,6 +63,7 @@
assert_equals(notification.vibrate, null);
assert_false(emptyNotification.silent);
assert_equals(emptyNotification.data, null);
+ assert_array_equals(emptyNotification.actions, []);
var invalidIconNotification = new Notification("My Notification", {
icon: "http://test:test/"
@@ -104,6 +123,19 @@
});
}, 'Set vibrate, when silent is true.');
+ // Check exception is thrown when an action doesn't contain title,
+ // or title is an empty string.
+ assert_throws(new TypeError(), function() {
+ var notification = new Notification("My Notification", {
+ actions: [{}]
+ });
+ }, 'Provide action without title.');
+ assert_throws(new TypeError(), function() {
+ var notification = new Notification("My Notification", {
+ actions: [{title: ""}]
+ });
+ }, 'Provide action with empty title.');
+
}, 'Checks the properties exposed on the Notification object.');
</script>
</body>

Powered by Google App Engine
This is Rietveld 408576698