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 // 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 silent: true, | 29 vibrate: [100, 200, 300], |
| 30 silent: false, |
30 data: [ | 31 data: [ |
31 { property: 'foobar', | 32 { property: 'foobar', |
32 string: '\uDFFF\u0000\uDBFF', | 33 string: '\uDFFF\u0000\uDBFF', |
33 scalar: true }, | 34 scalar: true }, |
34 12.15 | 35 12.15 |
35 ] | 36 ] |
36 }; | 37 }; |
37 | 38 |
38 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); | 39 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); |
39 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(workerInfo) { | 40 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(workerInfo) { |
(...skipping 18 matching lines...) Expand all Loading... |
58 testRunner.simulateWebNotificationClick(scope); | 59 testRunner.simulateWebNotificationClick(scope); |
59 return; | 60 return; |
60 } | 61 } |
61 | 62 |
62 // (3) Listen for confirmation from the Service Worker that th
e | 63 // (3) Listen for confirmation from the Service Worker that th
e |
63 // notification has been clicked on. Make sure that all proper
ties | 64 // notification has been clicked on. Make sure that all proper
ties |
64 // set on the Notification object are as expected. | 65 // set on the Notification object are as expected. |
65 assert_equals(event.data.command, 'click', 'The notification w
as expected to be clicked.'); | 66 assert_equals(event.data.command, 'click', 'The notification w
as expected to be clicked.'); |
66 | 67 |
67 Object.keys(options).forEach(function(key) { | 68 Object.keys(options).forEach(function(key) { |
68 if (key == 'data') | 69 assert_object_equals(event.data.notification[key], options
[key], 'The ' + key + ' field must be the same.'); |
69 return; // Check "data" separately to avoid stringify
ing it. | |
70 | |
71 assert_equals(event.data.notification[key], options[key],
'The ' + key + ' field must be the same.'); | |
72 }); | 70 }); |
73 | 71 |
74 assert_object_equals(event.data.notification.data, options.dat
a, 'The data field must be the same.'); | |
75 | |
76 test.done(); | 72 test.done(); |
77 }); | 73 }); |
78 }).catch(unreached_rejection(test)); | 74 }).catch(unreached_rejection(test)); |
79 | 75 |
80 }, 'Clicking on a notification displayed by a Service Worker the notificat
ionclick event.'); | 76 }, 'Clicking on a notification displayed by a Service Worker the notificat
ionclick event.'); |
81 </script> | 77 </script> |
82 </body> | 78 </body> |
83 </html> | 79 </html> |
OLD | NEW |