| 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 * @typedef {{ | 6 * @typedef {{ |
| 7 * lighthouseVersion: !string, | 7 * lighthouseVersion: !string, |
| 8 * generatedTime: !string, | 8 * generatedTime: !string, |
| 9 * initialUrl: !string, | 9 * initialUrl: !string, |
| 10 * url: !string, | 10 * url: !string, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 Audits2.Audits2Panel = class extends UI.Panel { | 28 Audits2.Audits2Panel = class extends UI.Panel { |
| 29 constructor() { | 29 constructor() { |
| 30 super('audits2'); | 30 super('audits2'); |
| 31 this.setHideOnDetach(); | 31 this.setHideOnDetach(); |
| 32 this.registerRequiredCSS('audits2/audits2Panel.css'); | 32 this.registerRequiredCSS('audits2/audits2Panel.css'); |
| 33 | 33 |
| 34 this._protocolService = new Audits2.ProtocolService(); | 34 this._protocolService = new Audits2.ProtocolService(); |
| 35 this._protocolService.registerStatusCallback(msg => this._updateStatus(Commo
n.UIString(msg))); | 35 this._protocolService.registerStatusCallback(msg => this._updateStatus(Commo
n.UIString(msg))); |
| 36 | 36 |
| 37 this._pwaSetting = Common.settings.createSetting('audits2_pwa', true); | 37 this._pwaSetting = Common.settings.createSetting('audits2_pwa', true); |
| 38 this._pwaSetting.setTitle(Common.UIString('Progressive web app audits')); |
| 38 this._perfSetting = Common.settings.createSetting('audits2_perf', true); | 39 this._perfSetting = Common.settings.createSetting('audits2_perf', true); |
| 40 this._perfSetting.setTitle(Common.UIString('Performance metrics and diagnost
ics')); |
| 39 this._practicesSetting = Common.settings.createSetting('audits2_best_practic
es', true); | 41 this._practicesSetting = Common.settings.createSetting('audits2_best_practic
es', true); |
| 42 this._practicesSetting.setTitle(Common.UIString('Modern web development best
practices')); |
| 40 | 43 |
| 41 var auditsViewElement = this.contentElement.createChild('div', 'hbox audits-
view'); | 44 var auditsViewElement = this.contentElement.createChild('div', 'hbox audits-
view'); |
| 42 this._resultsView = this.contentElement.createChild('div', 'vbox results-vie
w'); | 45 this._resultsView = this.contentElement.createChild('div', 'vbox results-vie
w'); |
| 43 auditsViewElement.appendChild(createElementWithClass('div', 'audits2-logo'))
; | 46 auditsViewElement.appendChild(createElementWithClass('div', 'audits2-logo'))
; |
| 44 auditsViewElement.appendChild(this._createLauncherUI()); | 47 auditsViewElement.appendChild(this._createLauncherUI()); |
| 45 } | 48 } |
| 46 | 49 |
| 47 _reset() { | 50 _reset() { |
| 48 this.contentElement.classList.remove('show-results'); | 51 this.contentElement.classList.remove('show-results'); |
| 49 this._resultsView.removeChildren(); | 52 this._resultsView.removeChildren(); |
| 50 } | 53 } |
| 51 | 54 |
| 52 /** | |
| 53 * @param {string} name | |
| 54 * @param {!Common.Setting} setting | |
| 55 * @return {!UI.ToolbarItem} | |
| 56 */ | |
| 57 _createSettingCheckbox(name, setting) { | |
| 58 const checkboxItem = new UI.ToolbarCheckbox(name, undefined, setting); | |
| 59 return checkboxItem; | |
| 60 } | |
| 61 | |
| 62 _createLauncherUI() { | 55 _createLauncherUI() { |
| 63 var uiElement = createElement('div'); | 56 var uiElement = createElement('div'); |
| 64 var headerElement = uiElement.createChild('header'); | 57 var headerElement = uiElement.createChild('header'); |
| 65 headerElement.createChild('p').textContent = Common.UIString( | 58 headerElement.createChild('p').textContent = Common.UIString( |
| 66 'Audits will analyze the page against modern development best practices
and collect useful performance metrics and diagnostics. Select audits to collect
:'); | 59 'Audits will analyze the page against modern development best practices
and collect useful performance metrics and diagnostics. Select audits to collect
:'); |
| 67 uiElement.appendChild(headerElement); | 60 uiElement.appendChild(headerElement); |
| 68 | 61 |
| 69 var auditSelectorForm = uiElement.createChild('form', 'audits2-form'); | 62 var auditSelectorForm = uiElement.createChild('form', 'audits2-form'); |
| 70 | 63 |
| 71 var perfCheckbox = | 64 var perfCheckbox = new UI.ToolbarSettingCheckbox(this._perfSetting); |
| 72 this._createSettingCheckbox(Common.UIString('Performance metrics and dia
gnostics'), this._perfSetting); | 65 var pwaCheckbox = new UI.ToolbarSettingCheckbox(this._pwaSetting); |
| 73 var pwaCheckbox = this._createSettingCheckbox(Common.UIString('Progressive w
eb app audits'), this._pwaSetting); | 66 var practicesCheckbox = new UI.ToolbarSettingCheckbox(this._practicesSetting
); |
| 74 var practicesCheckbox = | |
| 75 this._createSettingCheckbox(Common.UIString('Modern web development best
practices'), this._practicesSetting); | |
| 76 [perfCheckbox, practicesCheckbox, pwaCheckbox].forEach(checkbox => auditSele
ctorForm.appendChild(checkbox.element)); | 67 [perfCheckbox, practicesCheckbox, pwaCheckbox].forEach(checkbox => auditSele
ctorForm.appendChild(checkbox.element)); |
| 77 | 68 |
| 78 this._startButton = UI.createTextButton( | 69 this._startButton = UI.createTextButton( |
| 79 Common.UIString('Audit this page'), this._startButtonClicked.bind(this),
'run-audit audit-btn'); | 70 Common.UIString('Audit this page'), this._startButtonClicked.bind(this),
'run-audit audit-btn'); |
| 80 auditSelectorForm.appendChild(this._startButton); | 71 auditSelectorForm.appendChild(this._startButton); |
| 81 | 72 |
| 82 this._statusView = this._createStatusView(); | 73 this._statusView = this._createStatusView(); |
| 83 uiElement.appendChild(this._statusView); | 74 uiElement.appendChild(this._statusView); |
| 84 return uiElement; | 75 return uiElement; |
| 85 } | 76 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 * @param {!Object=} params | 268 * @param {!Object=} params |
| 278 * @return {!Promise<!Audits2.WorkerResult|undefined>} | 269 * @return {!Promise<!Audits2.WorkerResult|undefined>} |
| 279 */ | 270 */ |
| 280 _send(method, params) { | 271 _send(method, params) { |
| 281 if (!this._backendPromise) | 272 if (!this._backendPromise) |
| 282 this._initWorker(); | 273 this._initWorker(); |
| 283 | 274 |
| 284 return this._backendPromise.then(_ => this._backend.send(method, params)); | 275 return this._backendPromise.then(_ => this._backend.send(method, params)); |
| 285 } | 276 } |
| 286 }; | 277 }; |
| OLD | NEW |