OLD | NEW |
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 priority: "high", |
21 icon: "http://localhost/my_icon.png", | 22 icon: "http://localhost/my_icon.png", |
22 silent: true, | 23 silent: 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); |
| 42 assert_equals(notification.priority, options.priority); |
41 assert_equals(notification.icon, options.icon); | 43 assert_equals(notification.icon, options.icon); |
42 assert_true(notification.silent); | 44 assert_true(notification.silent); |
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, ""); |
| 65 assert_equals(emptyNotification.priority, "normal"); |
63 assert_equals(emptyNotification.icon, ""); | 66 assert_equals(emptyNotification.icon, ""); |
64 assert_equals(notification.vibrate, null); | 67 assert_equals(notification.vibrate, null); |
65 assert_false(emptyNotification.silent); | 68 assert_false(emptyNotification.silent); |
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 invalidIconNotification = new Notification("My Notification", { | 72 var invalidIconNotification = new Notification("My Notification", { |
70 icon: "http://test:test/" | 73 icon: "http://test:test/" |
71 }); | 74 }); |
72 | 75 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 assert_throws(new TypeError(), function() { | 147 assert_throws(new TypeError(), function() { |
145 var notification = new Notification("My Notification", { | 148 var notification = new Notification("My Notification", { |
146 actions: [{action: "foo", title: ""}] | 149 actions: [{action: "foo", title: ""}] |
147 }); | 150 }); |
148 }, 'NotificationAction with empty title.'); | 151 }, 'NotificationAction with empty title.'); |
149 | 152 |
150 }, 'Checks the properties exposed on the Notification object.'); | 153 }, 'Checks the properties exposed on the Notification object.'); |
151 </script> | 154 </script> |
152 </body> | 155 </body> |
153 </html> | 156 </html> |
OLD | NEW |