lighthouse 9.5.0-dev.20220425 → 9.5.0-dev.20220426

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.
@@ -177,7 +177,7 @@ function getFlags(manualArgv, options = {}) {
177
177
  },
178
178
  'enable-error-reporting': {
179
179
  type: 'boolean',
180
- describe: 'Enables error reporting, overriding any saved preference. --no-enable-error-reporting will do the opposite. More: https://git.io/vFFTO',
180
+ describe: 'Enables error reporting, overriding any saved preference. --no-enable-error-reporting will do the opposite. More: https://github.com/GoogleChrome/lighthouse/blob/master/docs/error-reporting.md',
181
181
  },
182
182
  'gather-mode': {
183
183
  alias: 'G',
@@ -19,6 +19,8 @@ const UIStrings = {
19
19
  '[Learn more](https://web.dev/doctype/).',
20
20
  /** Explanatory message stating that the document has no doctype. */
21
21
  explanationNoDoctype: 'Document must contain a doctype',
22
+ /** Explanatory message stating that the document has wrong doctype */
23
+ explanationWrongDoctype: 'Document contains a doctype that triggers quirks-mode',
22
24
  /** Explanatory message stating that the publicId field is not empty. */
23
25
  explanationPublicId: 'Expected publicId to be an empty string',
24
26
  /** Explanatory message stating that the systemId field is not empty. */
@@ -59,6 +61,7 @@ class Doctype extends Audit {
59
61
  const doctypeName = artifacts.Doctype.name;
60
62
  const doctypePublicId = artifacts.Doctype.publicId;
61
63
  const doctypeSystemId = artifacts.Doctype.systemId;
64
+ const compatMode = artifacts.Doctype.documentCompatMode;
62
65
 
63
66
  if (doctypePublicId !== '') {
64
67
  return {
@@ -76,14 +79,23 @@ class Doctype extends Audit {
76
79
 
77
80
  /* Note that the casing of this property is normalized to be lowercase.
78
81
  see: https://html.spec.whatwg.org/#doctype-name-state */
79
- if (doctypeName === 'html') {
82
+ if (doctypeName !== 'html') {
80
83
  return {
81
- score: 1,
84
+ score: 0,
85
+ explanation: str_(UIStrings.explanationBadDoctype),
82
86
  };
83
- } else {
87
+ }
88
+
89
+ // Catch-all for any quirks-mode situations the above checks didn't get.
90
+ // https://github.com/GoogleChrome/lighthouse/issues/10030
91
+ if (compatMode === 'BackCompat') {
84
92
  return {
85
93
  score: 0,
86
- explanation: str_(UIStrings.explanationBadDoctype),
94
+ explanation: str_(UIStrings.explanationWrongDoctype),
95
+ };
96
+ } else {
97
+ return {
98
+ score: 1,
87
99
  };
88
100
  }
89
101
  }
@@ -12,7 +12,8 @@ const FRGatherer = require('../../../fraggle-rock/gather/base-gatherer.js');
12
12
  /**
13
13
  * Get and return `name`, `publicId`, `systemId` from
14
14
  * `document.doctype`
15
- * @return {{name: string, publicId: string, systemId: string} | null}
15
+ * and `compatMode` from `document` to check `quirks-mode`
16
+ * @return {{name: string, publicId: string, systemId: string, documentCompatMode: string} | null}
16
17
  */
17
18
  function getDoctype() {
18
19
  // An example of this is warnerbros.com/archive/spacejam/movie/jam.htm
@@ -20,8 +21,9 @@ function getDoctype() {
20
21
  return null;
21
22
  }
22
23
 
24
+ const documentCompatMode = document.compatMode;
23
25
  const {name, publicId, systemId} = document.doctype;
24
- return {name, publicId, systemId};
26
+ return {name, publicId, systemId, documentCompatMode};
25
27
  }
26
28
 
27
29
  class Doctype extends FRGatherer {
@@ -612,39 +612,59 @@ class TraceProcessor {
612
612
  // Find the inspected frame
613
613
  const mainFrameIds = this.findMainFrameIds(keyEvents);
614
614
 
615
- const frames = keyEvents
615
+ /** @type {Map<string, {id: string, url: string, parent?: string}>} */
616
+ const framesById = new Map();
617
+
618
+ // Begin collection of frame tree information with TracingStartedInBrowser,
619
+ // which should be present even without navigations.
620
+ const tracingStartedFrames = keyEvents
621
+ .find(e => e.name === 'TracingStartedInBrowser')?.args?.data?.frames;
622
+ if (tracingStartedFrames) {
623
+ for (const frame of tracingStartedFrames) {
624
+ framesById.set(frame.frame, {
625
+ id: frame.frame,
626
+ url: frame.url,
627
+ parent: frame.parent,
628
+ });
629
+ }
630
+ }
631
+
632
+ // Update known frames if FrameCommittedInBrowser events come in, typically
633
+ // with updated `url`, as well as pid, etc. Some traces (like timespans) may
634
+ // not have any committed frames.
635
+ keyEvents
616
636
  .filter(/** @return {evt is FrameCommittedEvent} */ evt => {
617
637
  return Boolean(
618
638
  evt.name === 'FrameCommittedInBrowser' &&
619
639
  evt.args.data?.frame &&
620
640
  evt.args.data.url
621
641
  );
622
- })
623
- .map(evt => {
624
- return {
642
+ }).forEach(evt => {
643
+ framesById.set(evt.args.data.frame, {
625
644
  id: evt.args.data.frame,
626
645
  url: evt.args.data.url,
627
646
  parent: evt.args.data.parent,
628
- };
647
+ });
629
648
  });
649
+ const frames = [...framesById.values()];
630
650
  const frameIdToRootFrameId = this.resolveRootFrames(frames);
631
651
 
632
652
  // Filter to just events matching the main frame ID, just to make sure.
633
653
  const frameEvents = keyEvents.filter(e => e.args.frame === mainFrameIds.frameId);
634
654
 
635
655
  // Filter to just events matching the main frame ID or any child frame IDs.
636
- // In practice, there should always be FrameCommittedInBrowser events to define the frame tree.
637
- // Unfortunately, many test traces do not include FrameCommittedInBrowser events due to minification.
638
- // This ensures there is always a minimal frame tree and events so those tests don't fail.
639
656
  let frameTreeEvents = [];
640
657
  if (frameIdToRootFrameId.has(mainFrameIds.frameId)) {
641
658
  frameTreeEvents = keyEvents.filter(e => {
642
659
  return e.args.frame && frameIdToRootFrameId.get(e.args.frame) === mainFrameIds.frameId;
643
660
  });
644
661
  } else {
662
+ // In practice, there should always be TracingStartedInBrowser/FrameCommittedInBrowser events to
663
+ // define the frame tree. Unfortunately, many test traces do not that frame info due to minification.
664
+ // This ensures there is always a minimal frame tree and events so those tests don't fail.
645
665
  log.warn(
646
666
  'trace-of-tab',
647
- 'frameTreeEvents may be incomplete, make sure the trace has FrameCommittedInBrowser events'
667
+ 'frameTreeEvents may be incomplete, make sure the trace has frame events'
648
668
  );
649
669
  frameIdToRootFrameId.set(mainFrameIds.frameId, mainFrameIds.frameId);
650
670
  frameTreeEvents = frameEvents;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lighthouse",
3
- "version": "9.5.0-dev.20220425",
3
+ "version": "9.5.0-dev.20220426",
4
4
  "description": "Automated auditing, performance metrics, and best practices for the web.",
5
5
  "main": "./lighthouse-core/index.js",
6
6
  "bin": {
package/readme.md CHANGED
@@ -99,7 +99,7 @@ Configuration:
99
99
  --screenEmulation Sets screen emulation parameters. See also --preset. Use --screenEmulation.disabled to disable. Otherwise set these 4 parameters individually: --screenEmulation.mobile --screenEmulation.width=360 --screenEmulation.height=640 --screenEmulation.deviceScaleFactor=2
100
100
  --emulatedUserAgent Sets useragent emulation [string]
101
101
  --max-wait-for-load The timeout (in milliseconds) to wait before the page is considered done loading and the run should continue. WARNING: Very high values can lead to large traces and instability [number]
102
- --enable-error-reporting Enables error reporting, overriding any saved preference. --no-enable-error-reporting will do the opposite. More: https://git.io/vFFTO [boolean]
102
+ --enable-error-reporting Enables error reporting, overriding any saved preference. --no-enable-error-reporting will do the opposite. More: https://github.com/GoogleChrome/lighthouse/blob/master/docs/error-reporting.md [boolean]
103
103
  --gather-mode, -G Collect artifacts from a connected browser and save to disk. (Artifacts folder path may optionally be provided). If audit-mode is not also enabled, the run will quit early.
104
104
  --audit-mode, -A Process saved artifacts from disk. (Artifacts folder path may be provided, otherwise defaults to ./latest-run/)
105
105
  --only-audits Only run the specified audits [array]
@@ -788,6 +788,9 @@
788
788
  "lighthouse-core/audits/dobetterweb/doctype.js | explanationSystemId": {
789
789
  "message": "Expected systemId to be an empty string"
790
790
  },
791
+ "lighthouse-core/audits/dobetterweb/doctype.js | explanationWrongDoctype": {
792
+ "message": "Document contains a doctype that triggers quirks-mode"
793
+ },
791
794
  "lighthouse-core/audits/dobetterweb/doctype.js | failureTitle": {
792
795
  "message": "Page lacks the HTML doctype, thus triggering quirks-mode"
793
796
  },
@@ -788,6 +788,9 @@
788
788
  "lighthouse-core/audits/dobetterweb/doctype.js | explanationSystemId": {
789
789
  "message": "Êx́p̂éĉt́êd́ ŝýŝt́êḿÎd́ t̂ó b̂é âń êḿp̂t́ŷ śt̂ŕîńĝ"
790
790
  },
791
+ "lighthouse-core/audits/dobetterweb/doctype.js | explanationWrongDoctype": {
792
+ "message": "D̂óĉúm̂én̂t́ ĉón̂t́âín̂ś â d́ôćt̂ýp̂é t̂h́ât́ t̂ŕîǵĝér̂ś q̂úîŕk̂ś-m̂ód̂é"
793
+ },
791
794
  "lighthouse-core/audits/dobetterweb/doctype.js | failureTitle": {
792
795
  "message": "P̂áĝé l̂áĉḱŝ t́ĥé ĤT́M̂Ĺ d̂óĉt́ŷṕê, t́ĥúŝ t́r̂íĝǵêŕîńĝ q́ûír̂ḱŝ-ḿôd́ê"
793
796
  },
@@ -252,6 +252,7 @@ declare module Artifacts {
252
252
  name: string;
253
253
  publicId: string;
254
254
  systemId: string;
255
+ documentCompatMode: string;
255
256
  }
256
257
 
257
258
  interface DOMStats {
@@ -961,6 +962,7 @@ export interface TraceEvent {
961
962
  documentLoaderURL?: string;
962
963
  frames?: {
963
964
  frame: string;
965
+ url: string;
964
966
  parent?: string;
965
967
  processId?: number;
966
968
  }[];