Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / extensions / renderer / resources / service_worker_bindings.js
blobbc8cfd6bd79675ffd1ff9474ff9ed7212a90d9d5
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 (function(backgroundUrl) {
6 'use strict';
8 self.chrome = self.chrome || {};
10 self.chrome.getBackgroundClient = function() { return new Promise(
11 function(resolve, reject) {
12 self.clients.matchAll({
13 includeUncontrolled: true,
14 type: 'window'
15 }).then(function(clients) {
16 for (let client of clients) {
17 if (client.url == backgroundUrl) {
18 resolve(client);
19 return;
22 reject("BackgroundClient ('" + backgroundUrl + "') does not exist.")
24 });
26 });