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 NotificationUIManagerTest instrumentation test | 8 <!-- This page is used by the NotificationPlatformBridgeTest instrumentation |
9 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(function(registration) { | 14 .then(registration => registration.showNotification(title, options)) |
15 registration.showNotification(title, options); | 15 .catch(sendToTest); |
16 }); | 16 } |
| 17 |
| 18 // NotificationPlatformBridgeTest observes changes to the tab title as an |
| 19 // asynchronous response mechanism from JavaScript to Java. |
| 20 var errorCounter = 0; |
| 21 function sendToTest(message) { |
| 22 // Duplicate messages cannot be detected by the test, don't send them. |
| 23 if (message == document.title) { |
| 24 console.log('Duplicate message: ' + message); |
| 25 message = |
| 26 'Error ' + errorCounter + ' - duplicate message: ' + message; |
| 27 errorCounter++; |
| 28 } |
| 29 document.title = message; |
17 } | 30 } |
18 </script> | 31 </script> |
19 </body> | 32 </body> |
20 </html> | 33 </html> |
OLD | NEW |