chromium/chrome/test/data/extensions/api_test/service_worker/worker_based_background/script_root_scope/a.js

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

navigator.serviceWorker.register('sw.js').then(function() {
  return navigator.serviceWorker.ready;
}).then(function(registration) {
  chrome.test.sendMessage('WORKER_STARTED');
}).catch(function(err) {
  chrome.test.sendMessage('REGISTRATION_FAILED');
});