OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Notifications: Property reflection in the "notificationclick" event a
nd SWR.getNotifications().</title> | 4 <title>Notifications: Property reflection in the "notificationclick" event a
nd SWR.getNotifications().</title> |
5 <script src="../resources/testharness.js"></script> | 5 <script src="../resources/testharness.js"></script> |
6 <script src="../resources/testharnessreport.js"></script> | 6 <script src="../resources/testharnessreport.js"></script> |
7 <script src="../serviceworker/resources/test-helpers.js"></script> | 7 <script src="../serviceworker/resources/test-helpers.js"></script> |
8 <script src="resources/test-helpers.js"></script> | 8 <script src="resources/test-helpers.js"></script> |
9 </head> | 9 </head> |
10 <body> | 10 <body> |
(...skipping 28 matching lines...) Expand all Loading... |
39 icon: 'https://example/icon.png', | 39 icon: 'https://example/icon.png', |
40 vibrate: [100, 200, 300], | 40 vibrate: [100, 200, 300], |
41 silent: false, | 41 silent: false, |
42 requireInteraction: true, | 42 requireInteraction: true, |
43 data: [ | 43 data: [ |
44 { property: 'foobar', | 44 { property: 'foobar', |
45 string: '\uDFFF\u0000\uDBFF', | 45 string: '\uDFFF\u0000\uDBFF', |
46 scalar: true }, | 46 scalar: true }, |
47 12.15 | 47 12.15 |
48 ], | 48 ], |
49 actions: [{ action: 'one', title: 'Action 1' }, | 49 actions: [] |
50 { action: 'two', title: 'Action 2' }, | |
51 { action: 'three', title: 'Action 3' }] | |
52 }; | 50 }; |
| 51 // Deliberately add more actions than are supported. |
| 52 for (var i = 0; i < 2 * Notification.maxActions; i++) { |
| 53 options.actions.push({ |
| 54 action: "a" + i, |
| 55 title: "Action " + i |
| 56 }); |
| 57 } |
53 | 58 |
54 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); | 59 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); |
55 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(workerInfo) { | 60 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(workerInfo) { |
56 // (1) Tell the Service Worker to display a Web Notification. | 61 // (1) Tell the Service Worker to display a Web Notification. |
57 workerInfo.port.postMessage({ | 62 workerInfo.port.postMessage({ |
58 command: 'show', | 63 command: 'show', |
59 | 64 |
60 title: scope, | 65 title: scope, |
61 options: options | 66 options: options |
62 }); | 67 }); |
(...skipping 19 matching lines...) Expand all Loading... |
82 // notification has been clicked on. Make sure that all proper
ties | 87 // notification has been clicked on. Make sure that all proper
ties |
83 // set on the cloned Notification object are as expected. | 88 // set on the cloned Notification object are as expected. |
84 assert_equals(event.data.command, 'click', 'The notification w
as expected to be clicked.'); | 89 assert_equals(event.data.command, 'click', 'The notification w
as expected to be clicked.'); |
85 assert_object_is_superset(event.data.notification, options, 'T
he Notification object properties must be the same in notificationclick events.'
); | 90 assert_object_is_superset(event.data.notification, options, 'T
he Notification object properties must be the same in notificationclick events.'
); |
86 | 91 |
87 // (4) Check that the properties are also set correctly on the | 92 // (4) Check that the properties are also set correctly on the |
88 // non-cloned Notification object from getNotifications. | 93 // non-cloned Notification object from getNotifications. |
89 workerInfo.registration.getNotifications().then(function(notif
ications) { | 94 workerInfo.registration.getNotifications().then(function(notif
ications) { |
90 assert_equals(notifications.length, 1); | 95 assert_equals(notifications.length, 1); |
91 assert_object_is_superset(notifications[0], options, 'The
Notification object properties must be the same in getNotifications.'); | 96 assert_object_is_superset(notifications[0], options, 'The
Notification object properties must be the same in getNotifications.'); |
| 97 |
| 98 notifications[0].actions.foo = "bar"; |
| 99 notifications[0].actions.push({ title: "Foo" }); |
| 100 if (notifications[0].actions.length) { |
| 101 notifications[0].actions[0].title = "Changed"; |
| 102 notifications[0].actions[0].foo = "bar"; |
| 103 } |
| 104 assert_object_equals(notifications[0].actions, options.act
ions, 'The actions field should be immutable.'); |
| 105 |
| 106 // TODO(johnme): This should pass before shipping Notifica
tion.actions; this is blocked on https://crbug.com/515920. |
| 107 //assert_equals(notifications[0].actions, notifications[0]
.actions, 'The actions field should === itself.'); |
| 108 |
92 test.done(); | 109 test.done(); |
93 }); | 110 }); |
94 }); | 111 }); |
95 }).catch(unreached_rejection(test)); | 112 }).catch(unreached_rejection(test)); |
96 | 113 |
97 }, 'Clicking on a notification displayed by a Service Worker the notificat
ionclick event.'); | 114 }, 'Clicking on a notification displayed by a Service Worker the notificat
ionclick event.'); |
98 </script> | 115 </script> |
99 </body> | 116 </body> |
100 </html> | 117 </html> |
OLD | NEW |