Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 <!doctype html> | 1 <!doctype html> | 
| 2 <html> | 2 <html> | 
| 3 <head> | 3 <head> | 
| 4 <title>Notifications: ServiceWorkerRegistration.showNotification() shows not ification with correct notification direction.</title> | 4 <title>Notifications: ServiceWorkerRegistration.showNotification() shows not ification with correct notification vibrate.</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 showNotification() function resolves a promise, and that the | 12 // Tests that the showNotification() function resolves a promise, and that the | 
| 13 // notificationclick event gets fired with the correct notification direct ion. | 13 // notificationclick event gets fired with the correct notification vibrat e. | 
| 14 // This test requires the test runner. | 14 // This test requires the test runner. | 
| 15 | |
| 16 async_test(function(test) { | 15 async_test(function(test) { | 
| 17 var scope = 'resources/spec/' + location.pathname, | 16 var scope = 'resources/spec/' + location.pathname, | 
| 18 script = 'resources/instrumentation-service-worker.js'; | 17 script = 'resources/instrumentation-service-worker.js'; | 
| 19 | 18 | 
| 20 testRunner.grantWebNotificationPermission(location.origin, true); | 19 testRunner.grantWebNotificationPermission(location.origin, true); | 
| 21 | 20 | 
| 22 var workerInfo = null; | 21 var workerInfo = null; | 
| 23 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(info) { | 22 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(info) { | 
| 24 workerInfo = info; | 23 workerInfo = info; | 
| 25 | 24 | 
| 26 // (1) Display a Web Notification from the document. | 25 // (1) Display a Web Notification from the document. | 
| 27 return workerInfo.registration.showNotification(scope, { | 26 return workerInfo.registration.showNotification(scope, { | 
| 28 dir: 'rtl' | 27 vibrate: [100, 200, 300] | 
| 29 }); | 28 }); | 
| 30 }).then(function() { | 29 }).then(function() { | 
| 31 // (2) Simulate a click on the notification that has been displaye d. | 30 // (2) Simulate a click on the notification that has been displaye d. | 
| 32 testRunner.simulateWebNotificationClick(scope); | 31 testRunner.simulateWebNotificationClick(scope); | 
| 33 | 32 | 
| 34 workerInfo.port.addEventListener('message', function(event) { | 33 workerInfo.port.addEventListener('message', function(event) { | 
| 35 if (typeof event.data != 'object' || !event.data.command) { | 34 if (typeof event.data != 'object' || !event.data.command) { | 
| 36 assert_unreached('Received an invalid message from the Ser vice Worker.'); | 35 assert_unreached('Received an invalid message from the Ser vice Worker.'); | 
| 37 return; | 36 return; | 
| 38 } | 37 } | 
| 39 | 38 | 
| 40 // (3) Verify that the click event was received by the Service Worker, | 39 // (3) Verify that the click event was received by the Service Worker | 
| 41 // and that the correct direction was passed along. | |
| 42 assert_equals(event.data.command, 'click'); | 40 assert_equals(event.data.command, 'click'); | 
| 43 assert_equals(event.data.notification.dir, 'rtl'); | 41 // FIXME: Verify that the correct vibrate is returned or not. | 
| 
 
Peter Beverloo
2015/04/07 11:37:31
This test doesn't actually test anything. Can we r
 
Sanghyun Park
2015/04/08 08:00:02
Sure, After the this implementation is completed u
 
 | |
| 44 | 42 | 
| 45 test.done(); | 43 test.done(); | 
| 46 }); | 44 }); | 
| 47 }).catch(unreached_rejection(test)); | 45 }).catch(unreached_rejection(test)); | 
| 48 | 46 | 
| 49 }, 'Clicking on a notification displayed through showNotification() fires a Service Worker event with the correct notification direction'); | 47 }, 'Clicking on a notification displayed through showNotification() fires a Service Worker event with the correct notification virate'); | 
| 50 </script> | 48 </script> | 
| 51 </body> | 49 </body> | 
| 52 </html> | 50 </html> | 
| OLD | NEW |