lighthouse 9.5.0-dev.20220430 → 9.5.0-dev.20220503

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4219,17 +4219,19 @@ class PerformanceCategoryRenderer extends CategoryRenderer {
4219
4219
  metricsBoxesEl.appendChild(this._renderMetric(item));
4220
4220
  });
4221
4221
 
4222
- const descriptionEl = this.dom.find('.lh-category-header__description', element);
4223
- const estValuesEl = this.dom.createChildOf(descriptionEl, 'div', 'lh-metrics__disclaimer');
4224
- const disclaimerEl = this.dom.convertMarkdownLinkSnippets(strings.varianceDisclaimer);
4225
- estValuesEl.appendChild(disclaimerEl);
4226
-
4227
- // Add link to score calculator.
4228
- const calculatorLink = this.dom.createChildOf(estValuesEl, 'a', 'lh-calclink');
4229
- calculatorLink.target = '_blank';
4230
- calculatorLink.textContent = strings.calculatorLink;
4231
- this.dom.safelySetHref(calculatorLink, this._getScoringCalculatorHref(category.auditRefs));
4232
-
4222
+ // Only add the disclaimer with the score calculator link if the category was rendered with a score gauge.
4223
+ if (element.querySelector('.lh-gauge__wrapper')) {
4224
+ const descriptionEl = this.dom.find('.lh-category-header__description', element);
4225
+ const estValuesEl = this.dom.createChildOf(descriptionEl, 'div', 'lh-metrics__disclaimer');
4226
+ const disclaimerEl = this.dom.convertMarkdownLinkSnippets(strings.varianceDisclaimer);
4227
+ estValuesEl.appendChild(disclaimerEl);
4228
+
4229
+ // Add link to score calculator.
4230
+ const calculatorLink = this.dom.createChildOf(estValuesEl, 'a', 'lh-calclink');
4231
+ calculatorLink.target = '_blank';
4232
+ calculatorLink.textContent = strings.calculatorLink;
4233
+ this.dom.safelySetHref(calculatorLink, this._getScoringCalculatorHref(category.auditRefs));
4234
+ }
4233
4235
 
4234
4236
  metricsGroupEl.classList.add('lh-audit-group--metrics');
4235
4237
  element.appendChild(metricsGroupEl);
@@ -6106,4 +6108,6 @@ function renderReport(lhr, opts = {}) {
6106
6108
  return rootEl;
6107
6109
  }
6108
6110
 
