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 icon: "http://localhost/my_icon.png", | 21 icon: "http://localhost/my_icon.png", |
22 silent: true, | 22 silent: true, |
23 data: "my data", | 23 data: "my data", |
24 actions: [] | 24 actions: [] |
25 }; | 25 }; |
26 // Deliberately add more actions than are supported. | 26 // Deliberately add more actions than are supported. |
27 for (var i = 0; i < 2 * Notification.maxActions; i++) { | 27 for (var i = 0; i < 2 * Notification.maxActions; i++) { |
28 options.actions.push({ | 28 options.actions.push({ |
29 action: "" + i, | |
Peter Beverloo
2015/07/31 18:05:34
No need for "" (bindings should do that for you)
johnme
2015/07/31 18:14:22
Done.
| |
29 title: "Action " + i | 30 title: "Action " + i |
30 }); | 31 }); |
31 } | 32 } |
32 | 33 |
33 var notification = new Notification("My Notification", options); | 34 var notification = new Notification("My Notification", options); |
34 | 35 |
35 assert_equals(notification.title, "My Notification"); | 36 assert_equals(notification.title, "My Notification"); |
36 assert_equals(notification.dir, options.dir); | 37 assert_equals(notification.dir, options.dir); |
37 assert_equals(notification.lang, options.lang); | 38 assert_equals(notification.lang, options.lang); |
38 assert_equals(notification.body, options.body); | 39 assert_equals(notification.body, options.body); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 Array.apply(null, new Array(99)).map(Number.prototype.valueO f, 10000)); | 117 Array.apply(null, new Array(99)).map(Number.prototype.valueO f, 10000)); |
117 | 118 |
118 // Verifying the exception throwing behavior, when silent set true a nd vibrate is presented. | 119 // Verifying the exception throwing behavior, when silent set true a nd vibrate is presented. |
119 assert_throws(new TypeError(), function() { | 120 assert_throws(new TypeError(), function() { |
120 var notification = new Notification("My Notification", { | 121 var notification = new Notification("My Notification", { |
121 silent: true, | 122 silent: true, |
122 vibrate: 1000 | 123 vibrate: 1000 |
123 }); | 124 }); |
124 }, 'Set vibrate, when silent is true.'); | 125 }, 'Set vibrate, when silent is true.'); |
125 | 126 |
126 // Check exception is thrown when an action doesn't contain title, | 127 // Check exception is thrown when an action doesn't contain |
127 // or title is an empty string. | 128 // action/title, or when action/title is an empty string. |
Peter Beverloo
2015/07/31 18:05:34
Please use a full sentence.
johnme
2015/07/31 18:14:22
Done.
| |
128 assert_throws(new TypeError(), function() { | 129 assert_throws(new TypeError(), function() { |
129 var notification = new Notification("My Notification", { | 130 var notification = new Notification("My Notification", { |
130 actions: [{}] | 131 actions: [{title: "Foo"}] |
131 }); | 132 }); |
132 }, 'Provide action without title.'); | 133 }, 'NotificationAction without action.'); |
133 assert_throws(new TypeError(), function() { | 134 assert_throws(new TypeError(), function() { |
134 var notification = new Notification("My Notification", { | 135 var notification = new Notification("My Notification", { |
135 actions: [{title: ""}] | 136 actions: [{action: "foo"}] |
136 }); | 137 }); |
137 }, 'Provide action with empty title.'); | 138 }, 'NotificationAction without title.'); |
139 assert_throws(new TypeError(), function() { | |
140 var notification = new Notification("My Notification", { | |
141 actions: [{action: "", title: "Foo"}] | |
142 }); | |
143 }, 'NotificationAction with empty action.'); | |
144 assert_throws(new TypeError(), function() { | |
145 var notification = new Notification("My Notification", { | |
146 actions: [{action: "foo", title: ""}] | |
147 }); | |
148 }, 'NotificationAction with empty title.'); | |
138 | 149 |
139 }, 'Checks the properties exposed on the Notification object.'); | 150 }, 'Checks the properties exposed on the Notification object.'); |
140 </script> | 151 </script> |
141 </body> | 152 </body> |
142 </html> | 153 </html> |
OLD | NEW |