Chromium Code Reviews| 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 silent: true, |
| 30 data: [ | |
| 31 { property: 'foobar', | |
|
johnme
2015/04/08 18:27:51
Since this is our only test of SerializedScriptVal
Peter Beverloo
2015/04/20 11:29:41
Done.
| |
| 32 scalar: true }, | |
| 33 12.15 | |
| 34 ] | |
| 30 }; | 35 }; |
| 31 | 36 |
| 32 testRunner.grantWebNotificationPermission(location.origin, true); | 37 testRunner.grantWebNotificationPermission(location.origin, true); |
| 33 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(workerInfo) { | 38 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(workerInfo) { |
| 34 // (1) Tell the Service Worker to display a Web Notification. | 39 // (1) Tell the Service Worker to display a Web Notification. |
| 35 workerInfo.port.postMessage({ | 40 workerInfo.port.postMessage({ |
| 36 command: 'show', | 41 command: 'show', |
| 37 | 42 |
| 38 title: scope, | 43 title: scope, |
| 39 options: options | 44 options: options |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 52 testRunner.simulateWebNotificationClick(scope); | 57 testRunner.simulateWebNotificationClick(scope); |
| 53 return; | 58 return; |
| 54 } | 59 } |
| 55 | 60 |
| 56 // (3) Listen for confirmation from the Service Worker that th e | 61 // (3) Listen for confirmation from the Service Worker that th e |
| 57 // notification has been clicked on. Make sure that all proper ties | 62 // notification has been clicked on. Make sure that all proper ties |
| 58 // set on the Notification object are as expected. | 63 // set on the Notification object are as expected. |
| 59 assert_equals(event.data.command, 'click', 'The notification w as expected to be clicked.'); | 64 assert_equals(event.data.command, 'click', 'The notification w as expected to be clicked.'); |
| 60 | 65 |
| 61 Object.keys(options).forEach(function(key) { | 66 Object.keys(options).forEach(function(key) { |
| 67 if (key == 'data') | |
| 68 return; // Check "data" separately to avoid stringifyin g it. | |
| 69 | |
| 62 assert_equals(event.data.notification[key], options[key], 'The ' + key + ' field must be the same.'); | 70 assert_equals(event.data.notification[key], options[key], 'The ' + key + ' field must be the same.'); |
| 63 }); | 71 }); |
| 64 | 72 |
| 73 assert_object_equals(event.data.notification.data, options.dat a, 'The data field must be the same.'); | |
| 74 | |
| 65 test.done(); | 75 test.done(); |
| 66 }); | 76 }); |
| 67 }).catch(unreached_rejection(test)); | 77 }).catch(unreached_rejection(test)); |
| 68 | 78 |
| 69 }, 'Clicking on a notification displayed by a Service Worker the notificat ionclick event.'); | 79 }, 'Clicking on a notification displayed by a Service Worker the notificat ionclick event.'); |
| 70 </script> | 80 </script> |
| 71 </body> | 81 </body> |
| 72 </html> | 82 </html> |
| OLD | NEW |