Chromium Code Reviews| 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 if (window.testRunner) | 13 if (window.testRunner) |
| 14 testRunner.clearWebNotificationPermissions(); | 14 testRunner.clearWebNotificationPermissions(); |
| 15 | 15 |
| 16 test(function () { | 16 test(function () { |
| 17 var options = { | 17 var options = { |
| 18 dir: "rtl", | 18 dir: "rtl", |
| 19 lang: "nl-NL", | 19 lang: "nl-NL", |
| 20 body: "Hallo, wereld!", | 20 body: "Hallo, wereld!", |
| 21 tag: "notification", | 21 tag: "notification", |
| 22 icon: "http://localhost/my_icon.png" | 22 icon: "http://localhost/my_icon.png", |
| 23 data: "my data" | |
| 23 }; | 24 }; |
| 24 | 25 |
| 25 var notification = new Notification("My Notification", options); | 26 var notification = new Notification("My Notification", options); |
| 26 | 27 |
| 27 assert_equals(notification.title, "My Notification"); | 28 assert_equals(notification.title, "My Notification"); |
| 28 assert_equals(notification.dir, options.dir); | 29 assert_equals(notification.dir, options.dir); |
| 29 assert_equals(notification.lang, options.lang); | 30 assert_equals(notification.lang, options.lang); |
| 30 assert_equals(notification.body, options.body); | 31 assert_equals(notification.body, options.body); |
| 31 assert_equals(notification.tag, options.tag); | 32 assert_equals(notification.tag, options.tag); |
| 32 assert_equals(notification.icon, options.icon); | 33 assert_equals(notification.icon, options.icon); |
| 34 assert_equals(notification.data, options.data); | |
| 33 | 35 |
| 34 var emptyNotification = new Notification("My Notification"); | 36 var emptyNotification = new Notification("My Notification"); |
| 35 | 37 |
| 36 assert_equals(emptyNotification.title, "My Notification"); | 38 assert_equals(emptyNotification.title, "My Notification"); |
| 37 assert_equals(emptyNotification.dir, "auto"); | 39 assert_equals(emptyNotification.dir, "auto"); |
| 38 assert_equals(emptyNotification.lang, ""); | 40 assert_equals(emptyNotification.lang, ""); |
| 39 assert_equals(emptyNotification.body, ""); | 41 assert_equals(emptyNotification.body, ""); |
| 40 assert_equals(emptyNotification.tag, ""); | 42 assert_equals(emptyNotification.tag, ""); |
| 41 assert_equals(emptyNotification.icon, ""); | 43 assert_equals(emptyNotification.icon, ""); |
| 44 assert_equals(emptyNotification.data, null); | |
| 42 | 45 |
| 43 var invalidIconNotification = new Notification("My Notification", { | 46 var invalidIconNotification = new Notification("My Notification", { |
| 44 icon: "http://test:test/" | 47 icon: "http://test:test/" |
| 45 }); | 48 }); |
| 46 | 49 |
| 47 // Invalid icon URLs should be reset to an empty string. | 50 // Invalid icon URLs should be reset to an empty string. |
| 48 assert_equals(invalidIconNotification.icon, ""); | 51 assert_equals(invalidIconNotification.icon, ""); |
| 49 | 52 |
| 50 var serializedUrlNotification = new Notification("My Notification", { | 53 var serializedUrlNotification = new Notification("My Notification", { |
| 51 icon: "http://example.com" | 54 icon: "http://example.com" |
| 52 }); | 55 }); |
| 53 | 56 |
| 54 // Icon URLs should be returned in serialized form. | 57 // Icon URLs should be returned in serialized form. |
| 55 assert_equals(serializedUrlNotification.icon, "http://example.com/") ; | 58 assert_equals(serializedUrlNotification.icon, "http://example.com/") ; |
| 56 | 59 |
| 57 var noTagNotification = new Notification("My Notification"), | 60 var noTagNotification = new Notification("My Notification"), |
| 58 emptyTagNotification = new Notification("My Notification", { tag : "" }); | 61 emptyTagNotification = new Notification("My Notification", { tag : "" }); |
| 59 | 62 |
| 60 // Setting an empty string as the tag should be equal to not setting the tag at all. | 63 // Setting an empty string as the tag should be equal to not setting the tag at all. |
| 61 assert_equals(noTagNotification.tag, emptyTagNotification.tag); | 64 assert_equals(noTagNotification.tag, emptyTagNotification.tag); |
| 62 | 65 |
| 66 // Set notification's data to a structured clone of options's data. | |
|
Peter Beverloo
2015/03/10 23:34:26
While I think that the three earlier additions to
Sanghyun Park
2015/03/11 10:59:51
Okay I'll make new test file about data property.
| |
| 67 var serializedDataNotification = new Notification("My Notification", { | |
| 68 data: { | |
| 69 first: "first", | |
| 70 second: "second" | |
| 71 } | |
| 72 }); | |
| 73 | |
| 74 assert_equals(serializedDataNotification.data.first, "first"); | |
| 75 assert_equals(serializedDataNotification.data.second, "second"); | |
| 76 | |
| 63 }, 'Checks the properties exposed on the Notification object.'); | 77 }, 'Checks the properties exposed on the Notification object.'); |
| 64 </script> | 78 </script> |
| 65 </body> | 79 </body> |
| 66 </html> | 80 </html> |
| OLD | NEW |