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>Platform Notification Service BrowserTest service page</title> | 5 <title>Platform Notification Service BrowserTest service page</title> |
6 </head> | 6 </head> |
7 <body> | 7 <body> |
8 <!-- This page is intended to be used by the | 8 <!-- This page is intended to be used by the |
9 PlatformNotificationServiceBrowserTest. --> | 9 PlatformNotificationServiceBrowserTest. --> |
10 <script> | 10 <script> |
11 var messagePort = null, | 11 var messagePort = null, |
12 messageStack = [], | 12 messageStack = [], |
13 expectingMessage = false; | 13 expectingMessage = false; |
14 | 14 |
15 // Requests permission to display Web Notifications. Will return the | 15 // Requests permission to display Web Notifications. Will return the |
16 // permission level to the DOM Automation Controller. | 16 // permission level to the DOM Automation Controller. |
17 function RequestPermission() { | 17 function RequestPermission() { |
18 Notification.requestPermission(function (level) { | 18 Notification.requestPermission(function () { |
19 domAutomationController.send(level); | 19 domAutomationController.send(Notification.permission); |
Peter Beverloo
2015/01/27 13:37:04
Are you doing this because |level| will say "grant
dewittj
2015/01/27 23:10:12
Yes, that's correct. I've reimplemented this by r
| |
20 }); | 20 }); |
21 } | 21 } |
22 | 22 |
23 // Returns a promise that will be resolved with an activated Service | 23 // Returns a promise that will be resolved with an activated Service |
24 // Worker, or rejects when the Service Worker could not be started. There | 24 // Worker, or rejects when the Service Worker could not be started. There |
25 // will be a message port to and from the worker in |messagePort|. | 25 // will be a message port to and from the worker in |messagePort|. |
26 // TODO(peter): Generalize this in some sort of Service Worker utility | 26 // TODO(peter): Generalize this in some sort of Service Worker utility |
27 // JavaScript file so that other tests can re-use the same logic. | 27 // JavaScript file so that other tests can re-use the same logic. |
28 function GetActivatedServiceWorker(script, scope) { | 28 function GetActivatedServiceWorker(script, scope) { |
29 return navigator.serviceWorker.getRegistration(scope) | 29 return navigator.serviceWorker.getRegistration(scope) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 function GetMessageFromWorker() { | 97 function GetMessageFromWorker() { |
98 if (!messageStack.length) { | 98 if (!messageStack.length) { |
99 expectingMessage = true; | 99 expectingMessage = true; |
100 return; | 100 return; |
101 } | 101 } |
102 | 102 |
103 domAutomationController.send('' + messageStack.pop()); | 103 domAutomationController.send('' + messageStack.pop()); |
104 } | 104 } |
105 </script> | 105 </script> |
106 </body> | 106 </body> |
107 </html> | 107 </html> |
OLD | NEW |