OLD | NEW |
1 <html> | 1 <html> |
2 <!--notification_tester.html | 2 <!--notification_tester.html |
3 Script with javascript functions for creating and canceling notifications. | 3 Script with javascript functions for creating and canceling notifications. |
4 Also can be used to request permission for notifications. | 4 Also can be used to request permission for notifications. |
5 --> | 5 --> |
6 <script> | 6 <script> |
7 | 7 |
8 // Array of all notifications this page has created. | 8 // Array of all notifications this page has created. |
9 var g_notifications = []; | 9 var g_notifications = []; |
10 // Whether the site has requested and been granted permission. | 10 // Whether the site has requested and been granted permission. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } | 72 } |
73 | 73 |
74 // Callback for requesting notification privileges. | 74 // Callback for requesting notification privileges. |
75 function onPermissionGranted() { | 75 function onPermissionGranted() { |
76 g_permissionGranted = true; | 76 g_permissionGranted = true; |
77 } | 77 } |
78 | 78 |
79 // Helper function that shows the notification and adds it to | 79 // Helper function that shows the notification and adds it to |
80 // |g_notifications|. | 80 // |g_notifications|. |
81 function createNotificationHelper(note, replaceId) { | 81 function createNotificationHelper(note, replaceId) { |
| 82 note.replaceId = replaceId; |
82 note.show(); | 83 note.show(); |
83 // |push| returns the length of the array after the add. | 84 // |push| returns the length of the array after the add. |
84 return g_notifications.push(note) - 1; | 85 return g_notifications.push(note) - 1; |
85 } | 86 } |
86 | 87 |
87 // Sends a result back to the main test logic. | 88 // Sends a result back to the main test logic. |
88 function sendResultToTest(result) { | 89 function sendResultToTest(result) { |
89 // Convert the result to a string. | 90 // Convert the result to a string. |
90 var stringResult = "" + result; | 91 var stringResult = "" + result; |
91 if (typeof stringResult != "string") | 92 if (typeof stringResult != "string") |
92 stringResult = JSON.stringify(result); | 93 stringResult = JSON.stringify(result); |
93 window.domAutomationController.send(stringResult); | 94 window.domAutomationController.send(stringResult); |
94 } | 95 } |
95 | 96 |
96 </script> | 97 </script> |
97 | 98 |
98 <body> | 99 <body> |
99 This page is used for testing HTML5 notifications. | 100 This page is used for testing HTML5 notifications. |
100 </body> | 101 </body> |
101 </html> | 102 </html> |
OLD | NEW |