Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(573)

Side by Side Diff: content/browser/resources/service_worker/serviceworker_internals.js

Issue 299693002: Add option to open the DevTools window for ServiceWorker on start in serviceworker-internals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: WORKER_PAUSED_FOR_DEBUG_ON_START Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('serviceworker', function() { 5 cr.define('serviceworker', function() {
6 'use strict'; 6 'use strict';
7 7
8 function initialize() { 8 function initialize() {
9 if (window.location.hash == "#iframe") { 9 if (window.location.hash == "#iframe") {
10 // This page is loaded from chrome://inspect. 10 // This page is loaded from chrome://inspect.
11 window.addEventListener('message', onMessage.bind(this), false); 11 window.addEventListener('message', onMessage.bind(this), false);
12 } 12 }
13 update(); 13 update();
14 } 14 }
15 15
16 function onMessage(event) { 16 function onMessage(event) {
17 if (event.origin != 'chrome://inspect') { 17 if (event.origin != 'chrome://inspect') {
18 return; 18 return;
19 } 19 }
20 chrome.send(event.data.action, 20 chrome.send(event.data.action,
21 [event.data.partition_path, event.data.scope]); 21 [event.data.partition_path, event.data.scope]);
22 } 22 }
23 23
24 function update() { 24 function update() {
25 chrome.send('GetOptions');
25 chrome.send('getAllRegistrations'); 26 chrome.send('getAllRegistrations');
26 } 27 }
27 28
29 function onOptions(options) {
30 var template;
31 var container = $('serviceworker-options');
32 if (container.childNodes) {
33 template = container.childNodes[0];
34 }
35 if (!template) {
36 template = jstGetTemplate('serviceworker-options-template');
37 container.appendChild(template);
38 }
39 jstProcess(new JsEvalContext(options), template);
40 var inputs = container.querySelectorAll('input[type=\'checkbox\']');
41 for (var i = 0; i < inputs.length; ++i) {
42 if (!inputs[i].hasClickEvent) {
43 inputs[i].addEventListener('click', (function(event) {
44 chrome.send('SetOption',
45 [event.target.className, event.target.checked]);
46 }).bind(this), false);
47 inputs[i].hasClickEvent = true;
48 }
49 }
50 }
51
28 function progressNodeFor(link) { 52 function progressNodeFor(link) {
29 return link.parentNode.querySelector('.operation-status'); 53 return link.parentNode.querySelector('.operation-status');
30 } 54 }
31 55
32 // All commands are sent with the partition_path and scope, and 56 // All commands are sent with the partition_path and scope, and
33 // are all completed with 'onOperationComplete'. 57 // are all completed with 'onOperationComplete'.
34 var COMMANDS = ['unregister', 'start', 'stop', 'sync', 'inspect']; 58 var COMMANDS = ['unregister', 'start', 'stop', 'sync', 'inspect'];
35 function commandHandler(command) { 59 function commandHandler(command) {
36 return function(event) { 60 return function(event) {
37 var link = event.target; 61 var link = event.target;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 if (logArea.partition_id == partition_id && 225 if (logArea.partition_id == partition_id &&
202 logArea.version_id == version_id) { 226 logArea.version_id == version_id) {
203 logArea.value += message; 227 logArea.value += message;
204 } 228 }
205 } 229 }
206 } 230 }
207 231
208 return { 232 return {
209 initialize: initialize, 233 initialize: initialize,
210 update: update, 234 update: update,
235 onOptions: onOptions,
211 onOperationComplete: onOperationComplete, 236 onOperationComplete: onOperationComplete,
212 onPartitionData: onPartitionData, 237 onPartitionData: onPartitionData,
213 onWorkerStarted: onWorkerStarted, 238 onWorkerStarted: onWorkerStarted,
214 onWorkerStopped: onWorkerStopped, 239 onWorkerStopped: onWorkerStopped,
215 onErrorReported: onErrorReported, 240 onErrorReported: onErrorReported,
216 onConsoleMessageReported: onConsoleMessageReported, 241 onConsoleMessageReported: onConsoleMessageReported,
217 onVersionStateChanged: onVersionStateChanged, 242 onVersionStateChanged: onVersionStateChanged,
218 onRegistrationStored: onRegistrationStored, 243 onRegistrationStored: onRegistrationStored,
219 onRegistrationDeleted: onRegistrationDeleted, 244 onRegistrationDeleted: onRegistrationDeleted,
220 }; 245 };
221 }); 246 });
222 247
223 document.addEventListener('DOMContentLoaded', serviceworker.initialize); 248 document.addEventListener('DOMContentLoaded', serviceworker.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698