| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 ' help you identify and fix common problems that affect' + | 70 ' help you identify and fix common problems that affect' + |
| 71 ' your site\'s performance, accessibility, and user experience. '); | 71 ' your site\'s performance, accessibility, and user experience. '); |
| 72 var link = text.createChild('span', 'link'); | 72 var link = text.createChild('span', 'link'); |
| 73 link.textContent = Common.UIString('Learn more'); | 73 link.textContent = Common.UIString('Learn more'); |
| 74 link.addEventListener( | 74 link.addEventListener( |
| 75 'click', () => InspectorFrontendHost.openInNewTab('https://developers.go
ogle.com/web/tools/lighthouse/')); | 75 'click', () => InspectorFrontendHost.openInNewTab('https://developers.go
ogle.com/web/tools/lighthouse/')); |
| 76 | 76 |
| 77 var newButton = UI.createTextButton( | 77 var newButton = UI.createTextButton( |
| 78 Common.UIString('Perform an audit\u2026'), this._showLauncherUI.bind(thi
s), 'material-button default'); | 78 Common.UIString('Perform an audit\u2026'), this._showLauncherUI.bind(thi
s), 'material-button default'); |
| 79 landingCenter.appendChild(newButton); | 79 landingCenter.appendChild(newButton); |
| 80 this.setDefaultFocusedElement(newButton); |
| 80 } | 81 } |
| 81 | 82 |
| 82 _showLauncherUI() { | 83 _showLauncherUI() { |
| 83 this._dialog = new UI.Dialog(); | 84 this._dialog = new UI.Dialog(); |
| 84 this._dialog.setOutsideClickCallback(event => event.consume(true)); | 85 this._dialog.setOutsideClickCallback(event => event.consume(true)); |
| 85 var root = UI.createShadowRootWithCoreStyles(this._dialog.contentElement, 'a
udits2/audits2Dialog.css'); | 86 var root = UI.createShadowRootWithCoreStyles(this._dialog.contentElement, 'a
udits2/audits2Dialog.css'); |
| 86 var auditsViewElement = root.createChild('div', 'audits2-view'); | 87 var auditsViewElement = root.createChild('div', 'audits2-view'); |
| 87 var uiElement = auditsViewElement.createChild('div'); | 88 var uiElement = auditsViewElement.createChild('div'); |
| 88 var headerElement = uiElement.createChild('header'); | 89 var headerElement = uiElement.createChild('header'); |
| 89 this._headerTitleElement = headerElement.createChild('p'); | 90 this._headerTitleElement = headerElement.createChild('p'); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 */ | 228 */ |
| 228 _updateStatus(statusMessage) { | 229 _updateStatus(statusMessage) { |
| 229 if (!this._dialog) | 230 if (!this._dialog) |
| 230 return; | 231 return; |
| 231 this._statusElement.textContent = statusMessage; | 232 this._statusElement.textContent = statusMessage; |
| 232 } | 233 } |
| 233 | 234 |
| 234 /** | 235 /** |
| 235 * @return {!Promise<undefined>} | 236 * @return {!Promise<undefined>} |
| 236 */ | 237 */ |
| 237 _stopAndReattach() { | 238 async _stopAndReattach() { |
| 238 return this._protocolService.detach().then(_ => { | 239 await this._protocolService.detach(); |
| 239 Emulation.InspectedPagePlaceholder.instance().update(true); | 240 Emulation.InspectedPagePlaceholder.instance().update(true); |
| 240 this._auditRunning = false; | 241 var resourceTreeModel = SDK.targetManager.mainTarget().model(SDK.ResourceTre
eModel); |
| 241 this._updateButton(); | 242 // reload to reset the page state |
| 242 var resourceTreeModel = SDK.targetManager.mainTarget().model(SDK.ResourceT
reeModel); | 243 await resourceTreeModel.navigate(this._inspectedURL); |
| 243 // reload to reset the page state | 244 this._auditRunning = false; |
| 244 resourceTreeModel.navigate(this._inspectedURL).then(() => this._hideDialog
()); | 245 this._updateButton(); |
| 245 }); | |
| 246 } | 246 } |
| 247 | 247 |
| 248 /** | 248 /** |
| 249 * @param {!ReportRenderer.ReportJSON} lighthouseResult | 249 * @param {!ReportRenderer.ReportJSON} lighthouseResult |
| 250 */ | 250 */ |
| 251 _buildReportUI(lighthouseResult) { | 251 _buildReportUI(lighthouseResult) { |
| 252 if (lighthouseResult === null) { | 252 if (lighthouseResult === null) { |
| 253 this._updateStatus(Common.UIString('Auditing failed.')); | 253 this._updateStatus(Common.UIString('Auditing failed.')); |
| 254 return; | 254 return; |
| 255 } | 255 } |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 return; | 719 return; |
| 720 | 720 |
| 721 var element = Components.DOMPresentationUtils.linkifyNodeReference(node,
undefined, detailsItem.snippet); | 721 var element = Components.DOMPresentationUtils.linkifyNodeReference(node,
undefined, detailsItem.snippet); |
| 722 origElement.title = ''; | 722 origElement.title = ''; |
| 723 origElement.textContent = ''; | 723 origElement.textContent = ''; |
| 724 origElement.appendChild(element); | 724 origElement.appendChild(element); |
| 725 }); | 725 }); |
| 726 }); | 726 }); |
| 727 } | 727 } |
| 728 }; | 728 }; |
| OLD | NEW |