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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 assert_equals(emptyNotification.dir, "auto"); | 59 assert_equals(emptyNotification.dir, "auto"); |
60 assert_equals(emptyNotification.lang, ""); | 60 assert_equals(emptyNotification.lang, ""); |
61 assert_equals(emptyNotification.body, ""); | 61 assert_equals(emptyNotification.body, ""); |
62 assert_equals(emptyNotification.tag, ""); | 62 assert_equals(emptyNotification.tag, ""); |
63 assert_equals(emptyNotification.icon, ""); | 63 assert_equals(emptyNotification.icon, ""); |
64 assert_equals(notification.vibrate, null); | 64 assert_equals(notification.vibrate, null); |
65 assert_false(emptyNotification.silent); | 65 assert_false(emptyNotification.silent); |
66 assert_equals(emptyNotification.data, null); | 66 assert_equals(emptyNotification.data, null); |
67 assert_array_equals(emptyNotification.actions, []); | 67 assert_array_equals(emptyNotification.actions, []); |
68 | 68 |
69 var invalidIconNotification = new Notification("My Notification", { | |
70 icon: "http://test:test/" | |
71 }); | |
72 | |
73 // Invalid icon URLs should be reset to an empty string. | |
74 assert_equals(invalidIconNotification.icon, ""); | |
75 | |
76 var serializedUrlNotification = new Notification("My Notification",
{ | 69 var serializedUrlNotification = new Notification("My Notification",
{ |
77 icon: "http://example.com" | 70 icon: "http://example.com" |
78 }); | 71 }); |
79 | 72 |
80 // Icon URLs should be returned in serialized form. | 73 // Icon URLs should be returned in serialized form. |
81 assert_equals(serializedUrlNotification.icon, "http://example.com/")
; | 74 assert_equals(serializedUrlNotification.icon, "http://example.com/")
; |
82 | 75 |
83 var noTagNotification = new Notification("My Notification"), | 76 var noTagNotification = new Notification("My Notification"), |
84 emptyTagNotification = new Notification("My Notification", { tag
: "" }); | 77 emptyTagNotification = new Notification("My Notification", { tag
: "" }); |
85 | 78 |
(...skipping 13 matching lines...) Expand all Loading... |
99 vibrate: pattern | 92 vibrate: pattern |
100 }); | 93 }); |
101 assert_array_equals(sequenceVibrateNotification.vibrate, pattern); | 94 assert_array_equals(sequenceVibrateNotification.vibrate, pattern); |
102 | 95 |
103 // Invalid vibrate pattern should be reset to 0. | 96 // Invalid vibrate pattern should be reset to 0. |
104 var invalidVibrateNotification = new Notification("My Notification",
{ | 97 var invalidVibrateNotification = new Notification("My Notification",
{ |
105 vibrate: [100, 200, "invalid"] | 98 vibrate: [100, 200, "invalid"] |
106 }); | 99 }); |
107 assert_array_equals(invalidVibrateNotification.vibrate, [100, 200, 0
]); | 100 assert_array_equals(invalidVibrateNotification.vibrate, [100, 200, 0
]); |
108 | 101 |
109 // Invalid vibrate pattern should be sanitized. | |
110 // 1. If the vibration pattern is longer than 100 then truncate it. | |
111 // 2. If the last item in the vibration pattern is a pause then disc
ard it. | |
112 // 3. If any pattern entry is longer than 10000 then truncate it. | |
113 var sanitizedVibrateNotification = new Notification("My Notification
", { | |
114 vibrate: Array.apply(null, new Array(101)).map(Number.prototype.
valueOf, 20000) | |
115 }); | |
116 assert_array_equals(sanitizedVibrateNotification.vibrate, | |
117 Array.apply(null, new Array(99)).map(Number.prototype.valueO
f, 10000)); | |
118 | |
119 // Verifying the exception throwing behavior, when silent set true a
nd vibrate is presented. | |
120 assert_throws(new TypeError(), function() { | |
121 var notification = new Notification("My Notification", { | |
122 silent: true, | |
123 vibrate: 1000 | |
124 }); | |
125 }, 'Set vibrate, when silent is true.'); | |
126 | |
127 // Check exception is thrown when a NotificationAction is missing | |
128 // action or title, or when action or title is an empty string. | |
129 assert_throws(new TypeError(), function() { | |
130 var notification = new Notification("My Notification", { | |
131 actions: [{title: "Foo"}] | |
132 }); | |
133 }, 'NotificationAction without action.'); | |
134 assert_throws(new TypeError(), function() { | |
135 var notification = new Notification("My Notification", { | |
136 actions: [{action: "foo"}] | |
137 }); | |
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.'); | |
149 | |
150 }, 'Checks the properties exposed on the Notification object.'); | 102 }, 'Checks the properties exposed on the Notification object.'); |
151 </script> | 103 </script> |
152 </body> | 104 </body> |
153 </html> | 105 </html> |
OLD | NEW |