Index: chrome/test/data/extensions/api_test/service_worker/register/test.js |
diff --git a/chrome/test/data/extensions/api_test/service_worker/register/test.js b/chrome/test/data/extensions/api_test/service_worker/register/test.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..50202d42ca5e68135a5afcc15c7925e1ae9588a1 |
--- /dev/null |
+++ b/chrome/test/data/extensions/api_test/service_worker/register/test.js |
@@ -0,0 +1,26 @@ |
+var registered = false; |
Devlin
2015/07/10 21:51:23
nit: you'll need the license in .js files, too. (.
|
+var error_msg = ""; |
Devlin
2015/07/10 21:51:23
nitty nit: prefer single quotes, unless you have a
|
+ |
not at google - send to devlin
2015/07/10 22:00:42
also, JS style is camelcase unlike C++.
|
+chrome.test.runTests([ |
+ function registerServiceWorker() { |
+ if ('serviceWorker' in navigator) { |
Devlin
2015/07/10 21:51:23
We can probably ignore this - chrome always has se
|
+ navigator.serviceWorker.register('/sw.js').then(function(registration) { |
+ // Registration was successful |
+ console.log('ServiceWorker registration successful with scope: ', |
Devlin
2015/07/10 21:51:22
We're not supposed to spam the log with status fro
|
+ registration.scope); |
+ registered = true; |
+ }).catch(function(err) { |
+ // registration failed :( |
+ error_msg = err.name + ': ' + err.message; |
+ console.log('ServiceWorker registration failed: ' + error_msg); |
+ // This is the error message that should appear when the extension |
+ // scheme is registered to allow service workers |
+ chrome.test.assertEq('SecurityError: Failed to register a' |
Devlin
2015/07/10 21:51:23
For this test extension, how about we use chrome.t
|
+ + 'ServiceWorker: No URL is associated with the caller\'s' |
Devlin
2015/07/10 21:51:23
nitty nit: prefer double quotes when you have a qu
|
+ + ' document.', error_msg); |
+ }); |
+ } |
+ chrome.test.assertTrue(registered); |
+ } |
+]); |
+ |