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

Unified Diff: Source/devtools/front_end/resources/ServiceWorkersView.js

Issue 1100403004: Add skipWaiting checkbox to ServiceWorkersView in DevTools [2/2 blink] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use annotated named function 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/devtools/front_end/resources/serviceWorkersView.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/resources/ServiceWorkersView.js
diff --git a/Source/devtools/front_end/resources/ServiceWorkersView.js b/Source/devtools/front_end/resources/ServiceWorkersView.js
index 6414d55ee0ade02a50c6c6d6ec289d3a94ff49df..8bde6ee47585bc5a2e3a76cc51422f7ff1282e93 100644
--- a/Source/devtools/front_end/resources/ServiceWorkersView.js
+++ b/Source/devtools/front_end/resources/ServiceWorkersView.js
@@ -238,7 +238,7 @@ WebInspector.ServiceWorkerOriginElement.prototype = {
swRegistrationElement._updateRegistration(registration);
return;
}
- swRegistrationElement = new WebInspector.SWRegistrationElement(this._manager, registration);
+ swRegistrationElement = new WebInspector.SWRegistrationElement(this._manager, this, registration);
this._registrationElements.set(registration.id, swRegistrationElement);
this._childrenListNode.appendChild(swRegistrationElement._element);
},
@@ -253,17 +253,27 @@ WebInspector.ServiceWorkerOriginElement.prototype = {
return;
this._registrationElements.delete(registrationId);
this._childrenListNode.removeChild(swRegistrationElement._element);
- }
+ },
+
+ /**
+ * @return {boolean}
+ */
+ _visible: function()
+ {
+ return !!this._element.parentElement;
+ },
}
/**
* @constructor
* @param {!WebInspector.ServiceWorkerManager} manager
+ * @param {!WebInspector.ServiceWorkerOriginElement} originElement
* @param {!WebInspector.ServiceWorkerRegistration} registration
*/
-WebInspector.SWRegistrationElement = function(manager, registration)
+WebInspector.SWRegistrationElement = function(manager, originElement, registration)
{
this._manager = manager;
+ this._originElement = originElement;
this._registration = registration;
this._element = createElementWithClass("div", "service-workers-registration");
var headerNode = this._element.createChild("li").createChild("div", "service-workers-registration-header");
@@ -280,6 +290,15 @@ WebInspector.SWRegistrationElement = function(manager, registration)
this._pushButton.title = WebInspector.UIString("Emulate push event");
this._pushButton.disabled = true
this._childrenListNode = this._element.createChild("ol");
+
+ this._skipWaitingCheckboxLabel = createCheckboxLabel(WebInspector.UIString("Skip waiting"));
+ this._skipWaitingCheckboxLabel.title = WebInspector.UIString("Simulate skipWaiting()");
+ this._skipWaitingCheckboxLabel.classList.add("service-workers-skip-waiting-checkbox-label");
+ this._skipWaitingCheckbox = this._skipWaitingCheckboxLabel.checkboxElement;
+ this._skipWaitingCheckbox.checked = true;
+ this._skipWaitingCheckbox.classList.add("service-workers-skip-waiting-checkbox");
+ this._skipWaitingCheckbox.addEventListener("change", this._skipWaitingCheckboxChanged.bind(this), false);
+
this._updateRegistration(registration);
}
@@ -293,7 +312,22 @@ WebInspector.SWRegistrationElement.prototype = {
this._titleNode.textContent = WebInspector.UIString(registration.isDeleted ? "Scope: %s - deleted" : "Scope: %s", registration.scopeURL.asParsedURL().path);
this._updateButton.disabled = !!registration.isDeleted;
this._deleteButton.disabled = !!registration.isDeleted;
+ this._skipWaitingCheckboxLabel.remove();
this._updateVersionList();
+
+ if (this._visible() && this._skipWaitingCheckbox.checked) {
+ this._registration.versions.valuesArray().map(callSkipWaitingForInstalledVersions.bind(this));
+ }
+
+ /**
+ * @this {WebInspector.SWRegistrationElement}
+ * @param {!WebInspector.ServiceWorkerVersion} version
+ */
+ function callSkipWaitingForInstalledVersions(version)
+ {
+ if (version.isInstalled())
+ this._manager.skipWaiting(version.id);
+ }
},
_updateVersionList: function()
@@ -336,7 +370,11 @@ WebInspector.SWRegistrationElement.prototype = {
_createVersionModeRow: function(versions, modeClass, modeTitle)
{
var modeRowElement = createElementWithClass("div", "service-workers-version-mode-row service-workers-version-mode-row-" + modeClass);
- modeRowElement.createChild("div", "service-workers-version-mode").createChild("div", "service-workers-version-mode-text").createTextChild(modeTitle);
+ var modeTitleDiv = modeRowElement.createChild("div", "service-workers-version-mode");
+ modeTitleDiv.createChild("div", "service-workers-version-mode-text").createTextChild(modeTitle);
+ if (modeClass == "waiting") {
+ modeTitleDiv.appendChild(this._skipWaitingCheckboxLabel);
+ }
var versionsElement = modeRowElement.createChild("div", "service-workers-versions");
for (var version of versions) {
var stateRowElement = versionsElement.createChild("div", "service-workers-version-row");
@@ -448,5 +486,30 @@ WebInspector.SWRegistrationElement.prototype = {
_inspectButtonClicked: function(versionId, event)
{
this._manager.inspectWorker(versionId);
- }
+ },
+
+ _skipWaitingCheckboxChanged: function()
+ {
+ if (!this._skipWaitingCheckbox.checked)
+ return;
+ this._registration.versions.valuesArray().map(callSkipWaitingForInstalledVersions.bind(this));
+
+ /**
+ * @this {WebInspector.SWRegistrationElement}
+ * @param {!WebInspector.ServiceWorkerVersion} version
+ */
+ function callSkipWaitingForInstalledVersions(version)
+ {
+ if (version.isInstalled())
+ this._manager.skipWaiting(version.id);
+ }
+ },
+
+ /**
+ * @return {boolean}
+ */
+ _visible: function()
+ {
+ return this._originElement._visible();
+ },
}
« no previous file with comments | « no previous file | Source/devtools/front_end/resources/serviceWorkersView.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698