Chromium Code Reviews| OLD | NEW |
|---|---|
| 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() |
| 11 { | 11 { |
| 12 WebInspector.VBox.call(this, true); | 12 WebInspector.VBox.call(this, true); |
| 13 this.registerRequiredCSS("resources/serviceWorkersView.css"); | |
| 14 this.contentElement.classList.add("service-workers-view"); | |
| 15 | 13 |
| 14 this._reportView = new WebInspector.ReportView(WebInspector.UIString("Servic e Workers")); | |
| 15 this._reportView.show(this.contentElement); | |
| 16 | 16 |
| 17 /** @type {boolean} */ | 17 this._toolbar = this._reportView.createToolbar(); |
| 18 this._showAll = false; | 18 |
| 19 // /** @type {!Map.<!WebInspector.ServiceWorkerRegistration, !WebInspector.S erviceWorkersView.Section>} */ | |
|
caseq
2016/05/05 01:09:22
nuke //?
Also, drop the dot after Map.
pfeldman
2016/05/05 02:21:41
Done.
| |
| 20 this._sections = new Map(); | |
|
caseq
2016/05/05 01:09:22
... or put as Symbol() on the registration and you
pfeldman
2016/05/05 02:21:41
Acknowledged.
| |
| 21 | |
| 19 /** @type {!Set.<string>} */ | 22 /** @type {!Set.<string>} */ |
| 20 this._securityOriginHosts = new Set(); | 23 this._securityOrigins = new Set(); |
|
caseq
2016/05/05 01:09:22
Drop this altogether!
pfeldman
2016/05/05 02:21:41
Done.
| |
| 21 /** @type {!Map.<string, !WebInspector.ServiceWorkerOriginWidget>} */ | |
| 22 this._originHostToOriginWidgetMap = new Map(); | |
| 23 /** @type {!Map.<string, !WebInspector.ServiceWorkerOriginWidget>} */ | |
| 24 this._registrationIdToOriginWidgetMap = new Map(); | |
| 25 | |
| 26 this._toolbar = new WebInspector.Toolbar("", this.contentElement); | |
| 27 | |
| 28 this._root = this.contentElement.createChild("div"); | |
| 29 this._root.classList.add("service-workers-root"); | |
| 30 | 24 |
| 31 WebInspector.targetManager.observeTargets(this); | 25 WebInspector.targetManager.observeTargets(this); |
| 32 } | 26 } |
| 33 | 27 |
| 34 WebInspector.ServiceWorkersView.prototype = { | 28 WebInspector.ServiceWorkersView.prototype = { |
| 35 /** | 29 /** |
| 36 * @override | 30 * @override |
| 37 * @param {!WebInspector.Target} target | 31 * @param {!WebInspector.Target} target |
| 38 */ | 32 */ |
| 39 targetAdded: function(target) | 33 targetAdded: function(target) |
| 40 { | 34 { |
| 41 if (this._target) | 35 if (this._target) |
| 42 return; | 36 return; |
| 43 this._target = target; | 37 this._target = target; |
| 44 this._manager = this._target.serviceWorkerManager; | 38 this._manager = this._target.serviceWorkerManager; |
| 45 | 39 |
| 46 var forceUpdate = new WebInspector.ToolbarCheckbox(WebInspector.UIString ("Update worker on reload"), WebInspector.UIString("Update Service Worker on pag e reload"), this._manager.forceUpdateOnReloadSetting()); | 40 var forceUpdate = new WebInspector.ToolbarCheckbox(WebInspector.UIString ("Force update on reload"), WebInspector.UIString("Force update Service Worker o n page reload"), this._manager.forceUpdateOnReloadSetting()); |
| 47 this._toolbar.appendToolbarItem(forceUpdate); | 41 this._toolbar.appendToolbarItem(forceUpdate); |
| 48 var fallbackToNetwork = new WebInspector.ToolbarCheckbox(WebInspector.UI String("Bypass worker for network"), WebInspector.UIString("Bypass Service Worke r and load resources from the network"), target.networkManager.bypassServiceWork erSetting()); | 42 var fallbackToNetwork = new WebInspector.ToolbarCheckbox(WebInspector.UI String("Bypass worker for network"), WebInspector.UIString("Bypass Service Worke r and load resources from the network"), target.networkManager.bypassServiceWork erSetting()); |
| 49 this._toolbar.appendToolbarItem(fallbackToNetwork); | 43 this._toolbar.appendToolbarItem(fallbackToNetwork); |
| 50 this._toolbar.appendSpacer(); | 44 this._toolbar.appendSpacer(); |
| 51 this._showAllCheckbox = new WebInspector.ToolbarCheckbox(WebInspector.UI String("Show all"), WebInspector.UIString("Show all Service Workers regardless o f the scope")); | 45 this._showAllCheckbox = new WebInspector.ToolbarCheckbox(WebInspector.UI String("Show all"), WebInspector.UIString("Show all Service Workers regardless o f the origin")); |
| 52 this._showAllCheckbox.inputElement.addEventListener("change", this._onSh owAllCheckboxChanged.bind(this), false); | 46 this._showAllCheckbox.inputElement.addEventListener("change", this._upda teSectionVisibility.bind(this), false); |
| 53 this._toolbar.appendToolbarItem(this._showAllCheckbox); | 47 this._toolbar.appendToolbarItem(this._showAllCheckbox); |
| 54 | 48 |
| 55 for (var registration of this._manager.registrations().values()) | 49 for (var registration of this._manager.registrations().values()) |
| 56 this._updateRegistration(registration); | 50 this._updateRegistration(registration); |
| 57 | 51 |
| 58 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events. RegistrationUpdated, this._registrationUpdated, this); | 52 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events. RegistrationUpdated, this._registrationUpdated, this); |
| 59 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events. RegistrationDeleted, this._registrationDeleted, this); | 53 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events. RegistrationDeleted, this._registrationDeleted, this); |
| 54 this._manager.addEventListener(WebInspector.ServiceWorkerManager.Events. RegistrationErrorAdded, this._registrationErrorAdded, this); | |
| 60 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.SecurityOriginAdded, this._securityOriginAdded, this); | 55 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.SecurityOriginAdded, this._securityOriginAdded, this); |
| 61 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.SecurityOriginRemoved, this._securityOriginRemoved, this); | 56 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.SecurityOriginRemoved, this._securityOriginRemoved, this); |
| 62 var securityOrigins = this._target.resourceTreeModel.securityOrigins(); | 57 var securityOrigins = this._target.resourceTreeModel.securityOrigins(); |
| 63 for (var i = 0; i < securityOrigins.length; ++i) | 58 for (var i = 0; i < securityOrigins.length; ++i) |
| 64 this._addOrigin(securityOrigins[i]); | 59 this._addOrigin(securityOrigins[i]); |
| 65 }, | 60 }, |
| 66 | 61 |
| 67 /** | 62 /** |
| 68 * @override | 63 * @override |
| 69 * @param {!WebInspector.Target} target | 64 * @param {!WebInspector.Target} target |
| 70 */ | 65 */ |
| 71 targetRemoved: function(target) | 66 targetRemoved: function(target) |
| 72 { | 67 { |
| 73 if (target !== this._target) | 68 if (target !== this._target) |
| 74 return; | 69 return; |
| 75 delete this._target; | 70 delete this._target; |
| 76 }, | 71 }, |
| 77 | 72 |
| 78 /** | 73 _updateSectionVisibility: function() |
| 79 * @param {!Event} event | |
| 80 */ | |
| 81 _onShowAllCheckboxChanged: function(event) | |
| 82 { | 74 { |
| 83 this._showAll = this._showAllCheckbox.checked(); | 75 for (var section of this._sections.values()) { |
| 84 if (this._showAll) { | 76 var registration = section._registration; |
|
caseq
2016/05/05 01:09:22
inline?
pfeldman
2016/05/05 02:21:41
Done.
| |
| 85 for (var originWidget of this._originHostToOriginWidgetMap.values()) { | 77 var visible = this._showAllCheckbox.checked() || this._securityOrigi ns.has(registration.securityOrigin); |
| 86 if (!originWidget.parentWidget()) | 78 section._section.element.classList.toggle("hidden", !visible); |
| 87 originWidget.show(this._root); | |
| 88 } | |
| 89 } else { | |
| 90 for (var originWidget of this._originHostToOriginWidgetMap.values()) { | |
| 91 if (originWidget.parentWidget() && !this._securityOriginHosts.ha s(originWidget._originHost)) | |
| 92 originWidget.detach(); | |
| 93 } | |
| 94 } | 79 } |
| 95 }, | 80 }, |
| 96 | 81 |
| 97 /** | 82 /** |
| 98 * @param {!WebInspector.Event} event | 83 * @param {!WebInspector.Event} event |
| 99 */ | 84 */ |
| 100 _registrationUpdated: function(event) | 85 _registrationUpdated: function(event) |
| 101 { | 86 { |
| 102 var registration = /** @type {!WebInspector.ServiceWorkerRegistration} * / (event.data); | 87 var registration = /** @type {!WebInspector.ServiceWorkerRegistration} * / (event.data); |
| 103 this._updateRegistration(registration); | 88 this._updateRegistration(registration); |
| 104 }, | 89 }, |
| 105 | 90 |
| 106 /** | 91 /** |
| 92 * @param {!WebInspector.Event} event | |
| 93 */ | |
| 94 _registrationErrorAdded: function(event) | |
| 95 { | |
| 96 var registration = /** @type {!WebInspector.ServiceWorkerRegistration} * / (event.data["registration"]); | |
| 97 var error = /** @type {!ServiceWorkerAgent.ServiceWorkerErrorMessage} */ (event.data["error"]); | |
| 98 var section = this._sections.get(registration); | |
| 99 if (!section) | |
| 100 return; | |
| 101 section._addError(error); | |
| 102 }, | |
| 103 | |
| 104 /** | |
| 107 * @param {!WebInspector.ServiceWorkerRegistration} registration | 105 * @param {!WebInspector.ServiceWorkerRegistration} registration |
| 108 */ | 106 */ |
| 109 _updateRegistration: function(registration) | 107 _updateRegistration: function(registration) |
| 110 { | 108 { |
| 111 var parsedURL = registration.scopeURL.asParsedURL(); | 109 var section = this._sections.get(registration); |
| 112 if (!parsedURL) | 110 if (!section) { |
| 113 return; | 111 section = new WebInspector.ServiceWorkersView.Section(this._manager, this._reportView.appendSection(""), registration); |
| 114 var originHost = parsedURL.securityOrigin(); | 112 this._sections.set(registration, section); |
| 115 var originWidget = this._originHostToOriginWidgetMap.get(originHost); | |
| 116 if (!originWidget) { | |
| 117 originWidget = new WebInspector.ServiceWorkerOriginWidget(this._mana ger, originHost); | |
| 118 if (this._securityOriginHosts.has(originHost) || this._showAll) | |
| 119 originWidget.show(this._root); | |
| 120 this._originHostToOriginWidgetMap.set(originHost, originWidget); | |
| 121 } | 113 } |
| 122 this._registrationIdToOriginWidgetMap.set(registration.id, originWidget) ; | 114 section._scheduleUpdate(); |
| 123 originWidget._updateRegistration(registration); | |
| 124 }, | 115 }, |
| 125 | 116 |
| 126 /** | 117 /** |
| 127 * @param {!WebInspector.Event} event | 118 * @param {!WebInspector.Event} event |
| 128 */ | 119 */ |
| 129 _registrationDeleted: function(event) | 120 _registrationDeleted: function(event) |
| 130 { | 121 { |
| 131 var registration = /** @type {!WebInspector.ServiceWorkerRegistration} * / (event.data); | 122 var registration = /** @type {!WebInspector.ServiceWorkerRegistration} * / (event.data); |
| 132 var registrationId = registration.id; | 123 var section = this._sections.get(registration); |
| 133 var originWidget = this._registrationIdToOriginWidgetMap.get(registratio nId); | 124 if (section) |
| 134 if (!originWidget) | 125 section._section.remove(); |
| 135 return; | 126 this._sections.delete(registration); |
| 136 this._registrationIdToOriginWidgetMap.delete(registrationId); | |
| 137 originWidget._deleteRegistration(registrationId); | |
| 138 if (originWidget._hasRegistration()) | |
| 139 return; | |
| 140 if (originWidget.parentWidget()) | |
| 141 originWidget.detach(); | |
| 142 this._originHostToOriginWidgetMap.delete(originWidget._originHost); | |
| 143 }, | 127 }, |
| 144 | 128 |
| 145 /** | 129 /** |
| 146 * @param {!WebInspector.Event} event | 130 * @param {!WebInspector.Event} event |
| 147 */ | 131 */ |
| 148 _securityOriginAdded: function(event) | 132 _securityOriginAdded: function(event) |
| 149 { | 133 { |
| 150 this._addOrigin(/** @type {string} */ (event.data)); | 134 this._addOrigin(/** @type {string} */ (event.data)); |
| 151 }, | 135 }, |
| 152 | 136 |
| 153 /** | 137 /** |
| 154 * @param {string} securityOrigin | 138 * @param {string} securityOrigin |
| 155 */ | 139 */ |
| 156 _addOrigin: function(securityOrigin) | 140 _addOrigin: function(securityOrigin) |
|
caseq
2016/05/05 01:09:22
remove, call _updateSectionVisibility() directly.
pfeldman
2016/05/05 02:21:41
Done.
| |
| 157 { | 141 { |
| 158 var parsedURL = securityOrigin.asParsedURL(); | 142 this._securityOrigins.add(securityOrigin); |
| 159 if (!parsedURL) | 143 this._updateSectionVisibility(); |
| 160 return; | |
| 161 var originHost = parsedURL.securityOrigin(); | |
| 162 if (this._securityOriginHosts.has(originHost)) | |
| 163 return; | |
| 164 this._securityOriginHosts.add(originHost); | |
| 165 var originWidget = this._originHostToOriginWidgetMap.get(originHost); | |
| 166 if (!originWidget) | |
| 167 return; | |
| 168 originWidget.show(this._root); | |
| 169 }, | 144 }, |
| 170 | 145 |
| 171 /** | 146 /** |
| 172 * @param {!WebInspector.Event} event | 147 * @param {!WebInspector.Event} event |
| 173 */ | 148 */ |
| 174 _securityOriginRemoved: function(event) | 149 _securityOriginRemoved: function(event) |
|
caseq
2016/05/05 01:09:22
ditto.
pfeldman
2016/05/05 02:21:41
Done.
| |
| 175 { | 150 { |
| 176 var securityOrigin = /** @type {string} */ (event.data); | 151 var securityOrigin = /** @type {string} */ (event.data); |
| 177 var parsedURL = securityOrigin.asParsedURL(); | 152 this._securityOrigins.delete(securityOrigin); |
| 178 if (!parsedURL) | 153 this._updateSectionVisibility(); |
| 179 return; | |
| 180 var originHost = parsedURL.securityOrigin(); | |
| 181 if (!this._securityOriginHosts.has(originHost)) | |
| 182 return; | |
| 183 this._securityOriginHosts.delete(originHost); | |
| 184 if (this._showAll) | |
| 185 return; | |
| 186 var originWidget = this._originHostToOriginWidgetMap.get(originHost); | |
| 187 if (!originWidget) | |
| 188 return; | |
| 189 originWidget.detach(); | |
| 190 }, | 154 }, |
| 191 | 155 |
| 192 __proto__: WebInspector.VBox.prototype | 156 __proto__: WebInspector.VBox.prototype |
| 193 } | |
| 194 | |
| 195 /** | |
| 196 * @constructor | |
| 197 * @extends {WebInspector.VBox} | |
| 198 * @param {!WebInspector.ServiceWorkerManager} manager | |
| 199 * @param {string} originHost | |
| 200 */ | |
| 201 WebInspector.ServiceWorkerOriginWidget = function(manager, originHost) | |
| 202 { | |
| 203 WebInspector.VBox.call(this); | |
| 204 this._manager = manager; | |
| 205 /** @type {!Map.<string, !WebInspector.SWRegistrationWidget>} */ | |
| 206 this._registrationWidgets = new Map(); | |
| 207 this._originHost = originHost; | |
| 208 this.element.classList.add("service-workers-origin"); | |
| 209 this._titleElement = this.element.createChild("span", "service-workers-origi n-title"); | |
| 210 } | |
| 211 | |
| 212 WebInspector.ServiceWorkerOriginWidget.prototype = { | |
| 213 /** | |
| 214 * @return {boolean} | |
| 215 */ | |
| 216 _hasRegistration: function() | |
| 217 { | |
| 218 return this._registrationWidgets.size != 0; | |
| 219 }, | |
| 220 | |
| 221 /** | |
| 222 * @param {!WebInspector.ServiceWorkerRegistration} registration | |
| 223 */ | |
| 224 _updateRegistration: function(registration) | |
| 225 { | |
| 226 this._titleElement.setTextAndTitle(WebInspector.UIString(registration.is Deleted ? "%s%s - deleted" : "%s%s", this._originHost, registration.scopeURL.asP arsedURL().path)); | |
| 227 | |
| 228 var registrationWidget = this._registrationWidgets.get(registration.id); | |
| 229 if (registrationWidget) { | |
| 230 registrationWidget._updateRegistration(registration); | |
| 231 return; | |
| 232 } | |
| 233 registrationWidget = new WebInspector.SWRegistrationWidget(this._manager , this, registration); | |
| 234 this._registrationWidgets.set(registration.id, registrationWidget); | |
| 235 registrationWidget.show(this.element); | |
| 236 }, | |
| 237 | |
| 238 /** | |
| 239 * @param {string} registrationId | |
| 240 */ | |
| 241 _deleteRegistration: function(registrationId) | |
| 242 { | |
| 243 var registrationWidget = this._registrationWidgets.get(registrationId); | |
| 244 if (!registrationWidget) | |
| 245 return; | |
| 246 this._registrationWidgets.delete(registrationId); | |
| 247 registrationWidget.detach(); | |
| 248 }, | |
| 249 | |
| 250 __proto__: WebInspector.VBox.prototype | |
| 251 } | 157 } |
| 252 | 158 |
| 253 /** | 159 /** |
| 254 * @constructor | 160 * @constructor |
| 255 * @extends {WebInspector.VBox} | |
| 256 * @param {!WebInspector.ServiceWorkerManager} manager | 161 * @param {!WebInspector.ServiceWorkerManager} manager |
| 257 * @param {!WebInspector.ServiceWorkerOriginWidget} originWidget | 162 * @param {!WebInspector.ReportView.Section} section |
| 258 * @param {!WebInspector.ServiceWorkerRegistration} registration | 163 * @param {!WebInspector.ServiceWorkerRegistration} registration |
| 259 */ | 164 */ |
| 260 WebInspector.SWRegistrationWidget = function(manager, originWidget, registration ) | 165 WebInspector.ServiceWorkersView.Section = function(manager, section, registratio n) |
| 261 { | 166 { |
| 262 WebInspector.VBox.call(this); | |
| 263 this._manager = manager; | 167 this._manager = manager; |
| 264 this._originWidget = originWidget; | 168 this._section = section; |
| 265 this._registration = registration; | 169 this._registration = registration; |
| 266 this.element.classList.add("service-workers-registration"); | |
| 267 | 170 |
| 268 var toolbar = new WebInspector.Toolbar("", this.element); | 171 this._toolbar = section.createToolbar(); |
| 269 this._updateButton = new WebInspector.ToolbarButton(WebInspector.UIString("U pdate"), "refresh-toolbar-item", WebInspector.UIString("Update")); | 172 this._toolbar.renderAsLinks(); |
| 173 this._updateButton = new WebInspector.ToolbarButton(WebInspector.UIString("U pdate"), undefined, WebInspector.UIString("Update")); | |
| 270 this._updateButton.addEventListener("click", this._updateButtonClicked.bind( this)); | 174 this._updateButton.addEventListener("click", this._updateButtonClicked.bind( this)); |
| 271 toolbar.appendToolbarItem(this._updateButton); | 175 this._toolbar.appendToolbarItem(this._updateButton); |
| 272 | 176 |
| 273 toolbar.appendSeparator(); | 177 // Preserve the order. |
| 274 this._pushButton = new WebInspector.ToolbarButton(WebInspector.UIString("Emu late push event"), "notification-toolbar-item", WebInspector.UIString("Push")); | 178 this._section.appendField(WebInspector.UIString("Source")); |
| 179 this._section.appendField(WebInspector.UIString("Status")); | |
| 180 this._section.appendField(WebInspector.UIString("Clients")); | |
| 181 this._section.appendField(WebInspector.UIString("Errors")); | |
| 182 this._errorsList = this._wrapWidget(this._section.appendRow()); | |
| 183 this._errorsList.classList.add("service-worker-error-stack", "monospace", "h idden"); | |
| 184 | |
| 185 this._pushButton = new WebInspector.ToolbarButton(WebInspector.UIString("Emu late push event"), undefined, WebInspector.UIString("Push")); | |
|
caseq
2016/05/05 01:09:22
let's keep toolbar items together.
pfeldman
2016/05/05 02:21:41
What do you mean?
| |
| 275 this._pushButton.addEventListener("click", this._pushButtonClicked.bind(this )); | 186 this._pushButton.addEventListener("click", this._pushButtonClicked.bind(this )); |
| 276 toolbar.appendToolbarItem(this._pushButton); | 187 this._toolbar.appendToolbarItem(this._pushButton); |
| 277 toolbar.appendSpacer(); | 188 this._deleteButton = new WebInspector.ToolbarButton(WebInspector.UIString("U nregister service worker"), undefined, WebInspector.UIString("Unregister")); |
| 278 this._deleteButton = new WebInspector.ToolbarButton(WebInspector.UIString("U nregister service worker"), "garbage-collect-toolbar-item", WebInspector.UIStrin g("Unregister")); | 189 this._deleteButton.addEventListener("click", this._unregisterButtonClicked.b ind(this)); |
| 279 this._deleteButton.addEventListener("click", this._deleteButtonClicked.bind( this)); | 190 this._toolbar.appendToolbarItem(this._deleteButton); |
| 280 toolbar.appendToolbarItem(this._deleteButton); | |
| 281 | 191 |
| 282 this._tabbedPane = new WebInspector.TabbedPane(); | 192 this._linkifier = new WebInspector.Linkifier(); |
| 283 this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSele cted, this._tabSelected, this); | 193 /** @type {!Map<string, !WebInspector.TargetInfo>} */ |
| 284 var modes = WebInspector.ServiceWorkerVersion.Modes; | 194 this._clientInfoCache = new Map(); |
| 285 this._tabbedPane.appendTab(modes.Installing, WebInspector.UIString("Installi ng"), new WebInspector.VBox()); | 195 for (var error of registration.errors) |
| 286 this._tabbedPane.appendTab(modes.Waiting, WebInspector.UIString("Waiting"), new WebInspector.VBox()); | 196 this._addError(error); |
| 287 this._tabbedPane.appendTab(modes.Active, WebInspector.UIString("Active"), ne w WebInspector.VBox()); | 197 WebInspector.console.log("S: " + this._registration.scopeURL); |
|
caseq
2016/05/05 01:09:21
remove this?
pfeldman
2016/05/05 02:21:41
Done.
| |
| 288 this._tabbedPane.appendTab(modes.Redundant, WebInspector.UIString("Redundant "), new WebInspector.VBox()); | 198 this._throttler = new WebInspector.Throttler(500); |
| 289 this._tabbedPane.show(this.element); | |
| 290 | |
| 291 /** @type {!Map<string, !WebInspector.SWVersionWidget>} */ | |
| 292 this._versionWidgets = new Map(); | |
| 293 | |
| 294 this._updateRegistration(registration); | |
| 295 } | 199 } |
| 296 | 200 |
| 297 WebInspector.SWRegistrationWidget.prototype = { | 201 WebInspector.ServiceWorkersView.Section.prototype = { |
| 298 /** | 202 _scheduleUpdate: function() |
| 299 * @param {!WebInspector.Event} event | |
| 300 */ | |
| 301 _tabSelected: function(event) | |
| 302 { | 203 { |
| 303 if (event.data["isUserGesture"]) | 204 if (WebInspector.ServiceWorkersView._noThrottle) { |
| 304 this._lastManuallySelectedTab = event.data["tabId"]; | 205 this._update(); |
| 206 return; | |
| 207 } | |
| 208 this._throttler.schedule(this._update.bind(this)); | |
| 305 }, | 209 }, |
| 306 | 210 |
| 307 /** | 211 /** |
| 308 * @param {!WebInspector.ServiceWorkerRegistration} registration | 212 * @return {!Promise} |
| 309 */ | 213 */ |
| 310 _updateRegistration: function(registration) | 214 _update: function() |
| 311 { | 215 { |
| 312 this._registration = registration; | 216 var fingerprint = this._registration.fingerprint(); |
| 313 this._updateButton.setEnabled(!registration.isDeleted); | 217 if (fingerprint === this._fingerprint) |
| 314 this._deleteButton.setEnabled(!registration.isDeleted); | 218 return Promise.resolve(); |
| 219 this._fingerprint = fingerprint; | |
| 315 | 220 |
| 316 /** @type {!Map<string, !WebInspector.SWVersionWidget>} */ | 221 this._toolbar.setEnabled(!this._registration.isDeleted); |
| 317 var versionWidgets = new Map(); | |
| 318 | 222 |
| 319 // Remove all the redundant workers that are older than the | 223 var versions = this._registration.versionsByMode(); |
| 320 // active version. | 224 var title = WebInspector.UIString(this._registration.isDeleted ? "%s - d eleted" : "%s", this._registration.scopeURL); |
|
caseq
2016/05/05 01:09:22
nit:
var title = this._registration.isDeleted ? We
pfeldman
2016/05/05 02:21:41
Done.
| |
| 321 var versions = registration.versions.valuesArray(); | 225 this._section.setTitle(title); |
| 322 var activeVersion = versions.find(version => version.mode() === WebInspe ctor.ServiceWorkerVersion.Modes.Active); | 226 |
| 323 if (activeVersion) { | 227 var active = versions.get(WebInspector.ServiceWorkerVersion.Modes.Active ); |
| 324 versions = versions.filter(version => { | 228 var waiting = versions.get(WebInspector.ServiceWorkerVersion.Modes.Waiti ng); |
| 325 if (version.mode() == WebInspector.ServiceWorkerVersion.Modes.Re dundant) | 229 var installing = versions.get(WebInspector.ServiceWorkerVersion.Modes.In stalling); |
| 326 return version.scriptLastModified > activeVersion.scriptLast Modified; | 230 |
| 327 return true; | 231 var statusValue = this._wrapWidget(this._section.appendField(WebInspecto r.UIString("Status"))); |
| 328 }); | 232 statusValue.removeChildren(); |
| 233 var versionsStack = statusValue.createChild("div", "service-worker-versi on-stack"); | |
| 234 versionsStack.createChild("div", "service-worker-version-stack-bar"); | |
| 235 | |
| 236 if (active) { | |
|
caseq
2016/05/05 01:09:22
This is getting long, let's extract updating activ
pfeldman
2016/05/05 02:21:41
I'd rather not for now. It is still manageable.
| |
| 237 var scriptElement = this._section.appendField(WebInspector.UIString( "Source")); | |
| 238 scriptElement.removeChildren(); | |
| 239 var components = WebInspector.ParsedURL.splitURLIntoPathComponents(a ctive.scriptURL); | |
| 240 scriptElement.appendChild(WebInspector.linkifyURLAsNode(active.scrip tURL, components.peekLast())); | |
| 241 scriptElement.createChild("div", "report-field-value-subtitle").text Content = WebInspector.UIString("Last modified %s", new Date(active.scriptLastMo dified * 1000).toLocaleString()); | |
| 242 | |
| 243 var activeEntry = versionsStack.createChild("div", "service-worker-v ersion"); | |
| 244 activeEntry.createChild("div", "service-worker-active-circle"); | |
| 245 activeEntry.createChild("span").textContent = WebInspector.UIString( "#%s active and is %s", active.id, active.runningStatus); | |
| 246 | |
| 247 if (active.isRunning() || active.isStarting()) { | |
| 248 var stopButton = activeEntry.createChild("span", "link"); | |
| 249 stopButton.textContent = WebInspector.UIString("stop"); | |
| 250 stopButton.addEventListener("click", this._stopButtonClicked.bin d(this, active.id)); | |
| 251 if (!this._manager.targetForVersionId(active.id)) { | |
| 252 var inspectButton = activeEntry.createChild("span", "link"); | |
|
caseq
2016/05/05 01:09:21
Let's extract button creation into a method, we do
pfeldman
2016/05/05 02:21:41
Done.
| |
| 253 inspectButton.textContent = WebInspector.UIString("inspect") ; | |
| 254 inspectButton.addEventListener("click", this._inspectButtonC licked.bind(this, active.id)); | |
| 255 } | |
| 256 } else if (active.isStartable()) { | |
| 257 var startButton = activeEntry.createChild("span", "link"); | |
| 258 startButton.textContent = WebInspector.UIString("start"); | |
| 259 startButton.addEventListener("click", this._startButtonClicked.b ind(this)); | |
| 260 } | |
| 261 | |
| 262 var clientsList = this._wrapWidget(this._section.appendField(WebInsp ector.UIString("Clients"))); | |
| 263 clientsList.removeChildren(); | |
| 264 this._section.setFieldVisible(WebInspector.UIString("Clients"), acti ve.controlledClients.length); | |
| 265 for (var client of active.controlledClients) { | |
| 266 var clientLabelText = clientsList.createChild("div", "service-wo rker-client"); | |
| 267 if (this._clientInfoCache.has(client)) | |
| 268 this._updateClientInfo(clientLabelText, /** @type {!WebInspe ctor.TargetInfo} */(this._clientInfoCache.get(client))); | |
| 269 this._manager.getTargetInfo(client, this._onClientInfo.bind(this , clientLabelText)); | |
| 270 } | |
| 329 } | 271 } |
| 330 | 272 |
| 331 var firstMode; | 273 if (waiting) { |
| 332 var modesWithVersions = new Set(); | 274 var waitingEntry = versionsStack.createChild("div", "service-worker- version"); |
| 333 for (var version of versions) { | 275 waitingEntry.createChild("div", "service-worker-waiting-circle"); |
| 334 if (version.isStoppedAndRedundant() && !version.errorMessages.length ) | 276 waitingEntry.createChild("span").textContent = WebInspector.UIString ("#%s waiting to activate", waiting.id); |
| 335 continue; | 277 var skipButton = waitingEntry.createChild("span", "link"); |
| 336 var mode = version.mode(); | 278 skipButton.textContent = WebInspector.UIString("skipWaiting"); |
|
caseq
2016/05/05 01:09:21
Skip Waiting
pfeldman
2016/05/05 02:21:41
This is a term.
| |
| 337 if (!firstMode) | 279 skipButton.addEventListener("click", this._skipButtonClicked.bind(th is)); |
| 338 firstMode = mode; | 280 waitingEntry.createChild("div", "service-worker-subtitle").textConte nt = new Date(waiting.scriptLastModified * 1000).toLocaleString(); |
| 339 modesWithVersions.add(mode); | |
| 340 var view = this._tabbedPane.tabView(mode); | |
| 341 var versionWidget = this._versionWidgets.get(version.id); | |
| 342 if (versionWidget) | |
| 343 versionWidget._updateVersion(version); | |
| 344 else | |
| 345 versionWidget = new WebInspector.SWVersionWidget(this._manager, this._registration.scopeURL, version); | |
| 346 versionWidget.show(view.element, view.element.firstElementChild); | |
| 347 versionWidgets.set(version.id, versionWidget); | |
| 348 } | 281 } |
| 349 for (var id of this._versionWidgets.keys()) { | 282 if (installing) { |
| 350 if (!versionWidgets.has(id)) | 283 var installingEntry = versionsStack.createChild("div", "service-work er-version"); |
| 351 this._versionWidgets.get(id).detach(); | 284 installingEntry.createChild("div", "service-worker-installing-circle "); |
| 285 installingEntry.createChild("span").textContent = WebInspector.UIStr ing("#%s installing", installing.id); | |
| 286 installingEntry.createChild("div", "service-worker-subtitle").textCo ntent = new Date(installing.scriptLastModified * 1000).toLocaleString(); | |
| 352 } | 287 } |
| 353 this._versionWidgets = versionWidgets; | |
| 354 | 288 |
| 355 for (var id of this._tabbedPane.tabIds()) | 289 this._section.setFieldVisible(WebInspector.UIString("Errors"), !!this._r egistration.errors.length); |
| 356 this._tabbedPane.setTabEnabled(id, modesWithVersions.has(id)); | 290 var errorsValue = this._wrapWidget(this._section.appendField(WebInspecto r.UIString("Errors"))); |
| 357 | 291 var errorsLabel = createLabel(String(this._registration.errors.length), "error-icon"); |
| 358 this._pushButton.setEnabled(modesWithVersions.has(WebInspector.ServiceWo rkerVersion.Modes.Active) && !this._registration.isDeleted); | 292 errorsLabel.classList.add("service-worker-errors-label"); |
| 359 | 293 errorsValue.appendChild(errorsLabel); |
| 360 if (modesWithVersions.has(this._lastManuallySelectedTab)) { | 294 this._moreButton = errorsValue.createChild("span", "link"); |
| 361 this._tabbedPane.selectTab(this._lastManuallySelectedTab); | 295 this._moreButton.textContent = this._errorsList.classList.contains("hidd en") ? WebInspector.UIString("details") : WebInspector.UIString("hide"); |
| 362 return; | 296 this._moreButton.addEventListener("click", this._moreErrorsButtonClicked .bind(this)); |
| 363 } | 297 var clearButton = errorsValue.createChild("span", "link"); |
| 364 if (activeVersion) { | 298 clearButton.textContent = WebInspector.UIString("clear"); |
| 365 this._tabbedPane.selectTab(WebInspector.ServiceWorkerVersion.Modes.A ctive); | 299 clearButton.addEventListener("click", this._clearErrorsButtonClicked.bin d(this)); |
| 366 return; | 300 return Promise.resolve(); |
| 367 } | |
| 368 if (firstMode) | |
| 369 this._tabbedPane.selectTab(firstMode); | |
| 370 }, | 301 }, |
| 371 | 302 |
| 372 /** | 303 /** |
| 373 * @param {!WebInspector.Event} event | 304 * @param {!ServiceWorkerAgent.ServiceWorkerErrorMessage} error |
| 374 */ | 305 */ |
| 375 _deleteButtonClicked: function(event) | 306 _addError: function(error) |
| 307 { | |
| 308 var location = error.sourceURL ? "(" + error.sourceURL + ":" + error.lin eNumber + ")" : ""; | |
|
caseq
2016/05/05 01:09:21
WebInspector.UIString("(%s:%d)")
pfeldman
2016/05/05 02:21:41
It is unused :)
| |
| 309 var target = this._manager.targetForVersionId(error.versionId); | |
| 310 var message = this._errorsList.createChild("div"); | |
| 311 if (this._errorsList.childElementCount > 100) | |
| 312 this._errorsList.firstElementChild.remove(); | |
| 313 message.appendChild(this._linkifier.linkifyScriptLocation(target, null, error.sourceURL, error.lineNumber)); | |
| 314 message.appendChild(createLabel("#" + error.versionId + ": " + error.err orMessage, "error-icon")); | |
|
caseq
2016/05/05 01:09:22
WebInspector.UIString()?
pfeldman
2016/05/05 02:21:41
This is from the server, we don't wrap those.
| |
| 315 }, | |
| 316 | |
| 317 _unregisterButtonClicked: function() | |
| 376 { | 318 { |
| 377 this._manager.deleteRegistration(this._registration.id); | 319 this._manager.deleteRegistration(this._registration.id); |
| 378 }, | 320 }, |
| 379 | 321 |
| 380 /** | 322 _updateButtonClicked: function() |
| 381 * @param {!WebInspector.Event} event | |
| 382 */ | |
| 383 _updateButtonClicked: function(event) | |
| 384 { | 323 { |
| 385 this._manager.updateRegistration(this._registration.id); | 324 this._manager.updateRegistration(this._registration.id); |
| 386 }, | 325 }, |
| 387 | 326 |
| 388 /** | 327 _pushButtonClicked: function() |
| 389 * @param {!WebInspector.Event} event | |
| 390 */ | |
| 391 _pushButtonClicked: function(event) | |
| 392 { | 328 { |
| 393 var data = "Test push message from DevTools." | 329 var data = "Test push message from DevTools." |
| 394 this._manager.deliverPushMessage(this._registration.id, data); | 330 this._manager.deliverPushMessage(this._registration.id, data); |
| 395 }, | 331 }, |
| 396 | 332 |
| 397 __proto__: WebInspector.VBox.prototype | |
| 398 } | |
| 399 | |
| 400 /** | |
| 401 * @constructor | |
| 402 * @extends {WebInspector.VBox} | |
| 403 * @param {!WebInspector.ServiceWorkerManager} manager | |
| 404 * @param {string} scopeURL | |
| 405 * @param {!WebInspector.ServiceWorkerVersion} version | |
| 406 */ | |
| 407 WebInspector.SWVersionWidget = function(manager, scopeURL, version) | |
| 408 { | |
| 409 WebInspector.VBox.call(this); | |
| 410 this._manager = manager; | |
| 411 this._scopeURL = scopeURL; | |
| 412 this._version = version; | |
| 413 this.element.classList.add("service-workers-version", "flex-none"); | |
| 414 | |
| 415 /** | 333 /** |
| 416 * @type {!Object.<string, !WebInspector.TargetInfo>} | |
| 417 */ | |
| 418 this._clientInfoCache = {}; | |
| 419 this._createElements(); | |
| 420 this._updateVersion(version); | |
| 421 } | |
| 422 | |
| 423 WebInspector.SWVersionWidget.prototype = { | |
| 424 _createElements: function() | |
| 425 { | |
| 426 var panel = createElementWithClass("div", "service-workers-versions-pane l"); | |
| 427 var leftPanel = panel.createChild("div", "service-workers-versions-panel -top"); | |
| 428 var rightPanel = panel.createChild("div", "service-workers-versions-pane l-bottom"); | |
| 429 this._scriptCell = this._addTableRow(leftPanel, WebInspector.UIString("U RL")); | |
| 430 this._workerCell = this._addTableRow(leftPanel, WebInspector.UIString("S tate")); | |
| 431 this._updatedCell = this._addTableRow(leftPanel, WebInspector.UIString(" Updated")); | |
| 432 this._updatedCell.classList.add("service-worker-script-response-time"); | |
| 433 this._scriptLastModifiedCell = this._addTableRow(leftPanel, WebInspector .UIString("Last-Modified")); | |
| 434 this._scriptLastModifiedCell.classList.add("service-worker-script-last-m odified"); | |
| 435 rightPanel.createChild("div", "service-workers-versions-table-title").cr eateTextChild(WebInspector.UIString("Recent messages")); | |
| 436 this._messagesPanel = rightPanel.createChild("div", "service-workers-ver sions-table-messages-content"); | |
| 437 this._clientsTitle = rightPanel.createChild("div", "service-workers-vers ions-table-title"); | |
| 438 this._clientsTitle.createTextChild(WebInspector.UIString("Controlled cli ents")); | |
| 439 this._clientsPanel = rightPanel.createChild("div", "service-workers-vers ions-table-clients-content"); | |
| 440 this.element.appendChild(panel); | |
| 441 }, | |
| 442 | |
| 443 /** | |
| 444 * @param {!WebInspector.ServiceWorkerVersion} version | |
| 445 */ | |
| 446 _updateVersion: function(version) | |
| 447 { | |
| 448 this._workerCell.removeChildren(); | |
| 449 if (version.isRunning() || version.isStarting() || version.isStartable() ) { | |
| 450 var runningStatusCell = this._workerCell.createChild("div", "service -workers-versions-table-worker-running-status-cell"); | |
| 451 var runningStatusLeftCell = runningStatusCell.createChild("div"); | |
| 452 var runningStatusRightCell = runningStatusCell.createChild("div"); | |
| 453 if (version.isRunning() || version.isStarting()) { | |
| 454 var toolbar = new WebInspector.Toolbar("", runningStatusRightCel l); | |
| 455 var stopButton = new WebInspector.ToolbarButton(WebInspector.UIS tring("Stop"), "stop-toolbar-item"); | |
| 456 stopButton.addEventListener("click", this._stopButtonClicked.bin d(this, version.id)); | |
| 457 toolbar.appendToolbarItem(stopButton); | |
| 458 } else if (version.isStartable()) { | |
| 459 var toolbar = new WebInspector.Toolbar("", runningStatusRightCel l); | |
| 460 var startButton = new WebInspector.ToolbarButton(WebInspector.UI String("Start"), "play-toolbar-item"); | |
| 461 startButton.addEventListener("click", this._startButtonClicked.b ind(this)); | |
| 462 toolbar.appendToolbarItem(startButton); | |
| 463 } | |
| 464 runningStatusLeftCell.setTextAndTitle(version.runningStatus); | |
| 465 if ((version.isRunning() || version.isStarting()) && !this._manager. hasWorkerWithVersionId(version.id)) { | |
| 466 var inspectButton = runningStatusLeftCell.createChild("span", "s ervice-workers-versions-table-running-status-inspect"); | |
| 467 inspectButton.setTextAndTitle(WebInspector.UIString("inspect")); | |
| 468 inspectButton.addEventListener("click", this._inspectButtonClick ed.bind(this, version.id), false); | |
| 469 } | |
| 470 } else { | |
| 471 this._workerCell.setTextAndTitle(version.runningStatus); | |
| 472 } | |
| 473 | |
| 474 this._scriptCell.setTextAndTitle(version.scriptURL.asParsedURL().path); | |
| 475 this._updatedCell.setTextAndTitle(version.scriptResponseTime ? (new Date (version.scriptResponseTime * 1000)).toConsoleTime() : ""); | |
| 476 this._scriptLastModifiedCell.setTextAndTitle(version.scriptLastModified ? (new Date(version.scriptLastModified * 1000)).toConsoleTime() : ""); | |
| 477 | |
| 478 this._messagesPanel.removeChildren(); | |
| 479 if (version.scriptLastModified) { | |
| 480 var scriptLastModifiedLabel = this._messagesPanel.createChild("label ", " service-workers-info service-worker-script-last-modified", "dt-icon-label") ; | |
| 481 scriptLastModifiedLabel.type = "info-icon"; | |
| 482 scriptLastModifiedLabel.createTextChild(WebInspector.UIString("Last- Modified: %s", (new Date(version.scriptLastModified * 1000)).toConsoleTime())); | |
| 483 } | |
| 484 if (version.scriptResponseTime) { | |
| 485 var scriptResponseTimeDiv = this._messagesPanel.createChild("label", " service-workers-info service-worker-script-response-time", "dt-icon-label"); | |
| 486 scriptResponseTimeDiv.type = "info-icon"; | |
| 487 scriptResponseTimeDiv.createTextChild(WebInspector.UIString("Server response time: %s", (new Date(version.scriptResponseTime * 1000)).toConsoleTime( ))); | |
| 488 } | |
| 489 | |
| 490 var errorMessages = version.errorMessages; | |
| 491 for (var index = 0; index < errorMessages.length; ++index) { | |
| 492 var errorDiv = this._messagesPanel.createChild("div", "service-worke rs-error"); | |
| 493 errorDiv.createChild("label", "", "dt-icon-label").type = "error-ico n"; | |
| 494 errorDiv.createChild("div", "service-workers-error-message").createT extChild(errorMessages[index].errorMessage); | |
| 495 var script_path = errorMessages[index].sourceURL; | |
| 496 var script_url; | |
| 497 if (script_url = script_path.asParsedURL()) | |
| 498 script_path = script_url.displayName; | |
| 499 if (script_path.length && errorMessages[index].lineNumber != -1) | |
| 500 script_path = String.sprintf("(%s:%d)", script_path, errorMessag es[index].lineNumber); | |
| 501 errorDiv.createChild("div", "service-workers-error-line").createText Child(script_path); | |
| 502 } | |
| 503 | |
| 504 this._clientsTitle.classList.toggle("hidden", version.controlledClients. length == 0); | |
| 505 | |
| 506 this._clientsPanel.removeChildren(); | |
| 507 for (var i = 0; i < version.controlledClients.length; ++i) { | |
| 508 var client = version.controlledClients[i]; | |
| 509 var clientLabelText = this._clientsPanel.createChild("div", "service -worker-client"); | |
| 510 if (this._clientInfoCache[client]) { | |
| 511 this._updateClientInfo(clientLabelText, this._clientInfoCache[cl ient]); | |
| 512 } | |
| 513 this._manager.getTargetInfo(client, this._onClientInfo.bind(this, cl ientLabelText)); | |
| 514 } | |
| 515 }, | |
| 516 | |
| 517 /** | |
| 518 * @param {!Element} tableElement | |
| 519 * @param {string} title | |
| 520 * @return {!Element} | |
| 521 */ | |
| 522 _addTableRow: function(tableElement, title) | |
| 523 { | |
| 524 var rowElement = tableElement.createChild("div", "service-workers-versio ns-table-row"); | |
| 525 rowElement.createChild("div", "service-workers-versions-table-row-title" ).setTextAndTitle(title); | |
| 526 return rowElement.createChild("div", "service-workers-versions-table-row -content"); | |
| 527 }, | |
| 528 | |
| 529 /** | |
| 530 * @param {!Element} element | 334 * @param {!Element} element |
| 531 * @param {?WebInspector.TargetInfo} targetInfo | 335 * @param {?WebInspector.TargetInfo} targetInfo |
| 532 */ | 336 */ |
| 533 _onClientInfo: function(element, targetInfo) | 337 _onClientInfo: function(element, targetInfo) |
| 534 { | 338 { |
| 535 if (!targetInfo) | 339 if (!targetInfo) |
| 536 return; | 340 return; |
| 537 this._clientInfoCache[targetInfo.id] = targetInfo; | 341 this._clientInfoCache.set(targetInfo.id, targetInfo); |
| 538 this._updateClientInfo(element, targetInfo); | 342 this._updateClientInfo(element, targetInfo); |
| 539 }, | 343 }, |
| 540 | 344 |
| 541 /** | 345 /** |
| 542 * @param {!Element} element | 346 * @param {!Element} element |
| 543 * @param {!WebInspector.TargetInfo} targetInfo | 347 * @param {!WebInspector.TargetInfo} targetInfo |
| 544 */ | 348 */ |
| 545 _updateClientInfo: function(element, targetInfo) | 349 _updateClientInfo: function(element, targetInfo) |
| 546 { | 350 { |
| 547 if (!(targetInfo.isWebContents() || targetInfo.isFrame())) { | 351 if (!(targetInfo.isWebContents() || targetInfo.isFrame())) { |
| 548 element.createTextChild(WebInspector.UIString("Worker: %s", targetIn fo.url)); | 352 element.createTextChild(WebInspector.UIString("Worker: %s", targetIn fo.url)); |
| 549 return; | 353 return; |
| 550 } | 354 } |
| 551 element.removeChildren(); | 355 element.removeChildren(); |
| 552 element.createTextChild(WebInspector.UIString("Tab: %s", targetInfo.url) ); | 356 element.createTextChild(targetInfo.url); |
| 553 var focusLabel = element.createChild("label", "service-worker-client-foc us"); | 357 var focusLabel = element.createChild("label", "link"); |
| 554 focusLabel.createTextChild("focus"); | 358 focusLabel.createTextChild("focus"); |
| 555 focusLabel.addEventListener("click", this._activateTarget.bind(this, tar getInfo.id), true); | 359 focusLabel.addEventListener("click", this._activateTarget.bind(this, tar getInfo.id), true); |
| 556 }, | 360 }, |
| 557 | 361 |
| 558 /** | 362 /** |
| 559 * @param {string} targetId | 363 * @param {string} targetId |
| 560 */ | 364 */ |
| 561 _activateTarget: function(targetId) | 365 _activateTarget: function(targetId) |
| 562 { | 366 { |
| 563 this._manager.activateTarget(targetId); | 367 this._manager.activateTarget(targetId); |
| 564 }, | 368 }, |
| 565 | 369 |
| 566 /** | 370 _startButtonClicked: function() |
| 567 * @param {!WebInspector.Event} event | |
| 568 */ | |
| 569 _startButtonClicked: function(event) | |
| 570 { | 371 { |
| 571 this._manager.startWorker(this._scopeURL); | 372 this._manager.startWorker(this._registration.scopeURL); |
| 373 }, | |
| 374 | |
| 375 _skipButtonClicked: function() | |
| 376 { | |
| 377 this._manager.skipWaiting(this._registration.scopeURL); | |
|
caseq
2016/05/05 01:09:21
Let's extract this into a follow-up patch along wi
pfeldman
2016/05/05 02:21:41
I did the other way around.
| |
| 572 }, | 378 }, |
| 573 | 379 |
| 574 /** | 380 /** |
| 575 * @param {string} versionId | 381 * @param {string} versionId |
| 576 * @param {!WebInspector.Event} event | |
| 577 */ | 382 */ |
| 578 _stopButtonClicked: function(versionId, event) | 383 _stopButtonClicked: function(versionId) |
| 579 { | 384 { |
| 580 this._manager.stopWorker(versionId); | 385 this._manager.stopWorker(versionId); |
| 581 }, | 386 }, |
| 582 | 387 |
| 388 _moreErrorsButtonClicked: function() | |
| 389 { | |
| 390 var newVisible = this._errorsList.classList.contains("hidden"); | |
| 391 this._moreButton.textContent = newVisible ? WebInspector.UIString("hide" ) : WebInspector.UIString("details"); | |
| 392 this._errorsList.classList.toggle("hidden", !newVisible); | |
| 393 }, | |
| 394 | |
| 395 _clearErrorsButtonClicked: function() | |
| 396 { | |
| 397 this._errorsList.removeChildren(); | |
| 398 this._registration.clearErrors(); | |
| 399 this._scheduleUpdate(); | |
| 400 if (!this._errorsList.classList.contains("hidden")) | |
| 401 this._moreErrorsButtonClicked(); | |
| 402 }, | |
| 403 | |
| 583 /** | 404 /** |
| 584 * @param {string} versionId | 405 * @param {string} versionId |
| 585 * @param {!Event} event | |
| 586 */ | 406 */ |
| 587 _inspectButtonClicked: function(versionId, event) | 407 _inspectButtonClicked: function(versionId) |
| 588 { | 408 { |
| 589 this._manager.inspectWorker(versionId); | 409 this._manager.inspectWorker(versionId); |
| 590 }, | 410 }, |
| 591 | 411 |
| 592 __proto__: WebInspector.VBox.prototype | 412 /** |
| 413 * @param {!Element} container | |
| 414 * @return {!Element} | |
| 415 */ | |
| 416 _wrapWidget: function(container) | |
| 417 { | |
| 418 var shadowRoot = WebInspector.createShadowRootWithCoreStyles(container); | |
| 419 WebInspector.appendStyle(shadowRoot, "resources/serviceWorkersView.css") ; | |
| 420 var contentElement = createElement("div"); | |
| 421 shadowRoot.appendChild(contentElement); | |
| 422 return contentElement; | |
| 423 }, | |
| 424 | |
| 425 _dispose: function() | |
| 426 { | |
| 427 this._linkifier.dispose(); | |
| 428 if (this._pendingUpdate) | |
| 429 clearTimeout(this._pendingUpdate); | |
| 430 } | |
| 593 } | 431 } |
| OLD | NEW |