Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Unified Diff: LayoutTests/http/tests/notifications/notification-data-property.html

Issue 993893002: Add the data attribute to the Notification object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8e731dca5c25d43c609bb88b6d66526bfb95f826
--- /dev/null
+++ b/LayoutTests/http/tests/notifications/notification-data-property.html
@@ -0,0 +1,48 @@
+<!doctype html>
vivekg 2015/03/13 04:21:49 nit: We prefer <!DOCTYPE html>
Sanghyun Park 2015/03/13 05:03:08 Okay I'll fix this.
+<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 (Array.isArray(value))
+ assert_object_equals(notification.data, value);
+ else if (typeof value == 'object')
vivekg 2015/03/13 04:21:49 nit: replace '==' => '===' i.e. typeof value === '
Sanghyun Park 2015/03/13 05:03:08 ditto
+ 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");
vivekg 2015/03/13 04:21:49 Prefer using ' over " in all applicable javascript
Sanghyun Park 2015/03/13 05:03:08 I see. I'll modify double-quotes to single-quotes
+ 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; } });
+ }, "Set function in data");
+
+ }, 'Checks the data of several type property exposed on the Notification object.');
+ </script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698