4 <title>Notifications: The Notification object exposes the expected data property.
</title>
5 <script src=
"../resources/testharness.js"></script>
6 <script src=
"../resources/testharnessreport.js"></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.
14 function assertNotificationDataReflects(value
) {
15 var notification
= new Notification('Title', { data
: value
});
17 if (typeof value
=== 'object')
18 assert_object_equals(notification
.data
, value
);
20 assert_equals(notification
.data
, value
);
24 // Set notification's data of several type to a structured clone of options's data.
25 assertNotificationDataReflects(true); // Check Boolean type
26 assertNotificationDataReflects(1024); // Check Number type
27 assertNotificationDataReflects(Number
.NaN
); // Check Number.NaN type
28 assertNotificationDataReflects('any data'); // Check String type
30 var cars
= new Array('Saab', 'Volvo', 'BMW');
31 assertNotificationDataReflects(cars
); // Check Array type
33 var obj
= { first
: 'first', second
: 'second'};
34 assertNotificationDataReflects(obj
); // Check Object
36 // Verifying the exception throwing behavior of the method.
37 assert_throws('DataCloneError', function() {
38 var notification
= new Notification('Title', { data: function() { return 1; } });
39 }, 'Set function in data');
41 }, 'Checks the data of several type property exposed on the Notification object.');