| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 * @unrestricted | 6 * @unrestricted |
| 7 */ | 7 */ |
| 8 Audits2.Audits2Panel = class extends UI.PanelWithSidebar { | 8 Audits2.Audits2Panel = class extends UI.PanelWithSidebar { |
| 9 constructor() { | 9 constructor() { |
| 10 super('audits2'); | 10 super('audits2'); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 * @return {!Element} | 135 * @return {!Element} |
| 136 */ | 136 */ |
| 137 _createStatusView(launcherUIElement) { | 137 _createStatusView(launcherUIElement) { |
| 138 var statusView = launcherUIElement.createChild('div', 'audits2-status vbox h
idden'); | 138 var statusView = launcherUIElement.createChild('div', 'audits2-status vbox h
idden'); |
| 139 this._statusIcon = statusView.createChild('div', 'icon'); | 139 this._statusIcon = statusView.createChild('div', 'icon'); |
| 140 this._statusElement = statusView.createChild('div'); | 140 this._statusElement = statusView.createChild('div'); |
| 141 this._updateStatus(Common.UIString('Loading...')); | 141 this._updateStatus(Common.UIString('Loading...')); |
| 142 return statusView; | 142 return statusView; |
| 143 } | 143 } |
| 144 | 144 |
| 145 /** |
| 146 * @return {!Promise<undefined>} |
| 147 */ |
| 148 _updateInspectedURL() { |
| 149 var mainTarget = SDK.targetManager.mainTarget(); |
| 150 var runtimeModel = mainTarget.model(SDK.RuntimeModel); |
| 151 var executionContext = runtimeModel && runtimeModel.defaultExecutionContext(
); |
| 152 this._inspectedURL = mainTarget.inspectedURL(); |
| 153 if (!executionContext) |
| 154 return Promise.resolve(); |
| 155 |
| 156 return new Promise(resolve => { |
| 157 executionContext.evaluate('window.location.href', 'audits', false, false,
true, false, false, (object, err) => { |
| 158 if (!err && object) { |
| 159 this._inspectedURL = object.value; |
| 160 object.release(); |
| 161 } |
| 162 |
| 163 resolve(); |
| 164 }); |
| 165 }); |
| 166 } |
| 167 |
| 145 _start() { | 168 _start() { |
| 146 var emulationModel = self.singleton(Emulation.DeviceModeModel); | 169 var emulationModel = self.singleton(Emulation.DeviceModeModel); |
| 147 this._emulationEnabledBefore = emulationModel.enabledSetting().get(); | 170 this._emulationEnabledBefore = emulationModel.enabledSetting().get(); |
| 148 this._emulationOutlineEnabledBefore = emulationModel.deviceOutlineSetting().
get(); | 171 this._emulationOutlineEnabledBefore = emulationModel.deviceOutlineSetting().
get(); |
| 149 emulationModel.enabledSetting().set(true); | 172 emulationModel.enabledSetting().set(true); |
| 150 emulationModel.deviceOutlineSetting().set(true); | 173 emulationModel.deviceOutlineSetting().set(true); |
| 151 emulationModel.toolbarControlsEnabledSetting().set(false); | 174 emulationModel.toolbarControlsEnabledSetting().set(false); |
| 152 | 175 |
| 153 for (var device of Emulation.EmulatedDevicesList.instance().standard()) { | 176 for (var device of Emulation.EmulatedDevicesList.instance().standard()) { |
| 154 if (device.title === 'Nexus 5X') | 177 if (device.title === 'Nexus 5X') |
| 155 emulationModel.emulate(Emulation.DeviceModeModel.Type.Device, device, de
vice.modes[0], 1); | 178 emulationModel.emulate(Emulation.DeviceModeModel.Type.Device, device, de
vice.modes[0], 1); |
| 156 } | 179 } |
| 157 this._dialog.setCloseOnEscape(false); | 180 this._dialog.setCloseOnEscape(false); |
| 158 this._inspectedURL = SDK.targetManager.mainTarget().inspectedURL(); | |
| 159 | 181 |
| 160 var categoryIDs = []; | 182 var categoryIDs = []; |
| 161 for (var preset of Audits2.Audits2Panel.Presets) { | 183 for (var preset of Audits2.Audits2Panel.Presets) { |
| 162 if (preset.setting.get()) | 184 if (preset.setting.get()) |
| 163 categoryIDs.push(preset.configID); | 185 categoryIDs.push(preset.configID); |
| 164 } | 186 } |
| 165 | 187 |
| 166 return Promise.resolve() | 188 return Promise.resolve() |
| 189 .then(_ => this._updateInspectedURL()) |
| 167 .then(_ => this._protocolService.attach()) | 190 .then(_ => this._protocolService.attach()) |
| 168 .then(_ => { | 191 .then(_ => { |
| 169 this._auditRunning = true; | 192 this._auditRunning = true; |
| 170 this._updateButton(); | 193 this._updateButton(); |
| 171 this._updateStatus(Common.UIString('Loading\u2026')); | 194 this._updateStatus(Common.UIString('Loading\u2026')); |
| 172 }) | 195 }) |
| 173 .then(_ => this._protocolService.startLighthouse(this._inspectedURL, cat
egoryIDs)) | 196 .then(_ => this._protocolService.startLighthouse(this._inspectedURL, cat
egoryIDs)) |
| 174 .then(lighthouseResult => { | 197 .then(lighthouseResult => { |
| 175 if (lighthouseResult && lighthouseResult.fatal) { | 198 if (lighthouseResult && lighthouseResult.fatal) { |
| 176 const error = new Error(lighthouseResult.message); | 199 const error = new Error(lighthouseResult.message); |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 return; | 680 return; |
| 658 | 681 |
| 659 var element = Components.DOMPresentationUtils.linkifyNodeReference(node,
undefined, detailsItem.snippet); | 682 var element = Components.DOMPresentationUtils.linkifyNodeReference(node,
undefined, detailsItem.snippet); |
| 660 origElement.title = ''; | 683 origElement.title = ''; |
| 661 origElement.textContent = ''; | 684 origElement.textContent = ''; |
| 662 origElement.appendChild(element); | 685 origElement.appendChild(element); |
| 663 }); | 686 }); |
| 664 }); | 687 }); |
| 665 } | 688 } |
| 666 }; | 689 }; |
| OLD | NEW |