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