| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 Notification.requestPermission(permissionCallbackNoResponse); | 46 Notification.requestPermission(permissionCallbackNoResponse); |
| 47 sendResultToTest('requested'); | 47 sendResultToTest('requested'); |
| 48 } | 48 } |
| 49 | 49 |
| 50 // Requests permission for this origin to create notifications. The result will | 50 // Requests permission for this origin to create notifications. The result will |
| 51 // be sent from the callback (permissionCallbackWithResponse); | 51 // be sent from the callback (permissionCallbackWithResponse); |
| 52 function requestPermission() { | 52 function requestPermission() { |
| 53 Notification.requestPermission(permissionCallbackWithResponse); | 53 Notification.requestPermission(permissionCallbackWithResponse); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // Checks the notification permission status. The result will be sent directly |
| 57 // via permissionCallbackWithResponse. |
| 58 function queryPermissionStatus() { |
| 59 sendResultToTest(Notification.permission); |
| 60 } |
| 61 |
| 56 // Callback for requestPermissionAndRespond. Will send the permission status to | 62 // Callback for requestPermissionAndRespond. Will send the permission status to |
| 57 // the test driver. | 63 // the test driver. |
| 58 function permissionCallbackWithResponse(permissionStatus) { | 64 function permissionCallbackWithResponse(permissionStatus) { |
| 59 if (permissionStatus === 'granted') | 65 if (permissionStatus === 'granted') |
| 60 sendResultToTest('request-callback-granted'); | 66 sendResultToTest('request-callback-granted'); |
| 61 else if (permissionStatus === 'denied') | 67 else if (permissionStatus === 'denied') |
| 62 sendResultToTest('request-callback-denied'); | 68 sendResultToTest('request-callback-denied'); |
| 63 else if (permissionStatus === 'default') | 69 else if (permissionStatus === 'default') |
| 64 sendResultToTest('request-callback-default'); | 70 sendResultToTest('request-callback-default'); |
| 65 } | 71 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 96 stringResult = JSON.stringify(result); | 102 stringResult = JSON.stringify(result); |
| 97 window.domAutomationController.send(stringResult); | 103 window.domAutomationController.send(stringResult); |
| 98 } | 104 } |
| 99 | 105 |
| 100 </script> | 106 </script> |
| 101 | 107 |
| 102 <body> | 108 <body> |
| 103 This page is used for testing HTML5 notifications. | 109 This page is used for testing HTML5 notifications. |
| 104 </body> | 110 </body> |
| 105 </html> | 111 </html> |
| OLD | NEW |