| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var logForDebugging = false; | 5 chrome.tabs.create({url: chrome.extension.getURL("page.html")}); |
| 6 function log(message) { | |
| 7 if (logForDebugging) | |
| 8 console.log(message); | |
| 9 } | |
| 10 | |
| 11 chrome.test.runTests([ | |
| 12 function registerServiceWorker() { | |
| 13 navigator.serviceWorker.register('/sw.js').then(function(registration) { | |
| 14 // Registration was successful | |
| 15 log('ServiceWorker registration successful with scope: ', | |
| 16 registration.scope); | |
| 17 chrome.test.sendMessage("success"); | |
| 18 chrome.test.succeed(); | |
| 19 }).catch(function(err) { | |
| 20 // registration failed :( | |
| 21 var errorMsg = err.name + ': ' + err.message; | |
| 22 log('ServiceWorker registration failed: ' + errorMsg); | |
| 23 chrome.test.sendMessage(errorMsg); | |
| 24 chrome.test.fail(); | |
| 25 }); | |
| 26 } | |
| 27 ]); | |
| OLD | NEW |