| Index: content/browser/resources/service_worker/serviceworker_internals.js
|
| diff --git a/content/browser/resources/service_worker/serviceworker_internals.js b/content/browser/resources/service_worker/serviceworker_internals.js
|
| index 1be184cf6fcc7e33dde303d9a0b560bda16e7719..a3b2ef9bc527e9bc2e4ab906a502145cf98aad5f 100644
|
| --- a/content/browser/resources/service_worker/serviceworker_internals.js
|
| +++ b/content/browser/resources/service_worker/serviceworker_internals.js
|
| @@ -5,6 +5,22 @@
|
| cr.define('serviceworker', function() {
|
| 'use strict';
|
|
|
| + function initialize() {
|
| + if (window.location.hash == "#iframe") {
|
| + // This page is loaded from chrome://inspect.
|
| + window.addEventListener('message', onMessage.bind(this), false);
|
| + }
|
| + update();
|
| + }
|
| +
|
| + function onMessage(event) {
|
| + if (event.origin != 'chrome://inspect') {
|
| + return;
|
| + }
|
| + chrome.send(event.data.action,
|
| + [event.data.partition_path, event.data.scope]);
|
| + }
|
| +
|
| function update() {
|
| chrome.send('getAllRegistrations');
|
| }
|
| @@ -48,8 +64,34 @@ cr.define('serviceworker', function() {
|
|
|
| var allLogMessages = {};
|
|
|
| + // Send the active ServiceWorker information to chrome://inspect.
|
| + function sendToInspectPage(registrations, partition_id, partition_path) {
|
| + var workers = [];
|
| + for (var i = 0; i < registrations.length; i++) {
|
| + var registration = registrations[i];
|
| + if (!registration.active ||
|
| + registration.active.running_status != 'RUNNING') {
|
| + continue;
|
| + }
|
| + workers.push({
|
| + 'partition_path': partition_path,
|
| + 'scope': registration['scope'],
|
| + 'url': registration['script_url']
|
| + })
|
| + }
|
| + window.parent.postMessage({
|
| + 'partition_id': partition_id,
|
| + 'workers': workers,
|
| + }, 'chrome://inspect')
|
| + }
|
| +
|
| // Fired once per partition from the backend.
|
| function onPartitionData(registrations, partition_id, partition_path) {
|
| + if (window.location.hash == "#iframe") {
|
| + // This page is loaded from chrome://inspect.
|
| + sendToInspectPage(registrations, partition_id, partition_path);
|
| + return;
|
| + }
|
| var template;
|
| var container = $('serviceworker-list');
|
|
|
| @@ -164,6 +206,7 @@ cr.define('serviceworker', function() {
|
| }
|
|
|
| return {
|
| + initialize: initialize,
|
| update: update,
|
| onOperationComplete: onOperationComplete,
|
| onPartitionData: onPartitionData,
|
| @@ -177,4 +220,4 @@ cr.define('serviceworker', function() {
|
| };
|
| });
|
|
|
| -document.addEventListener('DOMContentLoaded', serviceworker.update);
|
| +document.addEventListener('DOMContentLoaded', serviceworker.initialize);
|
|
|