6109
- export { DOM, ReportRenderer, ReportUIFeatures, renderReport };
6111
+ const swapLocale = _ => {}; const format = _ => {};
6112
+
6113
+ export { DOM, ReportRenderer, ReportUIFeatures, format, renderReport, swapLocale };
@@ -127,7 +127,7 @@ class Ma{constructor(e,a){this._document=e,this._lighthouseChannel="unknown",thi
127
127
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
128
128
  * See the License for the specific language governing permissions and
129
129
  * limitations under the License.
130
- */class on extends Fa{_renderMetric(e){const a=this.dom.createComponent("metric"),n=this.dom.find(".lh-metric",a);n.id=e.result.id;const t=de.calculateRating(e.result.score,e.result.scoreDisplayMode);n.classList.add(`lh-metric--${t}`);this.dom.find(".lh-metric__title",a).textContent=e.result.title;const i=this.dom.find(".lh-metric__value",a);i.textContent=e.result.displayValue||"";const o=this.dom.find(".lh-metric__description",a);if(o.appendChild(this.dom.convertMarkdownLinkSnippets(e.result.description)),"error"===e.result.scoreDisplayMode){o.textContent="",i.textContent="Error!";this.dom.createChildOf(o,"span").textContent=e.result.errorMessage||"Report error: no metric information"}return n}_renderOpportunity(e,a){const n=this.dom.createComponent("opportunity"),t=this.populateAuditValues(e,n);if(t.id=e.result.id,!e.result.details||"error"===e.result.scoreDisplayMode)return t;const i=e.result.details;if("opportunity"!==i.type)return t;const o=this.dom.find("span.lh-audit__display-text, div.lh-audit__display-text",t),r=i.overallSavingsMs/a*100+"%";if(this.dom.find("div.lh-sparkline__bar",t).style.width=r,o.textContent=de.i18n.formatSeconds(i.overallSavingsMs,.01),e.result.displayValue){const a=e.result.displayValue;this.dom.find("div.lh-load-opportunity__sparkline",t).title=a,o.title=a}return t}_getWastedMs(e){if(e.result.details&&"opportunity"===e.result.details.type){const a=e.result.details;if("number"!=typeof a.overallSavingsMs)throw new Error("non-opportunity details passed to _getWastedMs");return a.overallSavingsMs}return Number.MIN_VALUE}_getScoringCalculatorHref(e){const a=e.filter((e=>"metrics"===e.group)),n=e.find((e=>"first-cpu-idle"===e.id)),t=e.find((e=>"first-meaningful-paint"===e.id));n&&a.push(n),t&&a.push(t);const i=[...a.map((e=>{let a;var n;return"number"==typeof e.result.numericValue?(a="cumulative-layout-shift"===e.id?(n=e.result.numericValue,Math.round(100*n)/100):Math.round(e.result.numericValue),a=a.toString()):a="null",[e.acronym||e.id,a]}))];de.reportJson&&(i.push(["device",de.reportJson.configSettings.formFactor]),i.push(["version",de.reportJson.lighthouseVersion]));const o=new URLSearchParams(i),r=new URL("https://googlechrome.github.io/lighthouse/scorecalc/");return r.hash=o.toString(),r.href}_classifyPerformanceAudit(e){return e.group?null:e.result.details&&"opportunity"===e.result.details.type?"load-opportunity":"diagnostic"}render(e,a,n){const t=de.i18n.strings,i=this.dom.createElement("div","lh-category");i.id=e.id,i.appendChild(this.renderCategoryHeader(e,a,n));const o=e.auditRefs.filter((e=>"metrics"===e.group));if(o.length){const[n,r]=this.renderAuditGroup(a.metrics),s=this.dom.createElement("input","lh-metrics-toggle__input"),l=`lh-metrics-toggle${de.getUniqueSuffix()}`;s.setAttribute("aria-label","Toggle the display of metric descriptions"),s.type="checkbox",s.id=l,n.prepend(s);const p=this.dom.find(".lh-audit-group__header",n),u=this.dom.createChildOf(p,"label","lh-metrics-toggle__label");u.htmlFor=l;const c=this.dom.createChildOf(u,"span","lh-metrics-toggle__labeltext--show"),d=this.dom.createChildOf(u,"span","lh-metrics-toggle__labeltext--hide");c.textContent=de.i18n.strings.expandView,d.textContent=de.i18n.strings.collapseView;const m=this.dom.createElement("div","lh-metrics-container");n.insertBefore(m,r),o.forEach((e=>{m.appendChild(this._renderMetric(e))}));const h=this.dom.find(".lh-category-header__description",i),g=this.dom.createChildOf(h,"div","lh-metrics__disclaimer"),v=this.dom.convertMarkdownLinkSnippets(t.varianceDisclaimer);g.appendChild(v);const f=this.dom.createChildOf(g,"a","lh-calclink");f.target="_blank",f.textContent=t.calculatorLink,this.dom.safelySetHref(f,this._getScoringCalculatorHref(e.auditRefs)),n.classList.add("lh-audit-group--metrics"),i.appendChild(n)}const r=this.dom.createChildOf(i,"div","lh-filmstrip-container"),s=e.auditRefs.find((e=>"screenshot-thumbnails"===e.id))?.result;if(s?.details){r.id=s.id;const e=this.detailsRenderer.render(s.details);e&&r.appendChild(e)}const l=e.auditRefs.filter((e=>"load-opportunity"===this._classifyPerformanceAudit(e))).filter((e=>!de.showAsPassed(e.result))).sort(((e,a)=>this._getWastedMs(a)-this._getWastedMs(e))),p=o.filter((e=>!!e.relevantAudits));if(p.length&&this.renderMetricAuditFilter(p,i),l.length){const e=2e3,n=l.map((e=>this._getWastedMs(e))),o=Math.max(...n),r=Math.max(1e3*Math.ceil(o/1e3),e),[s,p]=this.renderAuditGroup(a["load-opportunities"]),u=this.dom.createComponent("opportunityHeader");this.dom.find(".lh-load-opportunity__col--one",u).textContent=t.opportunityResourceColumnLabel,this.dom.find(".lh-load-opportunity__col--two",u).textContent=t.opportunitySavingsColumnLabel;const c=this.dom.find(".lh-load-opportunity__header",u);s.insertBefore(c,p),l.forEach((e=>s.insertBefore(this._renderOpportunity(e,r),p))),s.classList.add("lh-audit-group--load-opportunities"),i.appendChild(s)}const u=e.auditRefs.filter((e=>"diagnostic"===this._classifyPerformanceAudit(e))).filter((e=>!de.showAsPassed(e.result))).sort(((e,a)=>("informative"===e.result.scoreDisplayMode?100:Number(e.result.score))-("informative"===a.result.scoreDisplayMode?100:Number(a.result.score))));if(u.length){const[e,n]=this.renderAuditGroup(a.diagnostics);u.forEach((a=>e.insertBefore(this.renderAudit(a),n))),e.classList.add("lh-audit-group--diagnostics"),i.appendChild(e)}const c=e.auditRefs.filter((e=>this._classifyPerformanceAudit(e)&&de.showAsPassed(e.result)));if(!c.length)return i;const d={auditRefs:c,groupDefinitions:a},m=this.renderClump("passed",d);i.appendChild(m);const h=[];if(["performance-budget","timing-budget"].forEach((a=>{const n=e.auditRefs.find((e=>e.id===a));if(n?.result.details){const e=this.detailsRenderer.render(n.result.details);e&&(e.id=a,e.classList.add("lh-details","lh-details--budget","lh-audit"),h.push(e))}})),h.length>0){const[e,n]=this.renderAuditGroup(a.budgets);h.forEach((a=>e.insertBefore(a,n))),e.classList.add("lh-audit-group--budgets"),i.appendChild(e)}return i}renderMetricAuditFilter(e,a){const n=this.dom.createElement("div","lh-metricfilter");this.dom.createChildOf(n,"span","lh-metricfilter__text").textContent=de.i18n.strings.showRelevantAudits;const t=[{acronym:"All"},...e],i=de.getUniqueSuffix();for(const e of t){const t=`metric-${e.acronym}-${i}`,o=this.dom.createChildOf(n,"input","lh-metricfilter__radio");o.type="radio",o.name=`metricsfilter-${i}`,o.id=t;const r=this.dom.createChildOf(n,"label","lh-metricfilter__label");r.htmlFor=t,r.title=e.result?.title,r.textContent=e.acronym||e.id,"All"===e.acronym&&(o.checked=!0,r.classList.add("lh-metricfilter__label--active")),a.append(n),o.addEventListener("input",(n=>{for(const e of a.querySelectorAll("label.lh-metricfilter__label"))e.classList.toggle("lh-metricfilter__label--active",e.htmlFor===t);a.classList.toggle("lh-category--filtered","All"!==e.acronym);for(const n of a.querySelectorAll("div.lh-audit"))"All"!==e.acronym?(n.hidden=!0,e.relevantAudits&&e.relevantAudits.includes(n.id)&&(n.hidden=!1)):n.hidden=!1;const i=a.querySelectorAll("div.lh-audit-group, details.lh-audit-group");for(const e of i){e.hidden=!1;const a=Array.from(e.querySelectorAll("div.lh-audit")),n=!!a.length&&a.every((e=>e.hidden));e.hidden=n}}))}}}
130
+ */class on extends Fa{_renderMetric(e){const a=this.dom.createComponent("metric"),n=this.dom.find(".lh-metric",a);n.id=e.result.id;const t=de.calculateRating(e.result.score,e.result.scoreDisplayMode);n.classList.add(`lh-metric--${t}`);this.dom.find(".lh-metric__title",a).textContent=e.result.title;const i=this.dom.find(".lh-metric__value",a);i.textContent=e.result.displayValue||"";const o=this.dom.find(".lh-metric__description",a);if(o.appendChild(this.dom.convertMarkdownLinkSnippets(e.result.description)),"error"===e.result.scoreDisplayMode){o.textContent="",i.textContent="Error!";this.dom.createChildOf(o,"span").textContent=e.result.errorMessage||"Report error: no metric information"}return n}_renderOpportunity(e,a){const n=this.dom.createComponent("opportunity"),t=this.populateAuditValues(e,n);if(t.id=e.result.id,!e.result.details||"error"===e.result.scoreDisplayMode)return t;const i=e.result.details;if("opportunity"!==i.type)return t;const o=this.dom.find("span.lh-audit__display-text, div.lh-audit__display-text",t),r=i.overallSavingsMs/a*100+"%";if(this.dom.find("div.lh-sparkline__bar",t).style.width=r,o.textContent=de.i18n.formatSeconds(i.overallSavingsMs,.01),e.result.displayValue){const a=e.result.displayValue;this.dom.find("div.lh-load-opportunity__sparkline",t).title=a,o.title=a}return t}_getWastedMs(e){if(e.result.details&&"opportunity"===e.result.details.type){const a=e.result.details;if("number"!=typeof a.overallSavingsMs)throw new Error("non-opportunity details passed to _getWastedMs");return a.overallSavingsMs}return Number.MIN_VALUE}_getScoringCalculatorHref(e){const a=e.filter((e=>"metrics"===e.group)),n=e.find((e=>"first-cpu-idle"===e.id)),t=e.find((e=>"first-meaningful-paint"===e.id));n&&a.push(n),t&&a.push(t);const i=[...a.map((e=>{let a;var n;return"number"==typeof e.result.numericValue?(a="cumulative-layout-shift"===e.id?(n=e.result.numericValue,Math.round(100*n)/100):Math.round(e.result.numericValue),a=a.toString()):a="null",[e.acronym||e.id,a]}))];de.reportJson&&(i.push(["device",de.reportJson.configSettings.formFactor]),i.push(["version",de.reportJson.lighthouseVersion]));const o=new URLSearchParams(i),r=new URL("https://googlechrome.github.io/lighthouse/scorecalc/");return r.hash=o.toString(),r.href}_classifyPerformanceAudit(e){return e.group?null:e.result.details&&"opportunity"===e.result.details.type?"load-opportunity":"diagnostic"}render(e,a,n){const t=de.i18n.strings,i=this.dom.createElement("div","lh-category");i.id=e.id,i.appendChild(this.renderCategoryHeader(e,a,n));const o=e.auditRefs.filter((e=>"metrics"===e.group));if(o.length){const[n,r]=this.renderAuditGroup(a.metrics),s=this.dom.createElement("input","lh-metrics-toggle__input"),l=`lh-metrics-toggle${de.getUniqueSuffix()}`;s.setAttribute("aria-label","Toggle the display of metric descriptions"),s.type="checkbox",s.id=l,n.prepend(s);const p=this.dom.find(".lh-audit-group__header",n),u=this.dom.createChildOf(p,"label","lh-metrics-toggle__label");u.htmlFor=l;const c=this.dom.createChildOf(u,"span","lh-metrics-toggle__labeltext--show"),d=this.dom.createChildOf(u,"span","lh-metrics-toggle__labeltext--hide");c.textContent=de.i18n.strings.expandView,d.textContent=de.i18n.strings.collapseView;const m=this.dom.createElement("div","lh-metrics-container");if(n.insertBefore(m,r),o.forEach((e=>{m.appendChild(this._renderMetric(e))})),i.querySelector(".lh-gauge__wrapper")){const a=this.dom.find(".lh-category-header__description",i),n=this.dom.createChildOf(a,"div","lh-metrics__disclaimer"),o=this.dom.convertMarkdownLinkSnippets(t.varianceDisclaimer);n.appendChild(o);const r=this.dom.createChildOf(n,"a","lh-calclink");r.target="_blank",r.textContent=t.calculatorLink,this.dom.safelySetHref(r,this._getScoringCalculatorHref(e.auditRefs))}n.classList.add("lh-audit-group--metrics"),i.appendChild(n)}const r=this.dom.createChildOf(i,"div","lh-filmstrip-container"),s=e.auditRefs.find((e=>"screenshot-thumbnails"===e.id))?.result;if(s?.details){r.id=s.id;const e=this.detailsRenderer.render(s.details);e&&r.appendChild(e)}const l=e.auditRefs.filter((e=>"load-opportunity"===this._classifyPerformanceAudit(e))).filter((e=>!de.showAsPassed(e.result))).sort(((e,a)=>this._getWastedMs(a)-this._getWastedMs(e))),p=o.filter((e=>!!e.relevantAudits));if(p.length&&this.renderMetricAuditFilter(p,i),l.length){const e=2e3,n=l.map((e=>this._getWastedMs(e))),o=Math.max(...n),r=Math.max(1e3*Math.ceil(o/1e3),e),[s,p]=this.renderAuditGroup(a["load-opportunities"]),u=this.dom.createComponent("opportunityHeader");this.dom.find(".lh-load-opportunity__col--one",u).textContent=t.opportunityResourceColumnLabel,this.dom.find(".lh-load-opportunity__col--two",u).textContent=t.opportunitySavingsColumnLabel;const c=this.dom.find(".lh-load-opportunity__header",u);s.insertBefore(c,p),l.forEach((e=>s.insertBefore(this._renderOpportunity(e,r),p))),s.classList.add("lh-audit-group--load-opportunities"),i.appendChild(s)}const u=e.auditRefs.filter((e=>"diagnostic"===this._classifyPerformanceAudit(e))).filter((e=>!de.showAsPassed(e.result))).sort(((e,a)=>("informative"===e.result.scoreDisplayMode?100:Number(e.result.score))-("informative"===a.result.scoreDisplayMode?100:Number(a.result.score))));if(u.length){const[e,n]=this.renderAuditGroup(a.diagnostics);u.forEach((a=>e.insertBefore(this.renderAudit(a),n))),e.classList.add("lh-audit-group--diagnostics"),i.appendChild(e)}const c=e.auditRefs.filter((e=>this._classifyPerformanceAudit(e)&&de.showAsPassed(e.result)));if(!c.length)return i;const d={auditRefs:c,groupDefinitions:a},m=this.renderClump("passed",d);i.appendChild(m);const h=[];if(["performance-budget","timing-budget"].forEach((a=>{const n=e.auditRefs.find((e=>e.id===a));if(n?.result.details){const e=this.detailsRenderer.render(n.result.details);e&&(e.id=a,e.classList.add("lh-details","lh-details--budget","lh-audit"),h.push(e))}})),h.length>0){const[e,n]=this.renderAuditGroup(a.budgets);h.forEach((a=>e.insertBefore(a,n))),e.classList.add("lh-audit-group--budgets"),i.appendChild(e)}return i}renderMetricAuditFilter(e,a){const n=this.dom.createElement("div","lh-metricfilter");this.dom.createChildOf(n,"span","lh-metricfilter__text").textContent=de.i18n.strings.showRelevantAudits;const t=[{acronym:"All"},...e],i=de.getUniqueSuffix();for(const e of t){const t=`metric-${e.acronym}-${i}`,o=this.dom.createChildOf(n,"input","lh-metricfilter__radio");o.type="radio",o.name=`metricsfilter-${i}`,o.id=t;const r=this.dom.createChildOf(n,"label","lh-metricfilter__label");r.htmlFor=t,r.title=e.result?.title,r.textContent=e.acronym||e.id,"All"===e.acronym&&(o.checked=!0,r.classList.add("lh-metricfilter__label--active")),a.append(n),o.addEventListener("input",(n=>{for(const e of a.querySelectorAll("label.lh-metricfilter__label"))e.classList.toggle("lh-metricfilter__label--active",e.htmlFor===t);a.classList.toggle("lh-category--filtered","All"!==e.acronym);for(const n of a.querySelectorAll("div.lh-audit"))"All"!==e.acronym?(n.hidden=!0,e.relevantAudits&&e.relevantAudits.includes(n.id)&&(n.hidden=!1)):n.hidden=!1;const i=a.querySelectorAll("div.lh-audit-group, details.lh-audit-group");for(const e of i){e.hidden=!1;const a=Array.from(e.querySelectorAll("div.lh-audit")),n=!!a.length&&a.every((e=>e.hidden));e.hidden=n}}))}}}
131
131
  /**
132
132
  * @license
133
133
  * Copyright 2018 The Lighthouse Authors. All Rights Reserved.
@@ -110,7 +110,7 @@ class s{constructor(e,t){this._document=e,this._lighthouseChannel="unknown",this
110
110
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
111
111
  * See the License for the specific language governing permissions and
112
112
  * limitations under the License.
113
- */class F extends c{_renderMetric(e){const t=this.dom.createComponent("metric"),n=this.dom.find(".lh-metric",t);n.id=e.result.id;const r=l.calculateRating(e.result.score,e.result.scoreDisplayMode);n.classList.add(`lh-metric--${r}`);this.dom.find(".lh-metric__title",t).textContent=e.result.title;const o=this.dom.find(".lh-metric__value",t);o.textContent=e.result.displayValue||"";const i=this.dom.find(".lh-metric__description",t);if(i.appendChild(this.dom.convertMarkdownLinkSnippets(e.result.description)),"error"===e.result.scoreDisplayMode){i.textContent="",o.textContent="Error!";this.dom.createChildOf(i,"span").textContent=e.result.errorMessage||"Report error: no metric information"}return n}_renderOpportunity(e,t){const n=this.dom.createComponent("opportunity"),r=this.populateAuditValues(e,n);if(r.id=e.result.id,!e.result.details||"error"===e.result.scoreDisplayMode)return r;const o=e.result.details;if("opportunity"!==o.type)return r;const i=this.dom.find("span.lh-audit__display-text, div.lh-audit__display-text",r),a=o.overallSavingsMs/t*100+"%";if(this.dom.find("div.lh-sparkline__bar",r).style.width=a,i.textContent=l.i18n.formatSeconds(o.overallSavingsMs,.01),e.result.displayValue){const t=e.result.displayValue;this.dom.find("div.lh-load-opportunity__sparkline",r).title=t,i.title=t}return r}_getWastedMs(e){if(e.result.details&&"opportunity"===e.result.details.type){const t=e.result.details;if("number"!=typeof t.overallSavingsMs)throw new Error("non-opportunity details passed to _getWastedMs");return t.overallSavingsMs}return Number.MIN_VALUE}_getScoringCalculatorHref(e){const t=e.filter((e=>"metrics"===e.group)),n=e.find((e=>"first-cpu-idle"===e.id)),r=e.find((e=>"first-meaningful-paint"===e.id));n&&t.push(n),r&&t.push(r);const o=[...t.map((e=>{let t;var n;return"number"==typeof e.result.numericValue?(t="cumulative-layout-shift"===e.id?(n=e.result.numericValue,Math.round(100*n)/100):Math.round(e.result.numericValue),t=t.toString()):t="null",[e.acronym||e.id,t]}))];l.reportJson&&(o.push(["device",l.reportJson.configSettings.formFactor]),o.push(["version",l.reportJson.lighthouseVersion]));const i=new URLSearchParams(o),a=new URL("https://googlechrome.github.io/lighthouse/scorecalc/");return a.hash=i.toString(),a.href}_classifyPerformanceAudit(e){return e.group?null:e.result.details&&"opportunity"===e.result.details.type?"load-opportunity":"diagnostic"}render(e,t,n){const r=l.i18n.strings,o=this.dom.createElement("div","lh-category");o.id=e.id,o.appendChild(this.renderCategoryHeader(e,t,n));const i=e.auditRefs.filter((e=>"metrics"===e.group));if(i.length){const[n,a]=this.renderAuditGroup(t.metrics),s=this.dom.createElement("input","lh-metrics-toggle__input"),c=`lh-metrics-toggle${l.getUniqueSuffix()}`;s.setAttribute("aria-label","Toggle the display of metric descriptions"),s.type="checkbox",s.id=c,n.prepend(s);const d=this.dom.find(".lh-audit-group__header",n),h=this.dom.createChildOf(d,"label","lh-metrics-toggle__label");h.htmlFor=c;const p=this.dom.createChildOf(h,"span","lh-metrics-toggle__labeltext--show"),u=this.dom.createChildOf(h,"span","lh-metrics-toggle__labeltext--hide");p.textContent=l.i18n.strings.expandView,u.textContent=l.i18n.strings.collapseView;const g=this.dom.createElement("div","lh-metrics-container");n.insertBefore(g,a),i.forEach((e=>{g.appendChild(this._renderMetric(e))}));const m=this.dom.find(".lh-category-header__description",o),f=this.dom.createChildOf(m,"div","lh-metrics__disclaimer"),v=this.dom.convertMarkdownLinkSnippets(r.varianceDisclaimer);f.appendChild(v);const b=this.dom.createChildOf(f,"a","lh-calclink");b.target="_blank",b.textContent=r.calculatorLink,this.dom.safelySetHref(b,this._getScoringCalculatorHref(e.auditRefs)),n.classList.add("lh-audit-group--metrics"),o.appendChild(n)}const a=this.dom.createChildOf(o,"div","lh-filmstrip-container"),s=e.auditRefs.find((e=>"screenshot-thumbnails"===e.id))?.result;if(s?.details){a.id=s.id;const e=this.detailsRenderer.render(s.details);e&&a.appendChild(e)}const c=e.auditRefs.filter((e=>"load-opportunity"===this._classifyPerformanceAudit(e))).filter((e=>!l.showAsPassed(e.result))).sort(((e,t)=>this._getWastedMs(t)-this._getWastedMs(e))),d=i.filter((e=>!!e.relevantAudits));if(d.length&&this.renderMetricAuditFilter(d,o),c.length){const e=2e3,n=c.map((e=>this._getWastedMs(e))),i=Math.max(...n),a=Math.max(1e3*Math.ceil(i/1e3),e),[l,s]=this.renderAuditGroup(t["load-opportunities"]),d=this.dom.createComponent("opportunityHeader");this.dom.find(".lh-load-opportunity__col--one",d).textContent=r.opportunityResourceColumnLabel,this.dom.find(".lh-load-opportunity__col--two",d).textContent=r.opportunitySavingsColumnLabel;const h=this.dom.find(".lh-load-opportunity__header",d);l.insertBefore(h,s),c.forEach((e=>l.insertBefore(this._renderOpportunity(e,a),s))),l.classList.add("lh-audit-group--load-opportunities"),o.appendChild(l)}const h=e.auditRefs.filter((e=>"diagnostic"===this._classifyPerformanceAudit(e))).filter((e=>!l.showAsPassed(e.result))).sort(((e,t)=>("informative"===e.result.scoreDisplayMode?100:Number(e.result.score))-("informative"===t.result.scoreDisplayMode?100:Number(t.result.score))));if(h.length){const[e,n]=this.renderAuditGroup(t.diagnostics);h.forEach((t=>e.insertBefore(this.renderAudit(t),n))),e.classList.add("lh-audit-group--diagnostics"),o.appendChild(e)}const p=e.auditRefs.filter((e=>this._classifyPerformanceAudit(e)&&l.showAsPassed(e.result)));if(!p.length)return o;const u={auditRefs:p,groupDefinitions:t},g=this.renderClump("passed",u);o.appendChild(g);const m=[];if(["performance-budget","timing-budget"].forEach((t=>{const n=e.auditRefs.find((e=>e.id===t));if(n?.result.details){const e=this.detailsRenderer.render(n.result.details);e&&(e.id=t,e.classList.add("lh-details","lh-details--budget","lh-audit"),m.push(e))}})),m.length>0){const[e,n]=this.renderAuditGroup(t.budgets);m.forEach((t=>e.insertBefore(t,n))),e.classList.add("lh-audit-group--budgets"),o.appendChild(e)}return o}renderMetricAuditFilter(e,t){const n=this.dom.createElement("div","lh-metricfilter");this.dom.createChildOf(n,"span","lh-metricfilter__text").textContent=l.i18n.strings.showRelevantAudits;const r=[{acronym:"All"},...e],o=l.getUniqueSuffix();for(const e of r){const r=`metric-${e.acronym}-${o}`,i=this.dom.createChildOf(n,"input","lh-metricfilter__radio");i.type="radio",i.name=`metricsfilter-${o}`,i.id=r;const a=this.dom.createChildOf(n,"label","lh-metricfilter__label");a.htmlFor=r,a.title=e.result?.title,a.textContent=e.acronym||e.id,"All"===e.acronym&&(i.checked=!0,a.classList.add("lh-metricfilter__label--active")),t.append(n),i.addEventListener("input",(n=>{for(const e of t.querySelectorAll("label.lh-metricfilter__label"))e.classList.toggle("lh-metricfilter__label--active",e.htmlFor===r);t.classList.toggle("lh-category--filtered","All"!==e.acronym);for(const n of t.querySelectorAll("div.lh-audit"))"All"!==e.acronym?(n.hidden=!0,e.relevantAudits&&e.relevantAudits.includes(n.id)&&(n.hidden=!1)):n.hidden=!1;const o=t.querySelectorAll("div.lh-audit-group, details.lh-audit-group");for(const e of o){e.hidden=!1;const t=Array.from(e.querySelectorAll("div.lh-audit")),n=!!t.length&&t.every((e=>e.hidden));e.hidden=n}}))}}}
113
+ */class F extends c{_renderMetric(e){const t=this.dom.createComponent("metric"),n=this.dom.find(".lh-metric",t);n.id=e.result.id;const r=l.calculateRating(e.result.score,e.result.scoreDisplayMode);n.classList.add(`lh-metric--${r}`);this.dom.find(".lh-metric__title",t).textContent=e.result.title;const o=this.dom.find(".lh-metric__value",t);o.textContent=e.result.displayValue||"";const i=this.dom.find(".lh-metric__description",t);if(i.appendChild(this.dom.convertMarkdownLinkSnippets(e.result.description)),"error"===e.result.scoreDisplayMode){i.textContent="",o.textContent="Error!";this.dom.createChildOf(i,"span").textContent=e.result.errorMessage||"Report error: no metric information"}return n}_renderOpportunity(e,t){const n=this.dom.createComponent("opportunity"),r=this.populateAuditValues(e,n);if(r.id=e.result.id,!e.result.details||"error"===e.result.scoreDisplayMode)return r;const o=e.result.details;if("opportunity"!==o.type)return r;const i=this.dom.find("span.lh-audit__display-text, div.lh-audit__display-text",r),a=o.overallSavingsMs/t*100+"%";if(this.dom.find("div.lh-sparkline__bar",r).style.width=a,i.textContent=l.i18n.formatSeconds(o.overallSavingsMs,.01),e.result.displayValue){const t=e.result.displayValue;this.dom.find("div.lh-load-opportunity__sparkline",r).title=t,i.title=t}return r}_getWastedMs(e){if(e.result.details&&"opportunity"===e.result.details.type){const t=e.result.details;if("number"!=typeof t.overallSavingsMs)throw new Error("non-opportunity details passed to _getWastedMs");return t.overallSavingsMs}return Number.MIN_VALUE}_getScoringCalculatorHref(e){const t=e.filter((e=>"metrics"===e.group)),n=e.find((e=>"first-cpu-idle"===e.id)),r=e.find((e=>"first-meaningful-paint"===e.id));n&&t.push(n),r&&t.push(r);const o=[...t.map((e=>{let t;var n;return"number"==typeof e.result.numericValue?(t="cumulative-layout-shift"===e.id?(n=e.result.numericValue,Math.round(100*n)/100):Math.round(e.result.numericValue),t=t.toString()):t="null",[e.acronym||e.id,t]}))];l.reportJson&&(o.push(["device",l.reportJson.configSettings.formFactor]),o.push(["version",l.reportJson.lighthouseVersion]));const i=new URLSearchParams(o),a=new URL("https://googlechrome.github.io/lighthouse/scorecalc/");return a.hash=i.toString(),a.href}_classifyPerformanceAudit(e){return e.group?null:e.result.details&&"opportunity"===e.result.details.type?"load-opportunity":"diagnostic"}render(e,t,n){const r=l.i18n.strings,o=this.dom.createElement("div","lh-category");o.id=e.id,o.appendChild(this.renderCategoryHeader(e,t,n));const i=e.auditRefs.filter((e=>"metrics"===e.group));if(i.length){const[n,a]=this.renderAuditGroup(t.metrics),s=this.dom.createElement("input","lh-metrics-toggle__input"),c=`lh-metrics-toggle${l.getUniqueSuffix()}`;s.setAttribute("aria-label","Toggle the display of metric descriptions"),s.type="checkbox",s.id=c,n.prepend(s);const d=this.dom.find(".lh-audit-group__header",n),h=this.dom.createChildOf(d,"label","lh-metrics-toggle__label");h.htmlFor=c;const p=this.dom.createChildOf(h,"span","lh-metrics-toggle__labeltext--show"),u=this.dom.createChildOf(h,"span","lh-metrics-toggle__labeltext--hide");p.textContent=l.i18n.strings.expandView,u.textContent=l.i18n.strings.collapseView;const g=this.dom.createElement("div","lh-metrics-container");if(n.insertBefore(g,a),i.forEach((e=>{g.appendChild(this._renderMetric(e))})),o.querySelector(".lh-gauge__wrapper")){const t=this.dom.find(".lh-category-header__description",o),n=this.dom.createChildOf(t,"div","lh-metrics__disclaimer"),i=this.dom.convertMarkdownLinkSnippets(r.varianceDisclaimer);n.appendChild(i);const a=this.dom.createChildOf(n,"a","lh-calclink");a.target="_blank",a.textContent=r.calculatorLink,this.dom.safelySetHref(a,this._getScoringCalculatorHref(e.auditRefs))}n.classList.add("lh-audit-group--metrics"),o.appendChild(n)}const a=this.dom.createChildOf(o,"div","lh-filmstrip-container"),s=e.auditRefs.find((e=>"screenshot-thumbnails"===e.id))?.result;if(s?.details){a.id=s.id;const e=this.detailsRenderer.render(s.details);e&&a.appendChild(e)}const c=e.auditRefs.filter((e=>"load-opportunity"===this._classifyPerformanceAudit(e))).filter((e=>!l.showAsPassed(e.result))).sort(((e,t)=>this._getWastedMs(t)-this._getWastedMs(e))),d=i.filter((e=>!!e.relevantAudits));if(d.length&&this.renderMetricAuditFilter(d,o),c.length){const e=2e3,n=c.map((e=>this._getWastedMs(e))),i=Math.max(...n),a=Math.max(1e3*Math.ceil(i/1e3),e),[l,s]=this.renderAuditGroup(t["load-opportunities"]),d=this.dom.createComponent("opportunityHeader");this.dom.find(".lh-load-opportunity__col--one",d).textContent=r.opportunityResourceColumnLabel,this.dom.find(".lh-load-opportunity__col--two",d).textContent=r.opportunitySavingsColumnLabel;const h=this.dom.find(".lh-load-opportunity__header",d);l.insertBefore(h,s),c.forEach((e=>l.insertBefore(this._renderOpportunity(e,a),s))),l.classList.add("lh-audit-group--load-opportunities"),o.appendChild(l)}const h=e.auditRefs.filter((e=>"diagnostic"===this._classifyPerformanceAudit(e))).filter((e=>!l.showAsPassed(e.result))).sort(((e,t)=>("informative"===e.result.scoreDisplayMode?100:Number(e.result.score))-("informative"===t.result.scoreDisplayMode?100:Number(t.result.score))));if(h.length){const[e,n]=this.renderAuditGroup(t.diagnostics);h.forEach((t=>e.insertBefore(this.renderAudit(t),n))),e.classList.add("lh-audit-group--diagnostics"),o.appendChild(e)}const p=e.auditRefs.filter((e=>this._classifyPerformanceAudit(e)&&l.showAsPassed(e.result)));if(!p.length)return o;const u={auditRefs:p,groupDefinitions:t},g=this.renderClump("passed",u);o.appendChild(g);const m=[];if(["performance-budget","timing-budget"].forEach((t=>{const n=e.auditRefs.find((e=>e.id===t));if(n?.result.details){const e=this.detailsRenderer.render(n.result.details);e&&(e.id=t,e.classList.add("lh-details","lh-details--budget","lh-audit"),m.push(e))}})),m.length>0){const[e,n]=this.renderAuditGroup(t.budgets);m.forEach((t=>e.insertBefore(t,n))),e.classList.add("lh-audit-group--budgets"),o.appendChild(e)}return o}renderMetricAuditFilter(e,t){const n=this.dom.createElement("div","lh-metricfilter");this.dom.createChildOf(n,"span","lh-metricfilter__text").textContent=l.i18n.strings.showRelevantAudits;const r=[{acronym:"All"},...e],o=l.getUniqueSuffix();for(const e of r){const r=`metric-${e.acronym}-${o}`,i=this.dom.createChildOf(n,"input","lh-metricfilter__radio");i.type="radio",i.name=`metricsfilter-${o}`,i.id=r;const a=this.dom.createChildOf(n,"label","lh-metricfilter__label");a.htmlFor=r,a.title=e.result?.title,a.textContent=e.acronym||e.id,"All"===e.acronym&&(i.checked=!0,a.classList.add("lh-metricfilter__label--active")),t.append(n),i.addEventListener("input",(n=>{for(const e of t.querySelectorAll("label.lh-metricfilter__label"))e.classList.toggle("lh-metricfilter__label--active",e.htmlFor===r);t.classList.toggle("lh-category--filtered","All"!==e.acronym);for(const n of t.querySelectorAll("div.lh-audit"))"All"!==e.acronym?(n.hidden=!0,e.relevantAudits&&e.relevantAudits.includes(n.id)&&(n.hidden=!1)):n.hidden=!1;const o=t.querySelectorAll("div.lh-audit-group, details.lh-audit-group");for(const e of o){e.hidden=!1;const t=Array.from(e.querySelectorAll("div.lh-audit")),n=!!t.length&&t.every((e=>e.hidden));e.hidden=n}}))}}}
114
114
  /**
115
115
  * @license
116
116
  * Copyright 2018 The Lighthouse Authors. All Rights Reserved.
package/jest.config.js CHANGED
@@ -6,7 +6,7 @@
6
6
  'use strict';
7
7
 
8
8
  module.exports = {
9
- setupFilesAfterEnv: ['./lighthouse-core/test/test-utils.js'],
9
+ setupFilesAfterEnv: ['./lighthouse-core/test/jest-setup/setup.js'],
10
10
  testEnvironment: 'node',
11
11
  testMatch: [
12
12
  '**/lighthouse-core/**/*-test.js',
@@ -123,10 +123,10 @@ function getFlags(manualArgv, options = {}) {
123
123
  type: 'boolean',
124
124
  describe: 'Pause after page load to wait for permission to continue the run, evaluate `continueLighthouseRun` in the console to continue.',
125
125
  },
126
- 'fraggle-rock': {
126
+ 'legacy-navigation': {
127
127
  type: 'boolean',
128
128
  default: false,
129
- describe: '[EXPERIMENTAL] Use the new Fraggle Rock navigation runner to gather results.',
129
+ describe: '[DEPRECATED] Use the legacy navigation runner to gather results. Only use this if you are using a pre-10.0 custom Lighthouse config, or if Lighthouse unexpectedly fails after updating to 10.0. Please file a bug if you need this flag for Lighthouse to work.',
130
130
  },
131
131
  'additional-trace-categories': {
132
132
  type: 'string',
@@ -225,15 +225,16 @@ async function runLighthouse(url, flags, config) {
225
225
  flags.port = launchedChrome.port;
226
226
  }
227
227
 
228
- if (flags.fraggleRock) {
229
- flags.channel = 'fraggle-rock-cli';
228
+ if (flags.legacyNavigation) {
229
+ log.warn('CLI', 'Legacy navigation CLI is deprecated');
230
+ flags.channel = 'legacy-navigation-cli';
230
231
  } else {
231
232
  flags.channel = 'cli';
232
233
  }
233
234
 
234
- const runnerResult = flags.fraggleRock ?
235
- await lighthouse(url, flags, config) :
236
- await lighthouse.legacyNavigation(url, flags, config);
235
+ const runnerResult = flags.legacyNavigation ?
236
+ await lighthouse.legacyNavigation(url, flags, config) :
237
+ await lighthouse(url, flags, config);
237
238
 
238
239
  // If in gatherMode only, there will be no runnerResult.
239
240
  if (runnerResult) {
@@ -82,8 +82,9 @@ async function internalRun(url, tmpPath, configJson, options) {
82
82
  ];
83
83
 
84
84
  if (useFraggleRock) {
85
- args.push('--fraggle-rock');
86
85
  configJson = convertToFraggleRockConfig(configJson);
86
+ } else {
87
+ args.push('--legacy-navigation');
87
88
  }
88
89
 
89
90
  // Config can be optionally provided.
@@ -15,13 +15,13 @@ const i18n = require('../../lib/i18n/i18n.js');
15
15
 
16
16
  const UIStrings = {
17
17
  /** Title of an accesibility audit that evaluates if any list item elements do not have list parent elements. This title is descriptive of the successful state and is shown to users when no user action is required. */
18
- title: 'List items (`<li>`) are contained within `<ul>` or `<ol>` parent elements',
18
+ title: 'List items (`<li>`) are contained within `<ul>`, `<ol>` or `<menu>` parent elements',
19
19
  /** Title of an accesibility audit that evaluates if any list item elements do not have list parent elements. This title is descriptive of the failing state and is shown to users when there is a failure that needs to be addressed. */
20
- failureTitle: 'List items (`<li>`) are not contained within `<ul>` ' +
21
- 'or `<ol>` parent elements.',
20
+ failureTitle: 'List items (`<li>`) are not contained within `<ul>`, ' +
21
+ '`<ol>` or `<menu>` parent elements.',
22
22
  /** Description of a Lighthouse audit that tells the user *why* they should try to pass. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
23
23
  description: 'Screen readers require list items (`<li>`) to be contained within a ' +
24
- 'parent `<ul>` or `<ol>` to be announced properly. ' +
24
+ 'parent `<ul>`, `<ol>` or `<menu>` to be announced properly. ' +
25
25
  '[Learn more](https://dequeuniversity.com/rules/axe/4.4/listitem).',
26
26
  };
27
27
 
@@ -117,6 +117,9 @@ class CriticalRequestChains {
117
117
  // Ignore if some ancestor is not a critical request.
118
118
  if (networkPath.some(r => !CriticalRequestChains.isCritical(r, mainResource))) return;
119
119
 
120
+ // Ignore non-network things (like data urls).
121
+ if (NetworkRequest.isNonNetworkRequest(node.record)) return;
122
+
120
123
  addChain(networkPath);
121
124
  }, getNextNodes);
122
125
 
@@ -96,7 +96,7 @@ class ProtocolSession {
96
96
  /** @param {LH.Puppeteer.CDPSession} session */
97
97
  const listener = session => callback(new ProtocolSession(session));
98
98
  this._callbackMap.set(callback, listener);
99
- this._session.connection().on('sessionattached', listener);
99
+ this._getConnection().on('sessionattached', listener);
100
100
  }
101
101
 
102
102
  /**
@@ -106,7 +106,7 @@ class ProtocolSession {
106
106
  removeSessionAttachedListener(callback) {
107
107
  const listener = this._callbackMap.get(callback);
108
108
  if (!listener) return;
109
- this._session.connection().off('sessionattached', listener);
109
+ this._getConnection().off('sessionattached', listener);
110
110
  }
111
111
 
112
112
  /**
@@ -171,6 +171,12 @@ class ProtocolSession {
171
171
  this._session.removeAllListeners();
172
172
  await this._session.detach();
173
173
  }
174
+
175
+ _getConnection() {
176
+ const connection = this._session.connection();
177
+ if (!connection) throw new Error('Connection has been closed.');
178
+ return connection;
179
+ }
174
180
  }
175
181
 
176
182
  module.exports = ProtocolSession;
@@ -94,7 +94,7 @@ lighthouse.generateConfig = generateConfig;
94
94
  lighthouse.getAuditList = Runner.getAuditList;
95
95
  lighthouse.traceCategories = require('./gather/driver.js').traceCategories;
96
96
  lighthouse.Audit = require('./audits/audit.js');
97
- lighthouse.Gatherer = require('./gather/gatherers/gatherer.js');
97
+ lighthouse.Gatherer = require('./fraggle-rock/gather/base-gatherer.js');
98
98
 
99
99
  // Explicit type reference (hidden by makeComputedArtifact) for d.ts export.
100
100
  // TODO(esmodules): should be a workaround for module.export and can be removed when in esm.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lighthouse",
3
- "version": "9.5.0-dev.20220430",
3
+ "version": "9.5.0-dev.20220503",
4
4
  "description": "Automated auditing, performance metrics, and best practices for the web.",
5
5
  "main": "./lighthouse-core/index.js",
6
6
  "bin": {
@@ -76,7 +76,6 @@
76
76
  "update:sample-artifacts": "node lighthouse-core/scripts/update-report-fixtures.js",
77
77
  "update:sample-json": "yarn i18n:collect-strings && node ./lighthouse-cli -A=./lighthouse-core/test/results/artifacts --config-path=./lighthouse-core/test/results/sample-config.js --output=json --output-path=./lighthouse-core/test/results/sample_v2.json && node lighthouse-core/scripts/cleanup-LHR-for-diff.js ./lighthouse-core/test/results/sample_v2.json --only-remove-timing",
78
78
  "update:flow-sample-json": "yarn i18n:collect-strings && node ./lighthouse-core/scripts/update-flow-fixtures.js",
79
- "update:snapshot-sample-json": "node ./lighthouse-core/scripts/update-snapshot-sample.js",
80
79
  "update:test-devtools": "bash lighthouse-core/test/chromium-web-tests/test-locally.sh --reset-results",
81
80
  "test-devtools": "bash lighthouse-core/test/chromium-web-tests/test-locally.sh",
82
81
  "open-devtools": "bash lighthouse-core/scripts/open-devtools.sh",
@@ -164,7 +163,7 @@
164
163
  "pako": "^2.0.3",
165
164
  "preact": "^10.5.14",
166
165
  "pretty-json-stringify": "^0.0.2",
167
- "puppeteer": "10.2.0",
166
+ "puppeteer": "13.7.0",
168
167
  "resolve": "^1.20.0",
169
168
  "rollup": "^2.52.7",
170
169
  "rollup-plugin-node-resolve": "^5.2.0",
@@ -200,7 +199,7 @@
200
199
  "open": "^8.4.0",
201
200
  "parse-cache-control": "1.0.1",
202
201
  "ps-list": "^8.0.0",
203
- "puppeteer-core": "^10.2.0",
202
+ "puppeteer-core": "^13.7.0",
204
203
  "robots-parser": "^3.0.0",
205
204
  "semver": "^5.3.0",
206
205
  "speedline-core": "^1.4.3",
@@ -15,3 +15,4 @@ export {DOM} from '../renderer/dom.js';
15
15
  export {ReportRenderer} from '../renderer/report-renderer.js';
16
16
  export {ReportUIFeatures} from '../renderer/report-ui-features.js';
17
17
  export {renderReport} from '../renderer/api.js';
18
+ export {swapLocale, format} from '../../shared/localization/i18n-module.js';
@@ -205,17 +205,19 @@ export class PerformanceCategoryRenderer extends CategoryRenderer {
205
205
  metricsBoxesEl.appendChild(this._renderMetric(item));
206
206
  });
207
207
 
208
- const descriptionEl = this.dom.find('.lh-category-header__description', element);
209
- const estValuesEl = this.dom.createChildOf(descriptionEl, 'div', 'lh-metrics__disclaimer');
210
- const disclaimerEl = this.dom.convertMarkdownLinkSnippets(strings.varianceDisclaimer);
211
- estValuesEl.appendChild(disclaimerEl);
212
-
213
- // Add link to score calculator.
214
- const calculatorLink = this.dom.createChildOf(estValuesEl, 'a', 'lh-calclink');
215
- calculatorLink.target = '_blank';
216
- calculatorLink.textContent = strings.calculatorLink;
217
- this.dom.safelySetHref(calculatorLink, this._getScoringCalculatorHref(category.auditRefs));
218
-
208
+ // Only add the disclaimer with the score calculator link if the category was rendered with a score gauge.
209
+ if (element.querySelector('.lh-gauge__wrapper')) {
210
+ const descriptionEl = this.dom.find('.lh-category-header__description', element);
211
+ const estValuesEl = this.dom.createChildOf(descriptionEl, 'div', 'lh-metrics__disclaimer');
212
+ const disclaimerEl = this.dom.convertMarkdownLinkSnippets(strings.varianceDisclaimer);
213
+ estValuesEl.appendChild(disclaimerEl);
214
+
215
+ // Add link to score calculator.
216
+ const calculatorLink = this.dom.createChildOf(estValuesEl, 'a', 'lh-calclink');
217
+ calculatorLink.target = '_blank';
218
+ calculatorLink.textContent = strings.calculatorLink;
219
+ this.dom.safelySetHref(calculatorLink, this._getScoringCalculatorHref(category.auditRefs));
220
+ }
219
221
 
220
222
  metricsGroupEl.classList.add('lh-audit-group--metrics');
221
223
  element.appendChild(metricsGroupEl);
@@ -1,107 +1,15 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`ReportRendererAxe with aXe renders without axe violations 2`] = `
3
+ exports[`ReportRendererAxe with aXe renders without axe violations 1`] = `
4
4
  Array [
5
5
  Object {
6
- "description": "Ensures every id attribute value is unique",
7
- "help": "id attribute value must be unique",
8
- "helpUrl": "https://dequeuniversity.com/rules/axe/4.4/duplicate-id?application=axeAPI",
9
6
  "id": "duplicate-id",
10
- "impact": "minor",
11
- "nodes": Array [
12
- Object {
13
- "all": Array [],
14
- "any": Array [
15
- Object {
16
- "data": "viewport",
17
- "id": "duplicate-id",
18
- "impact": "minor",
19
- "message": "Document has multiple static elements with the same id attribute: viewport",
20
- "relatedNodes": Array [
21
- Object {
22
- "html": "<div class=\\"lh-audit lh-audit--binary lh-audit--pass\\" id=\\"viewport\\">",
23
- "target": Array [
24
- "#seo > .lh-audit-group:nth-child(4) > .lh-clump--passed.lh-clump > .lh-audit--binary.lh-audit--pass.lh-audit:nth-child(2)",
25
- ],
26
- },
27
- Object {
28
- "html": "<div class=\\"lh-audit lh-audit--binary lh-audit--pass\\" id=\\"viewport\\">",
29
- "target": Array [
30
- ".lh-audit-group--pwa-optimized > .lh-audit--binary.lh-audit--pass.lh-audit:nth-child(6)",
31
- ],
32
- },
33
- ],
34
- },
35
- ],
36
- "failureSummary": "Fix any of the following:
37
- Document has multiple static elements with the same id attribute: viewport",
38
- "html": "<div class=\\"lh-audit lh-audit--binary lh-audit--pass\\" id=\\"viewport\\">",
39
- "impact": "minor",
40
- "none": Array [],
41
- "target": Array [
42
- ".lh-audit--binary.lh-audit--pass.lh-audit:nth-child(20)",
43
- ],
44
- },
45
- Object {
46
- "all": Array [],
47
- "any": Array [
48
- Object {
49
- "data": "image-alt",
50
- "id": "duplicate-id",
51
- "impact": "minor",
52
- "message": "Document has multiple static elements with the same id attribute: image-alt",
53
- "relatedNodes": Array [
54
- Object {
55
- "html": "<div class=\\"lh-audit lh-audit--binary lh-audit--fail\\" id=\\"image-alt\\">",
56
- "target": Array [
57
- ".lh-audit-group--seo-content > .lh-audit--fail.lh-audit--binary.lh-audit:nth-child(3)",
58
- ],
59
- },
60
- ],
61
- },
62
- ],
63
- "failureSummary": "Fix any of the following:
64
- Document has multiple static elements with the same id attribute: image-alt",
65
- "html": "<div class=\\"lh-audit lh-audit--binary lh-audit--fail\\" id=\\"image-alt\\">",
66
- "impact": "minor",
67
- "none": Array [],
68
- "target": Array [
69
- ".lh-audit-group--a11y-names-labels > .lh-audit--fail.lh-audit--binary.lh-audit:nth-child(2)",
70
- ],
71
- },
72
- Object {
73
- "all": Array [],
74
- "any": Array [
75
- Object {
76
- "data": "document-title",
77
- "id": "duplicate-id",
78
- "impact": "minor",
79
- "message": "Document has multiple static elements with the same id attribute: document-title",
80
- "relatedNodes": Array [
81
- Object {
82
- "html": "<div class=\\"lh-audit lh-audit--binary lh-audit--pass\\" id=\\"document-title\\">",
83
- "target": Array [
84
- "#seo > .lh-audit-group:nth-child(4) > .lh-clump--passed.lh-clump > .lh-audit--binary.lh-audit--pass.lh-audit:nth-child(3)",
85
- ],
86
- },
87
- ],
88
- },
89
- ],
90
- "failureSummary": "Fix any of the following:
7
+ "message": "Fix any of the following:
8
+ Document has multiple static elements with the same id attribute: viewport
9
+ Fix any of the following:
10
+ Document has multiple static elements with the same id attribute: image-alt
11
+ Fix any of the following:
91
12
  Document has multiple static elements with the same id attribute: document-title",
92
- "html": "<div class=\\"lh-audit lh-audit--binary lh-audit--pass\\" id=\\"document-title\\">",
93
- "impact": "minor",
94
- "none": Array [],
95
- "target": Array [
96
- ".lh-audit--binary.lh-audit--pass.lh-audit:nth-child(13)",
97
- ],
98
- },
99
- ],
100
- "tags": Array [
101
- "cat.parsing",
102
- "wcag2a",
103
- "wcag411",
104
- ],
105
13
  },
106
14
  ]
107
15
  `;
@@ -106,6 +106,17 @@ describe('PerfCategoryRenderer', () => {
106
106
  assert.strictEqual(new URL(calcLink.href).hostname, 'googlechrome.github.io');
107
107
  });
108
108
 
109
+ it('does not render disclaimer if there is no category gauge', () => {
110
+ // Timespan mode uses a category fraction instead of a gauge.
111
+ const categoryDOM = renderer.render(
112
+ category,
113
+ sampleResults.categoryGroups,
114
+ {gatherMode: 'timespan'}
115
+ );
116
+ const disclaimerEl = categoryDOM.querySelector('.lh-metrics__disclaimer');
117
+ assert.ok(!disclaimerEl);
118
+ });
119
+
109
120
  it('ignores hidden audits', () => {
110
121
  const categoryDOM = renderer.render(category, sampleResults.categoryGroups);
111
122
 
@@ -45,6 +45,8 @@ describe('ReportRendererAxe', () => {
45
45
  'heading-order': {enabled: true},
46
46
  'meta-viewport': {enabled: true},
47
47
  'aria-treeitem-name': {enabled: true},
48
+ // TODO: re-enable. https://github.com/GoogleChrome/lighthouse/issues/13918
49
+ 'color-contrast': {enabled: false},
48
50
  },
49
51
  };
50
52
 
@@ -75,21 +77,7 @@ describe('ReportRendererAxe', () => {
75
77
  message: v.nodes.map((n) => n.failureSummary).join('\n'),
76
78
  };
77
79
  });
78
- expect(axeSummary).toMatchInlineSnapshot(`
79
- Array [
80
- Object {
81
- "id": "duplicate-id",
82
- "message": "Fix any of the following:
83
- Document has multiple static elements with the same id attribute: viewport
84
- Fix any of the following:
85
- Document has multiple static elements with the same id attribute: image-alt
86
- Fix any of the following:
87
- Document has multiple static elements with the same id attribute: document-title",
88
- },
89
- ]
90
- `);
91
-
92
- expect(axeResults.violations).toMatchSnapshot();
80
+ expect(axeSummary).toMatchSnapshot();
93
81
  },
94
82
  // This test takes 10s on fast hardware, but can take longer in CI.
95
83
  // https://github.com/dequelabs/axe-core/tree/b573b1c1/doc/examples/jest_react#timeout-issues
@@ -119,7 +119,7 @@ body {
119
119
  border-width: 1px 0;
120
120
  padding: 4px;
121
121
  }
122
- button {
122
+ #reanalyze {
123
123
  background-color: hsl(216deg 100% 50%);
124
124
  border-radius: 4px;
125
125
  color: white;
@@ -133,8 +133,9 @@ button {
133
133
  </head>
134
134
  <body >
135
135
  <noscript>PSI requires JavaScript. Please enable.</noscript>
136
+ <button type=button id="translate">→ Español</button>
136
137
  <div class="page">
137
- <button type=button>Reanalyze</button>
138
+ <button type=button id="reanalyze">Reanalyze</button>
138
139
  <div class="tabset">
139
140
  <input type="radio" name="tabset" id="tab1" aria-controls="mobile" checked />
140
141
  <label for="tab1">Mobile</label>
@@ -17,7 +17,12 @@ const wait = (ms = 100) => new Promise(resolve => setTimeout(resolve, ms));
17
17
  (async function __initPsiReports__() {
18
18
  renderLHReport();
19
19
 
20
- document.querySelector('button')?.addEventListener('click', () => {
20
+ document.querySelector('button#reanalyze')?.addEventListener('click', () => {
21
+ renderLHReport();
22
+ });
23
+
24
+ document.querySelector('button#translate')?.addEventListener('click', async () => {
25
+ await swapLhrLocale('es');
21
26
  renderLHReport();
22
27
  });
23
28
  })();
@@ -82,6 +87,22 @@ async function renderLHReport() {
82
87
  }
83
88
  }
84
89
 
90
+ /**
91
+ * @param {LH.Locale} locale
92
+ */
93
+ async function swapLhrLocale(locale) {
94
+ const response = await fetch(`https://www.gstatic.com/pagespeed/insights/ui/locales/${locale}.json`);
95
+ /** @type {import('../../shared/localization/locales').LhlMessages} */
96
+ const lhlMessages = await response.json();
97
+ console.log(lhlMessages);
98
+ if (!lhlMessages) throw new Error(`could not fetch data for locale: ${locale}`);
99
+
100
+ lighthouseRenderer.format.registerLocaleData(locale, lhlMessages);
101
+ // @ts-expect-error LHR global
102
+ window.__LIGHTHOUSE_JSON__ = lighthouseRenderer.swapLocale(window.__LIGHTHOUSE_JSON__, locale)
103
+ .lhr;
104
+ }
105
+
85
106
 
86
107
  /**
87
108
  * Tweak the LHR to make the desktop and mobile reports easier to identify.
@@ -450,13 +450,13 @@
450
450
  "message": "Lists contain only `<li>` elements and script supporting elements (`<script>` and `<template>`)."
451
451
  },
452
452
  "lighthouse-core/audits/accessibility/listitem.js | description": {
453
- "message": "Screen readers require list items (`<li>`) to be contained within a parent `<ul>` or `<ol>` to be announced properly. [Learn more](https://dequeuniversity.com/rules/axe/4.4/listitem)."
453
+ "message": "Screen readers require list items (`<li>`) to be contained within a parent `<ul>`, `<ol>` or `<menu>` to be announced properly. [Learn more](https://dequeuniversity.com/rules/axe/4.4/listitem)."
454
454
  },
455
455
  "lighthouse-core/audits/accessibility/listitem.js | failureTitle": {
456
- "message": "List items (`<li>`) are not contained within `<ul>` or `<ol>` parent elements."
456
+ "message": "List items (`<li>`) are not contained within `<ul>`, `<ol>` or `<menu>` parent elements."
457
457
  },
458
458
  "lighthouse-core/audits/accessibility/listitem.js | title": {
459
- "message": "List items (`<li>`) are contained within `<ul>` or `<ol>` parent elements"
459
+ "message": "List items (`<li>`) are contained within `<ul>`, `<ol>` or `<menu>` parent elements"
460
460
  },
461
461
  "lighthouse-core/audits/accessibility/meta-refresh.js | description": {
462
462
  "message": "Users do not expect a page to refresh automatically, and doing so will move focus back to the top of the page. This may create a frustrating or confusing experience. [Learn more](https://dequeuniversity.com/rules/axe/4.4/meta-refresh)."
@@ -450,13 +450,13 @@
450
450
  "message": "L̂íŝt́ŝ ćôńt̂áîń ôńl̂ý `<li>` êĺêḿêńt̂ś âńd̂ śĉŕîṕt̂ śûṕp̂ór̂t́îńĝ él̂ém̂én̂t́ŝ (`<script>` án̂d́ `<template>`)."
451
451
  },
452
452
  "lighthouse-core/audits/accessibility/listitem.js | description": {
453
- "message": "Ŝćr̂éêń r̂éâd́êŕŝ ŕêq́ûír̂é l̂íŝt́ ît́êḿŝ (`<li>`) t́ô b́ê ćôńt̂áîńêd́ ŵít̂h́îń â ṕâŕêńt̂ `<ul>` ór̂ `<ol>` t́ô b́ê án̂ńôún̂ćêd́ p̂ŕôṕêŕl̂ý. [L̂éâŕn̂ ḿôŕê](https://dequeuniversity.com/rules/axe/4.4/listitem)."
453
+ "message": "Ŝćr̂éêń r̂éâd́êŕŝ ŕêq́ûír̂é l̂íŝt́ ît́êḿŝ (`<li>`) t́ô b́ê ćôńt̂áîńêd́ ŵít̂h́îń â ṕâŕêńt̂ `<ul>`, `<ol>` ór̂ `<menu>` t́ô b́ê án̂ńôún̂ćêd́ p̂ŕôṕêŕl̂ý. [L̂éâŕn̂ ḿôŕê](https://dequeuniversity.com/rules/axe/4.4/listitem)."
454
454
  },
455
455
  "lighthouse-core/audits/accessibility/listitem.js | failureTitle": {
456
- "message": "L̂íŝt́ ît́êḿŝ (`<li>`) ár̂é n̂ót̂ ćôńt̂áîńêd́ ŵít̂h́îń `<ul>` ôŕ `<ol>` p̂ár̂én̂t́ êĺêḿêńt̂ś."
456
+ "message": "L̂íŝt́ ît́êḿŝ (`<li>`) ár̂é n̂ót̂ ćôńt̂áîńêd́ ŵít̂h́îń `<ul>`, `<ol>` ôŕ `<menu>` p̂ár̂én̂t́ êĺêḿêńt̂ś."
457
457
  },
458
458
  "lighthouse-core/audits/accessibility/listitem.js | title": {
459
- "message": "L̂íŝt́ ît́êḿŝ (`<li>`) ár̂é ĉón̂t́âín̂éd̂ ẃît́ĥín̂ `<ul>` ór̂ `<ol>` ṕâŕêńt̂ él̂ém̂én̂t́ŝ"
459
+ "message": "L̂íŝt́ ît́êḿŝ (`<li>`) ár̂é ĉón̂t́âín̂éd̂ ẃît́ĥín̂ `<ul>`, `<ol>` ór̂ `<menu>` ṕâŕêńt̂ él̂ém̂én̂t́ŝ"
460
460
  },
461
461
  "lighthouse-core/audits/accessibility/meta-refresh.js | description": {
462
462
  "message": "Ûśêŕŝ d́ô ńôt́ êx́p̂éĉt́ â ṕâǵê t́ô ŕêf́r̂éŝh́ âút̂óm̂át̂íĉál̂ĺŷ, án̂d́ d̂óîńĝ śô ẃîĺl̂ ḿôv́ê f́ôćûś b̂áĉḱ t̂ó t̂h́ê t́ôṕ ôf́ t̂h́ê ṕâǵê. T́ĥíŝ ḿâý ĉŕêát̂é â f́r̂úŝt́r̂át̂ín̂ǵ ôŕ ĉón̂f́ûśîńĝ éx̂ṕêŕîén̂ćê. [Ĺêár̂ń m̂ór̂é](https://dequeuniversity.com/rules/axe/4.4/meta-refresh)."
@@ -149,8 +149,8 @@ export interface CliFlags extends Flags {
149
149
  quiet: boolean;
150
150
  /** A flag to print the normalized config for the given config and options, then exit. */
151
151
  printConfig: boolean;
152
- /** Use the new Fraggle Rock navigation runner to gather CLI results. */
153
- fraggleRock: boolean;
152
+ /** Use the legacy navigation runner to gather CLI results. */
153
+ legacyNavigation: boolean;
154
154
  /** Path to the file where precomputed lantern data should be read from. */
155
155
  precomputedLanternDataPath?: string;
156
156
  /** Path to the file where precomputed lantern data should be written to. */