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 15 matching lines...) Expand all Loading... | |
26 // FIXME: Relative URLs for the icon attribute currently get refle cted as | 26 // FIXME: Relative URLs for the icon attribute currently get refle cted as |
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: [{title: "Action 1"}, {title: "Action 2"}, {title: "Actio n 3"}] | |
37 }; | 38 }; |
38 | 39 |
39 testRunner.setPermission('notifications', 'granted', location.origin, location.origin); | 40 testRunner.setPermission('notifications', 'granted', location.origin, location.origin); |
40 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(workerInfo) { | 41 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(workerInfo) { |
41 // (1) Tell the Service Worker to display a Web Notification. | 42 // (1) Tell the Service Worker to display a Web Notification. |
42 workerInfo.port.postMessage({ | 43 workerInfo.port.postMessage({ |
43 command: 'show', | 44 command: 'show', |
44 | 45 |
45 title: scope, | 46 title: scope, |
46 options: options | 47 options: options |
(...skipping 12 matching lines...) Expand all Loading... | |
59 testRunner.simulateWebNotificationClick(scope); | 60 testRunner.simulateWebNotificationClick(scope); |
60 return; | 61 return; |
61 } | 62 } |
62 | 63 |
63 // (3) Listen for confirmation from the Service Worker that th e | 64 // (3) Listen for confirmation from the Service Worker that th e |
64 // notification has been clicked on. Make sure that all proper ties | 65 // notification has been clicked on. Make sure that all proper ties |
65 // set on the Notification object are as expected. | 66 // set on the Notification object are as expected. |
66 assert_equals(event.data.command, 'click', 'The notification w as expected to be clicked.'); | 67 assert_equals(event.data.command, 'click', 'The notification w as expected to be clicked.'); |
67 | 68 |
68 Object.keys(options).forEach(function(key) { | 69 Object.keys(options).forEach(function(key) { |
70 if (key == 'actions') { | |
71 // TODO(johnme): actions are not yet serialized proper ly. | |
72 assert_equals(event.data.notification.actions.length, 0); | |
Peter Beverloo
2015/07/30 16:24:07
This doesn't look like a great idea. Serializing a
johnme
2015/07/31 15:10:10
Ok, I removed the assert and now just return (with
| |
73 return; | |
74 } | |
69 assert_object_equals(event.data.notification[key], options [key], 'The ' + key + ' field must be the same.'); | 75 assert_object_equals(event.data.notification[key], options [key], 'The ' + key + ' field must be the same.'); |
70 }); | 76 }); |
71 | 77 |
72 test.done(); | 78 test.done(); |
73 }); | 79 }); |
74 }).catch(unreached_rejection(test)); | 80 }).catch(unreached_rejection(test)); |
75 | 81 |
76 }, '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.'); |
77 </script> | 83 </script> |
78 </body> | 84 </body> |
79 </html> | 85 </html> |
OLD | NEW |