OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>Notifications: The Notification object exposes the expected data prop
erty.</title> |
| 5 <script src="../resources/testharness.js"></script> |
| 6 <script src="../resources/testharnessreport.js"></script> |
| 7 </head> |
| 8 <body> |
| 9 <script> |
| 10 // Tests that the Notification object exposes the data property per the |
| 11 // semantics defined by the specification. When the test is being ran |
| 12 // manually, grant Notification permission first. |
| 13 |
| 14 function assertNotificationDataReflects(value) { |
| 15 var notification = new Notification('Title', { data: value }); |
| 16 |
| 17 if (Array.isArray(value)) |
| 18 assert_object_equals(notification.data, value); |
| 19 else if (typeof value === 'object') |
| 20 assert_array_equals(notification.data, value); |
| 21 else |
| 22 assert_equals(notification.data, value); |
| 23 } |
| 24 |
| 25 test(function () { |
| 26 // Set notification's data of several type to a structured clone of opti
ons's data. |
| 27 assertNotificationDataReflects(true); // Check Boolean type |
| 28 assertNotificationDataReflects(1024); // Check Number type |
| 29 assertNotificationDataReflects(Number.NaN); // Check Number.NaN type |
| 30 assertNotificationDataReflects('any data'); // Check String type |
| 31 |
| 32 var cars = new Array('Saab', 'Volvo', 'BMW'); |
| 33 assertNotificationDataReflects(cars); // Check Array type |
| 34 |
| 35 var obj = { first: 'first', second: 'second'}; |
| 36 assertNotificationDataReflects(obj); // Check Object |
| 37 |
| 38 // Verifying the exception throwing behavior of the method. |
| 39 assert_throws('DataCloneError', function() { |
| 40 var notification = new Notification('Title', { data: function() { re
turn 1; } }); |
| 41 }, 'Set function in data'); |
| 42 |
| 43 }, 'Checks the data of several type property exposed on the Notification obj
ect.'); |
| 44 </script> |
| 45 </body> |
| 46 </html> |
OLD | NEW |