1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22

content / test / data / background_sync / register_sync_from_sw_service_worker.js [blame]

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

'use strict';

function sendMessageToClients(message) {
  clients.matchAll({ includeUncontrolled: true }).then(function(clients) {
    clients.forEach(function(client) {
      client.postMessage(message);
    });
  });
}

self.addEventListener('activate', function(event) {
  registration.sync.register('foo')
    .then(function () {
      sendMessageToClients('registration succeeded');
    }, function(e) {
      sendMessageToClients('registration failed');
    });
});