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 25 matching lines...) Expand all Loading... |
36 assert_equals(notification.data, options.data); | 36 assert_equals(notification.data, options.data); |
37 | 37 |
38 var emptyNotification = new Notification("My Notification"); | 38 var emptyNotification = new Notification("My Notification"); |
39 | 39 |
40 assert_equals(emptyNotification.title, "My Notification"); | 40 assert_equals(emptyNotification.title, "My Notification"); |
41 assert_equals(emptyNotification.dir, "auto"); | 41 assert_equals(emptyNotification.dir, "auto"); |
42 assert_equals(emptyNotification.lang, ""); | 42 assert_equals(emptyNotification.lang, ""); |
43 assert_equals(emptyNotification.body, ""); | 43 assert_equals(emptyNotification.body, ""); |
44 assert_equals(emptyNotification.tag, ""); | 44 assert_equals(emptyNotification.tag, ""); |
45 assert_equals(emptyNotification.icon, ""); | 45 assert_equals(emptyNotification.icon, ""); |
| 46 assert_equals(notification.vibrate, null); |
46 assert_false(emptyNotification.silent); | 47 assert_false(emptyNotification.silent); |
47 assert_equals(emptyNotification.data, null); | 48 assert_equals(emptyNotification.data, null); |
48 | 49 |
49 var invalidIconNotification = new Notification("My Notification", { | 50 var invalidIconNotification = new Notification("My Notification", { |
50 icon: "http://test:test/" | 51 icon: "http://test:test/" |
51 }); | 52 }); |
52 | 53 |
53 // Invalid icon URLs should be reset to an empty string. | 54 // Invalid icon URLs should be reset to an empty string. |
54 assert_equals(invalidIconNotification.icon, ""); | 55 assert_equals(invalidIconNotification.icon, ""); |
55 | 56 |
56 var serializedUrlNotification = new Notification("My Notification",
{ | 57 var serializedUrlNotification = new Notification("My Notification",
{ |
57 icon: "http://example.com" | 58 icon: "http://example.com" |
58 }); | 59 }); |
59 | 60 |
60 // Icon URLs should be returned in serialized form. | 61 // Icon URLs should be returned in serialized form. |
61 assert_equals(serializedUrlNotification.icon, "http://example.com/")
; | 62 assert_equals(serializedUrlNotification.icon, "http://example.com/")
; |
62 | 63 |
63 var noTagNotification = new Notification("My Notification"), | 64 var noTagNotification = new Notification("My Notification"), |
64 emptyTagNotification = new Notification("My Notification", { tag
: "" }); | 65 emptyTagNotification = new Notification("My Notification", { tag
: "" }); |
65 | 66 |
66 // Setting an empty string as the tag should be equal to not setting
the tag at all. | 67 // Setting an empty string as the tag should be equal to not setting
the tag at all. |
67 assert_equals(noTagNotification.tag, emptyTagNotification.tag); | 68 assert_equals(noTagNotification.tag, emptyTagNotification.tag); |
68 | 69 |
| 70 var vibrateNotification = new Notification("My Notification", { |
| 71 vibrate: 1000 |
| 72 }); |
| 73 |
| 74 // vibrate pattern should be returned in serialized form. |
| 75 assert_array_equals(vibrateNotification.vibrate, [1000]); |
| 76 |
| 77 // Tests that it must be a valid vibration sequence. |
| 78 var pattern = new Array(100, 200, 300); |
| 79 var sequenceVibrateNotification = new Notification("My Notification"
, { |
| 80 vibrate: pattern |
| 81 }); |
| 82 assert_array_equals(sequenceVibrateNotification.vibrate, pattern); |
| 83 |
| 84 // Invalid vibrate pattern should be reset to 0. |
| 85 var invalidVibrateNotification = new Notification("My Notification",
{ |
| 86 vibrate: [100, 200, "invalid"] |
| 87 }); |
| 88 assert_array_equals(invalidVibrateNotification.vibrate, [100, 200, 0
]); |
| 89 |
| 90 // Verifying the exception throwing behavior, when silent set true a
nd vibrate is presented. |
| 91 assert_throws(new TypeError(), function() { |
| 92 var notification = new Notification("My Notification", { |
| 93 silent: true, |
| 94 vibrate: 1000 |
| 95 }); |
| 96 }, 'Set vibrate, when silent is true.'); |
| 97 |
69 }, 'Checks the properties exposed on the Notification object.'); | 98 }, 'Checks the properties exposed on the Notification object.'); |
70 </script> | 99 </script> |
71 </body> | 100 </body> |
72 </html> | 101 </html> |
OLD | NEW |