Index: LayoutTests/http/tests/notifications/notification-data-property.html |
diff --git a/LayoutTests/http/tests/notifications/notification-data-property.html b/LayoutTests/http/tests/notifications/notification-data-property.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..27609a45a77bcdbd94c55b4ef921c733eb23c441 |
--- /dev/null |
+++ b/LayoutTests/http/tests/notifications/notification-data-property.html |
@@ -0,0 +1,48 @@ |
+<!doctype html> |
+<html> |
+ <head> |
+ <title>Notifications: The Notification object exposes the expected data property.</title> |
+ <script src="../resources/testharness.js"></script> |
+ <script src="../resources/testharnessreport.js"></script> |
+ </head> |
+ <body> |
+ <script> |
+ // Tests that the Notification object exposes the data property per the |
+ // semantics defined by the specification. When the test is being ran |
+ // manually, grant Notification permission first. |
+ if (window.testRunner) |
+ testRunner.clearWebNotificationPermissions(); |
+ |
+ function assertNotificationDataReflects(value) { |
+ var notification = new Notification('Title', { data: value }); |
+ |
+ 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.
|
+ assert_object_equals(notification.data, value); |
+ else if (value.constructor.toString().indexOf("Array") > -1) |
+ assert_array_equals(notification.data, value); |
+ else |
+ assert_equals(notification.data, value); |
+ } |
+ |
+ test(function () { |
+ // Set notification's data of several type to a structured clone of options's data. |
+ assertNotificationDataReflects(true); // Check Boolean type |
+ assertNotificationDataReflects(1024); // Check Number type |
+ assertNotificationDataReflects(Number.NaN); // Check Number.NaN type |
+ assertNotificationDataReflects("any data"); // Check String type |
+ |
+ var cars = new Array("Saab", "Volvo", "BMW"); |
+ assertNotificationDataReflects(cars); // Check Array type |
+ |
+ var obj = { first: "first", second: "second"}; |
+ assertNotificationDataReflects(obj); // Check Object |
+ |
+ // Verifying the exception throwing behavior of the method. |
+ assert_throws("DataCloneError", function() { |
+ var notification = new Notification('Title', { data: function() { return 1; } }); |
Peter Beverloo
2015/03/12 01:16:26
micro nit: indent +1 space
Sanghyun Park
2015/03/12 02:58:47
Done.
|
+ }, "Set function in data"); |
+ |
+ }, '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.
|
+ </script> |
+ </body> |
+</html> |