Chromium Code Reviews| 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 if (window.testRunner) | |
| 14 testRunner.clearWebNotificationPermissions(); | |
| 15 | |
| 16 function assertNotificationDataReflects(value) { | |
| 17 var notification = new Notification('Title', { data: value }); | |
| 18 | |
| 19 if (value.constructor.toString().indexOf("Object") > -1) | |
|
Peter Beverloo
2015/03/12 01:16:26
You can use some slightly nicer checks here;
if (
Sanghyun Park
2015/03/12 02:58:47
This is better. I'll fix this.
| |
| 20 assert_object_equals(notification.data, value); | |
| 21 else if (value.constructor.toString().indexOf("Array") > -1) | |
| 22 assert_array_equals(notification.data, value); | |
| 23 else | |
| 24 assert_equals(notification.data, value); | |
| 25 } | |
| 26 | |
| 27 test(function () { | |
| 28 // Set notification's data of several type to a structured clone of opti ons's data. | |
| 29 assertNotificationDataReflects(true); // Check Boolean type | |
| 30 assertNotificationDataReflects(1024); // Check Number type | |
| 31 assertNotificationDataReflects(Number.NaN); // Check Number.NaN type | |
| 32 assertNotificationDataReflects("any data"); // Check String type | |
| 33 | |
| 34 var cars = new Array("Saab", "Volvo", "BMW"); | |
| 35 assertNotificationDataReflects(cars); // Check Array type | |
| 36 | |
| 37 var obj = { first: "first", second: "second"}; | |
| 38 assertNotificationDataReflects(obj); // Check Object | |
| 39 | |
| 40 // Verifying the exception throwing behavior of the method. | |
| 41 assert_throws("DataCloneError", function() { | |
| 42 var notification = new Notification('Title', { data: function() { ret urn 1; } }); | |
|
Peter Beverloo
2015/03/12 01:16:26
micro nit: indent +1 space
Sanghyun Park
2015/03/12 02:58:47
Done.
| |
| 43 }, "Set function in data"); | |
| 44 | |
| 45 }, 'Checks the data of several type property exposed on the Notification object.'); | |
|
Peter Beverloo
2015/03/12 01:16:26
micro nit: indent -4 spaces
Sanghyun Park
2015/03/12 02:58:47
Done.
| |
| 46 </script> | |
| 47 </body> | |
| 48 </html> | |
| OLD | NEW |