Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / service_worker / register / test.js
blob0e3e96efbecac52abe52d87981937c43fbf5c5ea
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
3 // found in the LICENSE file.
5 var logForDebugging = false;
6 function log(message) {
7   if (logForDebugging)
8     console.log(message);
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 ]);