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

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

Issue 1309273007: Add requireInteraction to Notification & NotificationOptions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@constructor
Patch Set: Add to NotificationDataTest.cpp Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-reflection.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Notifications: The Notification object exposes the expected propertie s.</title> 4 <title>Notifications: The Notification object exposes the expected propertie s.</title>
5 <script src="../resources/testharness.js"></script> 5 <script src="../resources/testharness.js"></script>
6 <script src="../resources/testharnessreport.js"></script> 6 <script src="../resources/testharnessreport.js"></script>
7 </head> 7 </head>
8 <body> 8 <body>
9 <script> 9 <script>
10 // Tests that the Notification object exposes the properties per the 10 // Tests that the Notification object exposes the properties per the
11 // semantics defined by the specification. When the test is being ran 11 // semantics defined by the specification. When the test is being ran
12 // manually, grant Notification permission first. 12 // manually, grant Notification permission first.
13 test(function () { 13 test(function () {
14 assert_greater_than_equal(Notification.maxActions, 0); 14 assert_greater_than_equal(Notification.maxActions, 0);
15 15
16 var options = { 16 var options = {
17 dir: "rtl", 17 dir: "rtl",
18 lang: "nl-NL", 18 lang: "nl-NL",
19 body: "Hallo, wereld!", 19 body: "Hallo, wereld!",
20 tag: "notification", 20 tag: "notification",
21 icon: "http://localhost/my_icon.png", 21 icon: "http://localhost/my_icon.png",
22 silent: true, 22 silent: true,
23 requireInteraction: true,
23 data: "my data", 24 data: "my data",
24 actions: [] 25 actions: []
25 }; 26 };
26 // Deliberately add more actions than are supported. 27 // Deliberately add more actions than are supported.
27 for (var i = 0; i < 2 * Notification.maxActions; i++) { 28 for (var i = 0; i < 2 * Notification.maxActions; i++) {
28 options.actions.push({ 29 options.actions.push({
29 action: "" + i, 30 action: "" + i,
30 title: "Action " + i 31 title: "Action " + i
31 }); 32 });
32 } 33 }
33 34
34 var notification = new Notification("My Notification", options); 35 var notification = new Notification("My Notification", options);
35 36
36 assert_equals(notification.title, "My Notification"); 37 assert_equals(notification.title, "My Notification");
37 assert_equals(notification.dir, options.dir); 38 assert_equals(notification.dir, options.dir);
38 assert_equals(notification.lang, options.lang); 39 assert_equals(notification.lang, options.lang);
39 assert_equals(notification.body, options.body); 40 assert_equals(notification.body, options.body);
40 assert_equals(notification.tag, options.tag); 41 assert_equals(notification.tag, options.tag);
41 assert_equals(notification.icon, options.icon); 42 assert_equals(notification.icon, options.icon);
42 assert_true(notification.silent); 43 assert_true(notification.silent);
44 assert_true(notification.requireInteraction);
43 assert_equals(notification.data, options.data); 45 assert_equals(notification.data, options.data);
44 // Only the first maxActions actions should be reflected. 46 // Only the first maxActions actions should be reflected.
45 assert_object_equals(notification.actions, options.actions.slice(0, Notification.maxActions)); 47 assert_object_equals(notification.actions, options.actions.slice(0, Notification.maxActions));
46 48
47 // Notification.actions should be immutable. 49 // Notification.actions should be immutable.
48 notification.actions.push({ title: "Foo" }); 50 notification.actions.push({ title: "Foo" });
49 notification.actions.foo = "bar"; 51 notification.actions.foo = "bar";
50 if (notification.actions.length) { 52 if (notification.actions.length) {
51 notification.actions[0].title = "Changed"; 53 notification.actions[0].title = "Changed";
52 notification.actions[0].foo = "bar"; 54 notification.actions[0].foo = "bar";
53 } 55 }
54 assert_object_equals(notification.actions, options.actions.slice(0, Notification.maxActions)); 56 assert_object_equals(notification.actions, options.actions.slice(0, Notification.maxActions));
55 57
56 var emptyNotification = new Notification("My Notification"); 58 var emptyNotification = new Notification("My Notification");
57 59
58 assert_equals(emptyNotification.title, "My Notification"); 60 assert_equals(emptyNotification.title, "My Notification");
59 assert_equals(emptyNotification.dir, "auto"); 61 assert_equals(emptyNotification.dir, "auto");
60 assert_equals(emptyNotification.lang, ""); 62 assert_equals(emptyNotification.lang, "");
61 assert_equals(emptyNotification.body, ""); 63 assert_equals(emptyNotification.body, "");
62 assert_equals(emptyNotification.tag, ""); 64 assert_equals(emptyNotification.tag, "");
63 assert_equals(emptyNotification.icon, ""); 65 assert_equals(emptyNotification.icon, "");
64 assert_equals(notification.vibrate, null); 66 assert_equals(notification.vibrate, null);
65 assert_false(emptyNotification.silent); 67 assert_false(emptyNotification.silent);
68 assert_false(emptyNotification.requireInteraction);
66 assert_equals(emptyNotification.data, null); 69 assert_equals(emptyNotification.data, null);
67 assert_array_equals(emptyNotification.actions, []); 70 assert_array_equals(emptyNotification.actions, []);
68 71
69 var equalNotification = new Notification("My Notification", { 72 var equalNotification = new Notification("My Notification", {
70 vibrate: [50, 10, 50, 10, 50], 73 vibrate: [50, 10, 50, 10, 50],
71 data: { hello: "World!" }, 74 data: { hello: "World!" },
72 actions: [ 75 actions: [
73 { action: "foo", title: "Foo" }, 76 { action: "foo", title: "Foo" },
74 { action: "bar", title: "Bar" } 77 { action: "bar", title: "Bar" }
75 ] 78 ]
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 // Invalid vibrate pattern should be reset to 0. 117 // Invalid vibrate pattern should be reset to 0.
115 var invalidVibrateNotification = new Notification("My Notification", { 118 var invalidVibrateNotification = new Notification("My Notification", {
116 vibrate: [100, 200, "invalid"] 119 vibrate: [100, 200, "invalid"]
117 }); 120 });
118 assert_array_equals(invalidVibrateNotification.vibrate, [100, 200, 0 ]); 121 assert_array_equals(invalidVibrateNotification.vibrate, [100, 200, 0 ]);
119 122
120 }, 'Checks the properties exposed on the Notification object.'); 123 }, 'Checks the properties exposed on the Notification object.');
121 </script> 124 </script>
122 </body> 125 </body>
123 </html> 126 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-reflection.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698