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.<
/title> | 4 <title>Notifications: Property reflection in the "notificationclick" event.<
/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 16 matching lines...) Expand all Loading... |
27 // an absolute URL, which should probably be the given relative UR
L. | 27 // an absolute URL, which should probably be the given relative UR
L. |
28 icon: 'https://example/icon.png', | 28 icon: 'https://example/icon.png', |
29 vibrate: [100, 200, 300], | 29 vibrate: [100, 200, 300], |
30 silent: false, | 30 silent: false, |
31 data: [ | 31 data: [ |
32 { property: 'foobar', | 32 { property: 'foobar', |
33 string: '\uDFFF\u0000\uDBFF', | 33 string: '\uDFFF\u0000\uDBFF', |
34 scalar: true }, | 34 scalar: true }, |
35 12.15 | 35 12.15 |
36 ], | 36 ], |
37 actions: [{ action: "one", title: "Action 1" }, | 37 actions: [{ action: 'one', title: 'Action 1' }, |
38 { action: "two", title: "Action 2" }, | 38 { action: 'two', title: 'Action 2' }, |
39 { action: "three", title: "Action 3" }] | 39 { action: 'three', title: 'Action 3' }] |
40 }; | 40 }; |
41 | 41 |
42 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); | 42 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); |
43 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(workerInfo) { | 43 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(workerInfo) { |
44 // (1) Tell the Service Worker to display a Web Notification. | 44 // (1) Tell the Service Worker to display a Web Notification. |
45 workerInfo.port.postMessage({ | 45 workerInfo.port.postMessage({ |
46 command: 'show', | 46 command: 'show', |
47 | 47 |
48 title: scope, | 48 title: scope, |
49 options: options | 49 options: options |
(...skipping 12 matching lines...) Expand all Loading... |
62 testRunner.simulateWebNotificationClick(scope); | 62 testRunner.simulateWebNotificationClick(scope); |
63 return; | 63 return; |
64 } | 64 } |
65 | 65 |
66 // (3) Listen for confirmation from the Service Worker that th
e | 66 // (3) Listen for confirmation from the Service Worker that th
e |
67 // notification has been clicked on. Make sure that all proper
ties | 67 // notification has been clicked on. Make sure that all proper
ties |
68 // set on the Notification object are as expected. | 68 // set on the Notification object are as expected. |
69 assert_equals(event.data.command, 'click', 'The notification w
as expected to be clicked.'); | 69 assert_equals(event.data.command, 'click', 'The notification w
as expected to be clicked.'); |
70 | 70 |
71 Object.keys(options).forEach(function(key) { | 71 Object.keys(options).forEach(function(key) { |
72 if (key == 'actions') { | 72 if (key == 'actions') |
73 // TODO(johnme): actions are not yet serialized proper
ly. | 73 assert_object_equals(event.data.notification.actions,
options.actions.slice(0, Notification.maxActions)); |
74 return; | 74 else |
75 } | 75 assert_object_equals(event.data.notification[key], opt
ions[key], 'The ' + key + ' field must be the same.'); |
76 assert_object_equals(event.data.notification[key], options
[key], 'The ' + key + ' field must be the same.'); | |
77 }); | 76 }); |
78 | 77 |
79 test.done(); | 78 test.done(); |
80 }); | 79 }); |
81 }).catch(unreached_rejection(test)); | 80 }).catch(unreached_rejection(test)); |
82 | 81 |
83 }, 'Clicking on a notification displayed by a Service Worker the notificat
ionclick event.'); | 82 }, 'Clicking on a notification displayed by a Service Worker the notificat
ionclick event.'); |
84 </script> | 83 </script> |
85 </body> | 84 </body> |
86 </html> | 85 </html> |
OLD | NEW |