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 var logForDebugging = false; |
6 function log(message) { | 6 function log(message) { |
7 if (logForDebugging) | 7 if (logForDebugging) |
8 console.log(message); | 8 console.log(message); |
9 } | 9 } |
10 navigator.serviceWorker.register('/sw.js').then(function(registration) { | 10 navigator.serviceWorker.register('/sw.js').then(function(registration) { |
11 // Registration was successful | 11 // Registration was successful |
12 log('ServiceWorker registration successful with scope: ', | 12 log('ServiceWorker registration successful with scope: ', |
13 registration.scope); | 13 registration.scope); |
14 chrome.test.succeed(); | 14 chrome.test.succeed(); |
15 }).catch(function(err) { | 15 }).catch(function(err) { |
16 // registration failed :( | 16 // registration failed :( |
17 var errorMsg = err.name + ': ' + err.message; | 17 var errorMsg = err.name + ': ' + err.message; |
18 log('ServiceWorker registration failed: ' + errorMsg); | 18 log('ServiceWorker registration failed: ' + errorMsg); |
19 chrome.test.fail(); | 19 chrome.test.fail(); |
20 }); | 20 }); |
21 | |
OLD | NEW |