| 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();
|
| + },
|
| }
|
|
|