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

Side by Side Diff: Source/devtools/front_end/resources/ServiceWorkersView.js

Issue 1079013002: Add "emulate push event" button to ServiceWorkersView in DevTools [2/2 blink] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: s/dispatchPushEvent/deliverPushMessage/ Created 5 years, 8 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 (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 /** 5 /**
6 * @constructor 6 * @constructor
7 * @extends {WebInspector.VBox} 7 * @extends {WebInspector.VBox}
8 * @implements {WebInspector.TargetManager.Observer} 8 * @implements {WebInspector.TargetManager.Observer}
9 */ 9 */
10 WebInspector.ServiceWorkersView = function() 10 WebInspector.ServiceWorkersView = function()
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 WebInspector.SWRegistrationElement = function(manager, registration) 264 WebInspector.SWRegistrationElement = function(manager, registration)
265 { 265 {
266 this._manager = manager; 266 this._manager = manager;
267 this._registration = registration; 267 this._registration = registration;
268 this._element = createElementWithClass("div", "service-workers-registration" ); 268 this._element = createElementWithClass("div", "service-workers-registration" );
269 var headerNode = this._element.createChild("li").createChild("div", "service -workers-registration-header"); 269 var headerNode = this._element.createChild("li").createChild("div", "service -workers-registration-header");
270 this._titleNode = headerNode.createChild("div", "service-workers-registratio n-title"); 270 this._titleNode = headerNode.createChild("div", "service-workers-registratio n-title");
271 this._deleteButton = headerNode.createChild("button", "service-workers-butto n service-workers-delete-button"); 271 this._deleteButton = headerNode.createChild("button", "service-workers-butto n service-workers-delete-button");
272 this._deleteButton.addEventListener("click", this._deleteButtonClicked.bind( this), false); 272 this._deleteButton.addEventListener("click", this._deleteButtonClicked.bind( this), false);
273 this._deleteButton.title = WebInspector.UIString("Delete"); 273 this._deleteButton.title = WebInspector.UIString("Delete");
274 this._pushButton = headerNode.createChild("button", "service-workers-button service-workers-push-button");
275 this._pushButton.addEventListener("click", this._pushButtonClicked.bind(this ), false);
276 this._pushButton.title = WebInspector.UIString("Emulate push event");
277 this._pushButton.disabled = true
274 this._childrenListNode = this._element.createChild("ol"); 278 this._childrenListNode = this._element.createChild("ol");
275 this._updateRegistration(registration); 279 this._updateRegistration(registration);
276 } 280 }
277 281
278 WebInspector.SWRegistrationElement.prototype = { 282 WebInspector.SWRegistrationElement.prototype = {
279 /** 283 /**
280 * @param {!WebInspector.ServiceWorkerRegistration} registration 284 * @param {!WebInspector.ServiceWorkerRegistration} registration
281 */ 285 */
282 _updateRegistration: function(registration) 286 _updateRegistration: function(registration)
283 { 287 {
284 this._registration = registration; 288 this._registration = registration;
285 this._titleNode.textContent = WebInspector.UIString(registration.isDelet ed ? "Scope: %s - deleted" : "Scope: %s", registration.scopeURL.asParsedURL().pa th); 289 this._titleNode.textContent = WebInspector.UIString(registration.isDelet ed ? "Scope: %s - deleted" : "Scope: %s", registration.scopeURL.asParsedURL().pa th);
286 this._deleteButton.classList.toggle("hidden", registration.isDeleted); 290 this._deleteButton.disabled = !!registration.isDeleted;
287 this._updateVersionList(); 291 this._updateVersionList();
288 }, 292 },
289 293
290 _updateVersionList: function() 294 _updateVersionList: function()
291 { 295 {
292 var fragment = createDocumentFragment(); 296 var fragment = createDocumentFragment();
293 var tableElement = createElementWithClass("div", "service-workers-versio ns-table"); 297 var tableElement = createElementWithClass("div", "service-workers-versio ns-table");
294 var versions = this._registration.versions.valuesArray(); 298 var versions = this._registration.versions.valuesArray();
295 versions = versions.filter(function(version) { 299 versions = versions.filter(function(version) {
296 return !version.isStoppedAndRedundant() || version.errorMessages.len gth; 300 return !version.isStoppedAndRedundant() || version.errorMessages.len gth;
297 }); 301 });
302 var activeVersions = versions.filter(function(version) { return version. isActivating() || version.isActivated(); });
303 this._pushButton.disabled = !activeVersions.length || !!this._registrati on.isDeleted;
304
298 tableElement.appendChild(this._createVersionModeRow( 305 tableElement.appendChild(this._createVersionModeRow(
299 versions.filter(function(version) { return version.isNew() || versio n.isInstalling(); }), 306 versions.filter(function(version) { return version.isNew() || versio n.isInstalling(); }),
300 "installing", 307 "installing",
301 WebInspector.UIString("installing"))); 308 WebInspector.UIString("installing")));
302 tableElement.appendChild(this._createVersionModeRow( 309 tableElement.appendChild(this._createVersionModeRow(
303 versions.filter(function(version) { return version.isInstalled(); }) , 310 versions.filter(function(version) { return version.isInstalled(); }) ,
304 "waiting", 311 "waiting",
305 WebInspector.UIString("waiting"))); 312 WebInspector.UIString("waiting")));
306 tableElement.appendChild(this._createVersionModeRow( 313 tableElement.appendChild(this._createVersionModeRow(
307 versions.filter(function(version) { return version.isActivating() || version.isActivated(); }), 314 activeVersions,
308 "active", 315 "active",
309 WebInspector.UIString("active"))); 316 WebInspector.UIString("active")));
310 tableElement.appendChild(this._createVersionModeRow( 317 tableElement.appendChild(this._createVersionModeRow(
311 versions.filter(function(version) { return version.isRedundant(); }) , 318 versions.filter(function(version) { return version.isRedundant(); }) ,
312 "redundant", 319 "redundant",
313 WebInspector.UIString("redundant"))); 320 WebInspector.UIString("redundant")));
314 fragment.appendChild(tableElement); 321 fragment.appendChild(tableElement);
315 this._childrenListNode.removeChildren(); 322 this._childrenListNode.removeChildren();
316 this._childrenListNode.appendChild(fragment); 323 this._childrenListNode.appendChild(fragment);
317 }, 324 },
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 * @param {!Event} event 398 * @param {!Event} event
392 */ 399 */
393 _deleteButtonClicked: function(event) 400 _deleteButtonClicked: function(event)
394 { 401 {
395 this._manager.deleteRegistration(this._registration.id); 402 this._manager.deleteRegistration(this._registration.id);
396 }, 403 },
397 404
398 /** 405 /**
399 * @param {!Event} event 406 * @param {!Event} event
400 */ 407 */
408 _pushButtonClicked: function(event)
409 {
410 var data = "Test push message from DevTools."
411 this._manager.deliverPushMessage(this._registration.id, data);
412 },
413
414 /**
415 * @param {!Event} event
416 */
401 _startButtonClicked: function(event) 417 _startButtonClicked: function(event)
402 { 418 {
403 this._manager.startWorker(this._registration.scopeURL); 419 this._manager.startWorker(this._registration.scopeURL);
404 }, 420 },
405 421
406 /** 422 /**
407 * @param {string} versionId 423 * @param {string} versionId
408 * @param {!Event} event 424 * @param {!Event} event
409 */ 425 */
410 _stopButtonClicked: function(versionId, event) 426 _stopButtonClicked: function(versionId, event)
411 { 427 {
412 this._manager.stopWorker(versionId); 428 this._manager.stopWorker(versionId);
413 }, 429 },
414 430
415 /** 431 /**
416 * @param {string} versionId 432 * @param {string} versionId
417 * @param {!Event} event 433 * @param {!Event} event
418 */ 434 */
419 _inspectButtonClicked: function(versionId, event) 435 _inspectButtonClicked: function(versionId, event)
420 { 436 {
421 this._manager.inspectWorker(versionId); 437 this._manager.inspectWorker(versionId);
422 } 438 }
423 } 439 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/Images/notifications.svg ('k') | Source/devtools/front_end/resources/serviceWorkersView.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698