Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html lang="en"> | 2 <html lang="en"> |
| 3 <head> | 3 <head> |
| 4 <meta charset="utf-8"> | 4 <meta charset="utf-8"> |
| 5 <title>Android Web Notifications Instrumentation test-page</title> | 5 <title>Android Web Notifications Instrumentation test-page</title> |
| 6 </head> | 6 </head> |
| 7 <body> | 7 <body> |
| 8 <!-- This page is used by the NotificationPlatformBridgeTest instrumentation | 8 <!-- This page is used by the NotificationPlatformBridgeTest instrumentation |
| 9 test suite on Android. --> | 9 test suite on Android. --> |
| 10 <script src="notification_test_utils.js"></script> | 10 <script src="notification_test_utils.js"></script> |
| 11 <script> | 11 <script> |
| 12 function showNotification(title, options) { | 12 function showNotification(title, options) { |
| 13 GetActivatedServiceWorker('android_test_worker.js', location.pathname) | 13 GetActivatedServiceWorker('android_test_worker.js', location.pathname) |
| 14 .then(registration => registration.showNotification(title, options)) | 14 .then(registration => { |
| 15 messagePort.addEventListener('message', function(event) { | |
| 16 if (event.data.startsWith('reply: ')) { | |
| 17 sendToTest(event.data); | |
|
Peter Beverloo
2016/10/17 14:11:40
nit: consider naming the function and unregisterin
awdf
2016/10/17 14:51:24
Done.
| |
| 18 } | |
| 19 }); | |
| 20 return registration.showNotification(title, options); | |
| 21 }) | |
| 15 .catch(sendToTest); | 22 .catch(sendToTest); |
| 16 } | 23 } |
| 17 | 24 |
| 18 // NotificationPlatformBridgeTest observes changes to the tab title as an | 25 // NotificationPlatformBridgeTest observes changes to the tab title as an |
| 19 // asynchronous response mechanism from JavaScript to Java. | 26 // asynchronous response mechanism from JavaScript to Java. |
| 20 var errorCounter = 0; | 27 var errorCounter = 0; |
| 21 function sendToTest(message) { | 28 function sendToTest(message) { |
| 22 // Duplicate messages cannot be detected by the test, don't send them. | 29 // Duplicate messages cannot be detected by the test, don't send them. |
| 23 if (message == document.title) { | 30 if (message == document.title) { |
| 24 console.log('Duplicate message: ' + message); | 31 console.log('Duplicate message: ' + message); |
| 25 message = | 32 message = |
| 26 'Error ' + errorCounter + ' - duplicate message: ' + message; | 33 'Error ' + errorCounter + ' - duplicate message: ' + message; |
| 27 errorCounter++; | 34 errorCounter++; |
| 28 } | 35 } |
| 29 document.title = message; | 36 document.title = message; |
| 30 } | 37 } |
| 31 </script> | 38 </script> |
| 32 </body> | 39 </body> |
| 33 </html> | 40 </html> |
| OLD | NEW |