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 |
(...skipping 14 matching lines...) Expand all Loading... | |
25 }; | 25 }; |
26 | 26 |
27 var notification = new Notification("My Notification", options); | 27 var notification = new Notification("My Notification", options); |
28 | 28 |
29 assert_equals(notification.title, "My Notification"); | 29 assert_equals(notification.title, "My Notification"); |
30 assert_equals(notification.dir, options.dir); | 30 assert_equals(notification.dir, options.dir); |
31 assert_equals(notification.lang, options.lang); | 31 assert_equals(notification.lang, options.lang); |
32 assert_equals(notification.body, options.body); | 32 assert_equals(notification.body, options.body); |
33 assert_equals(notification.tag, options.tag); | 33 assert_equals(notification.tag, options.tag); |
34 assert_equals(notification.icon, options.icon); | 34 assert_equals(notification.icon, options.icon); |
35 assert_equals(notification.vibrate, null); | |
Peter Beverloo
2015/04/09 13:03:17
nit: Please add a value to |options| for this asse
Sanghyun Park
2015/04/09 13:48:05
Currently options.silent set true in this.
If vib
Peter Beverloo
2015/04/09 13:53:07
That seems good to me!
| |
35 assert_true(notification.silent); | 36 assert_true(notification.silent); |
36 assert_equals(notification.data, options.data); | 37 assert_equals(notification.data, options.data); |
37 | 38 |
38 var emptyNotification = new Notification("My Notification"); | 39 var emptyNotification = new Notification("My Notification"); |
39 | 40 |
40 assert_equals(emptyNotification.title, "My Notification"); | 41 assert_equals(emptyNotification.title, "My Notification"); |
41 assert_equals(emptyNotification.dir, "auto"); | 42 assert_equals(emptyNotification.dir, "auto"); |
42 assert_equals(emptyNotification.lang, ""); | 43 assert_equals(emptyNotification.lang, ""); |
43 assert_equals(emptyNotification.body, ""); | 44 assert_equals(emptyNotification.body, ""); |
44 assert_equals(emptyNotification.tag, ""); | 45 assert_equals(emptyNotification.tag, ""); |
45 assert_equals(emptyNotification.icon, ""); | 46 assert_equals(emptyNotification.icon, ""); |
47 assert_equals(notification.vibrate, null); | |
46 assert_false(emptyNotification.silent); | 48 assert_false(emptyNotification.silent); |
47 assert_equals(emptyNotification.data, null); | 49 assert_equals(emptyNotification.data, null); |
48 | 50 |
49 var invalidIconNotification = new Notification("My Notification", { | 51 var invalidIconNotification = new Notification("My Notification", { |
50 icon: "http://test:test/" | 52 icon: "http://test:test/" |
51 }); | 53 }); |
52 | 54 |
53 // Invalid icon URLs should be reset to an empty string. | 55 // Invalid icon URLs should be reset to an empty string. |
54 assert_equals(invalidIconNotification.icon, ""); | 56 assert_equals(invalidIconNotification.icon, ""); |
55 | 57 |
56 var serializedUrlNotification = new Notification("My Notification", { | 58 var serializedUrlNotification = new Notification("My Notification", { |
57 icon: "http://example.com" | 59 icon: "http://example.com" |
58 }); | 60 }); |
59 | 61 |
60 // Icon URLs should be returned in serialized form. | 62 // Icon URLs should be returned in serialized form. |
61 assert_equals(serializedUrlNotification.icon, "http://example.com/") ; | 63 assert_equals(serializedUrlNotification.icon, "http://example.com/") ; |
62 | 64 |
63 var noTagNotification = new Notification("My Notification"), | 65 var noTagNotification = new Notification("My Notification"), |
64 emptyTagNotification = new Notification("My Notification", { tag : "" }); | 66 emptyTagNotification = new Notification("My Notification", { tag : "" }); |
65 | 67 |
66 // Setting an empty string as the tag should be equal to not setting the tag at all. | 68 // Setting an empty string as the tag should be equal to not setting the tag at all. |
67 assert_equals(noTagNotification.tag, emptyTagNotification.tag); | 69 assert_equals(noTagNotification.tag, emptyTagNotification.tag); |
68 | 70 |
71 var vibrateNotification = new Notification("My Notification", { | |
72 vibrate: 1000 | |
73 }); | |
74 | |
75 // vibrate pattern should be returned in serialized form. | |
76 assert_array_equals([1000], vibrateNotification.vibrate); | |
Peter Beverloo
2015/04/09 13:03:17
nit: In testharness, the argument order for assert
Sanghyun Park
2015/04/09 13:48:05
Done.
| |
77 | |
78 // Tests that it must be a valid vibration sequence. | |
79 var pattern = new Array(100, 200, 300); | |
80 var sequenceVibrateNotification = new Notification("My Notification" , { | |
81 vibrate: pattern | |
82 }); | |
83 assert_array_equals(pattern, sequenceVibrateNotification.vibrate); | |
84 | |
85 // Invalid vibrate pattern should be reset to 0. | |
86 var invalidVibrateNotification = new Notification("My Notification", { | |
87 vibrate: [100, 200, "invalid"] | |
88 }); | |
89 assert_array_equals([100, 200, 0], invalidVibrateNotification.vibrat e); | |
90 | |
91 // Verifying the exception throwing behavior, when slient set true a nd vibrate is presented. | |
92 assert_throws(new TypeError(), function() { | |
93 var notification = new Notification("My Notification", { | |
94 silent: true, | |
95 vibrate: 1000 | |
96 }); | |
97 }, 'Set vibrate, when slient is true.'); | |
98 | |
69 }, 'Checks the properties exposed on the Notification object.'); | 99 }, 'Checks the properties exposed on the Notification object.'); |
70 </script> | 100 </script> |
71 </body> | 101 </body> |
72 </html> | 102 </html> |
OLD | NEW |