Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 5 | Audits.StatusView = class { |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 6 | /** |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 7 | * @param {!Audits.AuditController} controller |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 8 | */ |
| 9 | constructor(controller) { |
| 10 | this._controller = controller; |
| 11 | |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 12 | this._statusView = null; |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 13 | this._statusHeader = null; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 14 | this._progressWrapper = null; |
| 15 | this._progressBar = null; |
| 16 | this._statusText = null; |
Connor Clark | 9950836 | 2019-08-20 19:52:23 +0000 | [diff] [blame] | 17 | this._cancelButton = null; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 18 | |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 19 | this._inspectedURL = ''; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 20 | this._textChangedAt = 0; |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 21 | this._fastFactsQueued = Audits.StatusView.FastFacts.slice(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 22 | this._currentPhase = null; |
| 23 | this._scheduledTextChangeTimeout = null; |
| 24 | this._scheduledFastFactTimeout = null; |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 25 | |
| 26 | this._dialog = new UI.Dialog(); |
Patrick Hulce | 8d387f1 | 2018-05-29 18:54:54 +0000 | [diff] [blame] | 27 | this._dialog.setDimmed(true); |
| 28 | this._dialog.setCloseOnEscape(false); |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 29 | this._dialog.setOutsideClickCallback(event => event.consume(true)); |
| 30 | this._render(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 31 | } |
| 32 | |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 33 | _render() { |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 34 | const dialogRoot = UI.createShadowRootWithCoreStyles(this._dialog.contentElement, 'audits/auditsDialog.css'); |
| 35 | const auditsViewElement = dialogRoot.createChild('div', 'audits-view vbox'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 36 | |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 37 | const cancelButton = UI.createTextButton(ls`Cancel`, this._cancel.bind(this)); |
| 38 | const fragment = UI.Fragment.build` |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 39 | <div class="audits-view vbox"> |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 40 | <h2 $="status-header">Auditing your web page\u2026</h2> |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 41 | <div class="audits-status vbox" $="status-view"> |
| 42 | <div class="audits-progress-wrapper" $="progress-wrapper"> |
| 43 | <div class="audits-progress-bar" $="progress-bar"></div> |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 44 | </div> |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 45 | <div class="audits-status-text" $="status-text"></div> |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 46 | </div> |
| 47 | ${cancelButton} |
| 48 | </div> |
| 49 | `; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 50 | |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 51 | auditsViewElement.appendChild(fragment.element()); |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 52 | |
| 53 | this._statusView = fragment.$('status-view'); |
| 54 | this._statusHeader = fragment.$('status-header'); |
| 55 | this._progressWrapper = fragment.$('progress-wrapper'); |
| 56 | this._progressBar = fragment.$('progress-bar'); |
| 57 | this._statusText = fragment.$('status-text'); |
Connor Clark | 9950836 | 2019-08-20 19:52:23 +0000 | [diff] [blame] | 58 | this._cancelButton = cancelButton; |
John Emau | 463280d | 2019-07-19 00:37:40 +0000 | [diff] [blame] | 59 | UI.ARIAUtils.markAsStatus(this._statusText); |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 60 | |
| 61 | this._dialog.setDefaultFocusedElement(cancelButton); |
| 62 | this._dialog.setSizeBehavior(UI.GlassPane.SizeBehavior.SetExactWidthMaxHeight); |
| 63 | this._dialog.setMaxContentSize(new UI.Size(500, 400)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 64 | } |
| 65 | |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 66 | _reset() { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 67 | this._resetProgressBarClasses(); |
| 68 | clearTimeout(this._scheduledFastFactTimeout); |
| 69 | |
| 70 | this._textChangedAt = 0; |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 71 | this._fastFactsQueued = Audits.StatusView.FastFacts.slice(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 72 | this._currentPhase = null; |
| 73 | this._scheduledTextChangeTimeout = null; |
| 74 | this._scheduledFastFactTimeout = null; |
| 75 | } |
| 76 | |
| 77 | /** |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 78 | * @param {!Element} dialogRenderElement |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 79 | */ |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 80 | show(dialogRenderElement) { |
| 81 | this._reset(); |
| 82 | this.updateStatus(ls`Loading\u2026`); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 83 | |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 84 | const parsedURL = this._inspectedURL.asParsedURL(); |
| 85 | const pageHost = parsedURL && parsedURL.host; |
| 86 | const statusHeader = pageHost ? ls`Auditing ${pageHost}` : ls`Auditing your web page`; |
Connor Clark | 9950836 | 2019-08-20 19:52:23 +0000 | [diff] [blame] | 87 | this._renderStatusHeader(statusHeader); |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 88 | this._dialog.show(dialogRenderElement); |
| 89 | } |
| 90 | |
Connor Clark | 9950836 | 2019-08-20 19:52:23 +0000 | [diff] [blame] | 91 | /** |
| 92 | * @param {string=} statusHeader |
| 93 | */ |
| 94 | _renderStatusHeader(statusHeader) { |
| 95 | this._statusHeader.textContent = `${statusHeader}\u2026`; |
| 96 | } |
| 97 | |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 98 | hide() { |
| 99 | if (this._dialog.isShowing()) |
| 100 | this._dialog.hide(); |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * @param {string=} url |
| 105 | */ |
| 106 | setInspectedURL(url = '') { |
| 107 | this._inspectedURL = url; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | /** |
| 111 | * @param {?string} message |
| 112 | */ |
| 113 | updateStatus(message) { |
| 114 | if (!message || !this._statusText) |
| 115 | return; |
| 116 | |
| 117 | if (message.startsWith('Cancel')) { |
| 118 | this._commitTextChange(Common.UIString('Cancelling\u2026')); |
| 119 | clearTimeout(this._scheduledFastFactTimeout); |
| 120 | return; |
| 121 | } |
| 122 | |
| 123 | const nextPhase = this._getPhaseForMessage(message); |
| 124 | if (!nextPhase && !this._currentPhase) { |
| 125 | this._commitTextChange(Common.UIString('Lighthouse is warming up\u2026')); |
| 126 | clearTimeout(this._scheduledFastFactTimeout); |
| 127 | } else if (nextPhase && (!this._currentPhase || this._currentPhase.order < nextPhase.order)) { |
| 128 | this._currentPhase = nextPhase; |
| 129 | this._scheduleTextChange(this._getMessageForPhase(nextPhase)); |
| 130 | this._scheduleFastFactCheck(); |
| 131 | this._resetProgressBarClasses(); |
| 132 | this._progressBar.classList.add(nextPhase.progressBarClass); |
| 133 | } |
| 134 | } |
| 135 | |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 136 | _cancel() { |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 137 | this._controller.dispatchEventToListeners(Audits.Events.RequestAuditCancel); |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 138 | } |
| 139 | |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 140 | /** |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 141 | * @param {!Audits.StatusView.StatusPhases} phase |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 142 | * @return {string} |
| 143 | */ |
| 144 | _getMessageForPhase(phase) { |
| 145 | if (phase.message) |
Mandy Chen | ef16e33 | 2019-09-08 05:02:45 +0000 | [diff] [blame^] | 146 | return phase.message; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 147 | |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 148 | const deviceType = Audits.RuntimeSettings.find(item => item.setting.name === 'audits.device_type').setting.get(); |
| 149 | const throttling = Audits.RuntimeSettings.find(item => item.setting.name === 'audits.throttling').setting.get(); |
| 150 | const match = Audits.StatusView.LoadingMessages.find(item => { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 151 | return item.deviceType === deviceType && item.throttling === throttling; |
| 152 | }); |
| 153 | |
Mandy Chen | ef16e33 | 2019-09-08 05:02:45 +0000 | [diff] [blame^] | 154 | return match ? match.message : ls`Lighthouse is loading your page`; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | /** |
| 158 | * @param {string} message |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 159 | * @return {?Audits.StatusView.StatusPhases} |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 160 | */ |
| 161 | _getPhaseForMessage(message) { |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 162 | return Audits.StatusView.StatusPhases.find(phase => message.startsWith(phase.statusMessagePrefix)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | _resetProgressBarClasses() { |
| 166 | if (!this._progressBar) |
| 167 | return; |
| 168 | |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 169 | this._progressBar.className = 'audits-progress-bar'; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | _scheduleFastFactCheck() { |
| 173 | if (!this._currentPhase || this._scheduledFastFactTimeout) |
| 174 | return; |
| 175 | |
| 176 | this._scheduledFastFactTimeout = setTimeout(() => { |
| 177 | this._updateFastFactIfNecessary(); |
| 178 | this._scheduledFastFactTimeout = null; |
| 179 | |
| 180 | this._scheduleFastFactCheck(); |
| 181 | }, 100); |
| 182 | } |
| 183 | |
| 184 | _updateFastFactIfNecessary() { |
| 185 | const now = performance.now(); |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 186 | if (now - this._textChangedAt < Audits.StatusView.fastFactRotationInterval) |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 187 | return; |
| 188 | if (!this._fastFactsQueued.length) |
| 189 | return; |
| 190 | |
| 191 | const fastFactIndex = Math.floor(Math.random() * this._fastFactsQueued.length); |
| 192 | this._scheduleTextChange(ls`\ud83d\udca1 ${this._fastFactsQueued[fastFactIndex]}`); |
| 193 | this._fastFactsQueued.splice(fastFactIndex, 1); |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * @param {string} text |
| 198 | */ |
| 199 | _commitTextChange(text) { |
| 200 | if (!this._statusText) |
| 201 | return; |
| 202 | this._textChangedAt = performance.now(); |
| 203 | this._statusText.textContent = text; |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * @param {string} text |
| 208 | */ |
| 209 | _scheduleTextChange(text) { |
| 210 | if (this._scheduledTextChangeTimeout) |
| 211 | clearTimeout(this._scheduledTextChangeTimeout); |
| 212 | |
| 213 | const msSinceLastChange = performance.now() - this._textChangedAt; |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 214 | const msToTextChange = Audits.StatusView.minimumTextVisibilityDuration - msSinceLastChange; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 215 | |
| 216 | this._scheduledTextChangeTimeout = setTimeout(() => { |
| 217 | this._commitTextChange(text); |
| 218 | }, Math.max(msToTextChange, 0)); |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * @param {!Error} err |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 223 | */ |
Patrick Hulce | a087f62 | 2018-05-18 00:37:53 +0000 | [diff] [blame] | 224 | renderBugReport(err) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 225 | console.error(err); |
| 226 | clearTimeout(this._scheduledFastFactTimeout); |
| 227 | clearTimeout(this._scheduledTextChangeTimeout); |
| 228 | this._resetProgressBarClasses(); |
| 229 | this._progressBar.classList.add('errored'); |
| 230 | |
| 231 | this._commitTextChange(''); |
Paul Irish | f265907 | 2019-03-24 19:08:52 +0000 | [diff] [blame] | 232 | this._statusText.createChild('p').createTextChild(Common.UIString('Ah, sorry! We ran into an error.')); |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 233 | if (Audits.StatusView.KnownBugPatterns.some(pattern => pattern.test(err.message))) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 234 | const message = Common.UIString( |
Lorne Mitchell | 7aa2c6c | 2019-04-03 03:50:10 +0000 | [diff] [blame] | 235 | 'Try to navigate to the URL in a fresh Chrome profile without any other tabs or extensions open and try again.'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 236 | this._statusText.createChild('p').createTextChild(message); |
| 237 | } else { |
Paul Irish | f265907 | 2019-03-24 19:08:52 +0000 | [diff] [blame] | 238 | this._renderBugReportBody(err, this._inspectedURL); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 239 | } |
| 240 | } |
| 241 | |
| 242 | /** |
Connor Clark | 9950836 | 2019-08-20 19:52:23 +0000 | [diff] [blame] | 243 | * @param {string} statusHeader |
| 244 | * @param {string} text |
| 245 | */ |
| 246 | renderText(statusHeader, text) { |
| 247 | this._renderStatusHeader(statusHeader); |
| 248 | this._commitTextChange(text); |
| 249 | } |
| 250 | |
| 251 | /** |
| 252 | * @param {boolean} show |
| 253 | */ |
| 254 | toggleCancelButton(show) { |
| 255 | this._cancelButton.style.visibility = show ? 'visible' : 'hidden'; |
| 256 | } |
| 257 | |
| 258 | /** |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 259 | * @param {!Error} err |
| 260 | * @param {string} auditURL |
| 261 | */ |
Paul Irish | f265907 | 2019-03-24 19:08:52 +0000 | [diff] [blame] | 262 | _renderBugReportBody(err, auditURL) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 263 | const issueBody = ` |
Paul Irish | f265907 | 2019-03-24 19:08:52 +0000 | [diff] [blame] | 264 | ${err.message} |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 265 | \`\`\` |
Paul Irish | f265907 | 2019-03-24 19:08:52 +0000 | [diff] [blame] | 266 | Channel: DevTools |
| 267 | Initial URL: ${auditURL} |
| 268 | Chrome Version: ${navigator.userAgent.match(/Chrome\/(\S+)/)[1]} |
| 269 | Stack Trace: ${err.stack} |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 270 | \`\`\` |
Paul Irish | f265907 | 2019-03-24 19:08:52 +0000 | [diff] [blame] | 271 | `; |
| 272 | this._statusText.createChild('p').createTextChild( |
| 273 | ls`If this issue is reproducible, please report it at the Lighthouse GitHub repo.`); |
| 274 | this._statusText.createChild('code', 'monospace').createTextChild(issueBody.trim()); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 275 | } |
| 276 | }; |
| 277 | |
| 278 | |
| 279 | /** @type {!Array.<!RegExp>} */ |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 280 | Audits.StatusView.KnownBugPatterns = [ |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 281 | /PARSING_PROBLEM/, |
| 282 | /DOCUMENT_REQUEST/, |
| 283 | /READ_FAILED/, |
| 284 | /TRACING_ALREADY_STARTED/, |
| 285 | /^You must provide a url to the runner/, |
| 286 | /^You probably have multiple tabs open/, |
| 287 | ]; |
| 288 | |
| 289 | /** @typedef {{message: string, progressBarClass: string, order: number}} */ |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 290 | Audits.StatusView.StatusPhases = [ |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 291 | { |
| 292 | id: 'loading', |
| 293 | progressBarClass: 'loading', |
| 294 | statusMessagePrefix: 'Loading page', |
| 295 | order: 10, |
| 296 | }, |
| 297 | { |
| 298 | id: 'gathering', |
| 299 | progressBarClass: 'gathering', |
Mandy Chen | ef16e33 | 2019-09-08 05:02:45 +0000 | [diff] [blame^] | 300 | message: ls`Lighthouse is gathering information about the page to compute your score.`, |
cjamcl@google.com | f2f8c09 | 2019-05-30 22:01:56 +0000 | [diff] [blame] | 301 | statusMessagePrefix: 'Gathering', |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 302 | order: 20, |
| 303 | }, |
| 304 | { |
| 305 | id: 'auditing', |
| 306 | progressBarClass: 'auditing', |
Mandy Chen | ef16e33 | 2019-09-08 05:02:45 +0000 | [diff] [blame^] | 307 | message: ls`Almost there! Lighthouse is now generating your report.`, |
cjamcl@google.com | f2f8c09 | 2019-05-30 22:01:56 +0000 | [diff] [blame] | 308 | statusMessagePrefix: 'Auditing', |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 309 | order: 30, |
| 310 | } |
| 311 | ]; |
| 312 | |
| 313 | /** @typedef {{message: string, deviceType: string, throttling: string}} */ |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 314 | Audits.StatusView.LoadingMessages = [ |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 315 | { |
| 316 | deviceType: 'mobile', |
| 317 | throttling: 'on', |
Mandy Chen | ef16e33 | 2019-09-08 05:02:45 +0000 | [diff] [blame^] | 318 | message: ls`Lighthouse is loading your page with throttling to measure performance on a mobile device on 3G.`, |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 319 | }, |
| 320 | { |
| 321 | deviceType: 'desktop', |
| 322 | throttling: 'on', |
Mandy Chen | ef16e33 | 2019-09-08 05:02:45 +0000 | [diff] [blame^] | 323 | message: ls`Lighthouse is loading your page with throttling to measure performance on a slow desktop on 3G.`, |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 324 | }, |
| 325 | { |
| 326 | deviceType: 'mobile', |
| 327 | throttling: 'off', |
Mandy Chen | ef16e33 | 2019-09-08 05:02:45 +0000 | [diff] [blame^] | 328 | message: ls`Lighthouse is loading your page with mobile emulation.`, |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 329 | }, |
| 330 | { |
| 331 | deviceType: 'desktop', |
| 332 | throttling: 'off', |
Mandy Chen | ef16e33 | 2019-09-08 05:02:45 +0000 | [diff] [blame^] | 333 | message: ls`Lighthouse is loading your page.`, |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 334 | }, |
| 335 | ]; |
| 336 | |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 337 | Audits.StatusView.FastFacts = [ |
Mandy Chen | ef16e33 | 2019-09-08 05:02:45 +0000 | [diff] [blame^] | 338 | ls`1MB takes a minimum of 5 seconds to download on a typical 3G connection [Source: WebPageTest and DevTools 3G definition].`, |
| 339 | ls`Rebuilding Pinterest pages for performance increased conversion rates by 15% [Source: WPO Stats]`, |
| 340 | ls`BBC has seen a loss of 10% of their users for every extra second of page load [Source: WPO Stats]`, |
| 341 | ls`By reducing the response size of JSON needed for displaying comments, Instagram saw increased impressions [Source: WPO Stats]`, |
| 342 | ls`Walmart saw a 1% increase in revenue for every 100ms improvement in page load [Source: WPO Stats]`, |
| 343 | ls`If a site takes >1 second to become interactive, users lose attention, and their perception of completing the page task is broken [Source: Google Developers Blog]`, |
| 344 | ls`75% of global mobile users in 2016 were on 2G or 3G [Source: GSMA Mobile]`, |
| 345 | ls`The average user device costs less than 200 USD. [Source: International Data Corporation]`, |
| 346 | ls`53% of all site visits are abandoned if page load takes more than 3 seconds [Source: Google DoubleClick blog]`, |
| 347 | ls`19 seconds is the average time a mobile web page takes to load on a 3G connection [Source: Google DoubleClick blog]`, |
| 348 | ls`14 seconds is the average time a mobile web page takes to load on a 4G connection [Source: Google DoubleClick blog]`, |
| 349 | ls`70% of mobile pages take nearly 7 seconds for the visual content above the fold to display on the screen. [Source: Think with Google]`, |
| 350 | ls`As page load time increases from one second to seven seconds, the probability of a mobile site visitor bouncing increases 113%. [Source: Think with Google]`, |
| 351 | ls`As the number of elements on a page increases from 400 to 6,000, the probability of conversion drops 95%. [Source: Think with Google]`, |
| 352 | ls`70% of mobile pages weigh over 1MB, 36% over 2MB, and 12% over 4MB. [Source: Think with Google]`, |
| 353 | ls`Lighthouse only simulates mobile performance; to measure performance on a real device, try WebPageTest.org [Source: Lighthouse team]`, |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 354 | ]; |
| 355 | |
| 356 | /** @const */ |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 357 | Audits.StatusView.fastFactRotationInterval = 6000; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 +0000 | [diff] [blame] | 358 | /** @const */ |
cjamcl@google.com | aa1532c | 2019-05-31 03:01:24 +0000 | [diff] [blame] | 359 | Audits.StatusView.minimumTextVisibilityDuration = 3000; |