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> |
11 <script> | 11 <script> |
12 // Tests that the notification available in the "notificationclick" event
in the | 12 // Tests that the notification available in the "notificationclick" event
in the |
13 // Service Worker accurately reflects the attributes with which the notifi
cation | 13 // Service Worker accurately reflects the attributes with which the notifi
cation |
14 // was created (for this test --) in the document. | 14 // was created (for this test --) in the document. |
15 | 15 |
16 async_test(function(test) { | 16 async_test(function(test) { |
17 var scope = 'resources/scope/' + location.pathname, | 17 var scope = 'resources/scope/' + location.pathname, |
18 script = 'resources/instrumentation-service-worker.js'; | 18 script = 'resources/instrumentation-service-worker.js'; |
19 | 19 |
20 var options = { | 20 var options = { |
21 title: scope, | 21 title: scope, |
22 dir: 'rtl', | 22 dir: 'rtl', |
23 lang: 'nl-NL', | 23 lang: 'nl-NL', |
24 body: 'Hello, world!', | 24 body: 'Hello, world!', |
25 tag: 'tag', | 25 tag: 'tag', |
| 26 priority: 'high', |
26 // FIXME: Relative URLs for the icon attribute currently get refle
cted as | 27 // 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. | 28 // an absolute URL, which should probably be the given relative UR
L. |
28 icon: 'https://example/icon.png', | 29 icon: 'https://example/icon.png', |
29 vibrate: [100, 200, 300], | 30 vibrate: [100, 200, 300], |
30 silent: false, | 31 silent: false, |
31 data: [ | 32 data: [ |
32 { property: 'foobar', | 33 { property: 'foobar', |
33 string: '\uDFFF\u0000\uDBFF', | 34 string: '\uDFFF\u0000\uDBFF', |
34 scalar: true }, | 35 scalar: true }, |
35 12.15 | 36 12.15 |
(...skipping 26 matching lines...) Expand all Loading... |
62 testRunner.simulateWebNotificationClick(scope); | 63 testRunner.simulateWebNotificationClick(scope); |
63 return; | 64 return; |
64 } | 65 } |
65 | 66 |
66 // (3) Listen for confirmation from the Service Worker that th
e | 67 // (3) Listen for confirmation from the Service Worker that th
e |
67 // notification has been clicked on. Make sure that all proper
ties | 68 // notification has been clicked on. Make sure that all proper
ties |
68 // set on the Notification object are as expected. | 69 // set on the Notification object are as expected. |
69 assert_equals(event.data.command, 'click', 'The notification w
as expected to be clicked.'); | 70 assert_equals(event.data.command, 'click', 'The notification w
as expected to be clicked.'); |
70 | 71 |
71 Object.keys(options).forEach(function(key) { | 72 Object.keys(options).forEach(function(key) { |
| 73 if (key == 'priority') { |
| 74 // TODO(johnme): priority is not yet serialized proper
ly. |
| 75 return; |
| 76 } |
72 if (key == 'actions') { | 77 if (key == 'actions') { |
73 // TODO(johnme): actions are not yet serialized proper
ly. | 78 // TODO(johnme): actions are not yet serialized proper
ly. |
74 return; | 79 return; |
75 } | 80 } |
76 assert_object_equals(event.data.notification[key], options
[key], 'The ' + key + ' field must be the same.'); | 81 assert_object_equals(event.data.notification[key], options
[key], 'The ' + key + ' field must be the same.'); |
77 }); | 82 }); |
78 | 83 |
79 test.done(); | 84 test.done(); |
80 }); | 85 }); |
81 }).catch(unreached_rejection(test)); | 86 }).catch(unreached_rejection(test)); |
82 | 87 |
83 }, 'Clicking on a notification displayed by a Service Worker the notificat
ionclick event.'); | 88 }, 'Clicking on a notification displayed by a Service Worker the notificat
ionclick event.'); |
84 </script> | 89 </script> |
85 </body> | 90 </body> |
86 </html> | 91 </html> |
OLD | NEW |