Skip to content

Commit

Permalink
MainDocumentContent
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny committed Oct 15, 2019
1 parent 110f975 commit 4d99c78
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lighthouse-cli/test/cli/__snapshots__/index-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ Object {
"path": "iframe-elements",
},
Object {
"path": "initial-html",
"path": "main-document-content",
},
Object {
"path": "dobetterweb/appcache",
Expand Down
17 changes: 17 additions & 0 deletions lighthouse-cli/test/smokehouse/dbw-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @license Copyright 2017 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
'use strict';

/**
* Config file for running PWA smokehouse audits.
*/
module.exports = {
extends: 'lighthouse:default',
audits: [
// Test the `ignoredPatterns` audit option.
{path: 'errors-in-console', options: {ignoredPatterns: ['An ignored error']}},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const expectations = [
}, {
id: 'wordpress',
}],
InitialHtml: /^<!doctype html>.*DoBetterWeb Mega Tester.*aggressive-promise-polyfill.*<\/html>\n$/s,
MainDocumentContent: /^<!doctype html>.*DoBetterWeb Mega Tester.*aggressive-promise-polyfill.*<\/html>\n$/s,
LinkElements: [
{
rel: 'stylesheet',
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-cli/test/smokehouse/smoke-test-dfns.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const smokeTests = [{
}, {
id: 'dbw',
expectations: require('./dobetterweb/dbw-expectations.js'),
config: require('../../../lighthouse-core/config/default-config.js'),
config: require('./dbw-config.js'),
batch: 'parallel-second',
}, {
id: 'redirects',
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/config/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const defaultConfig = {
'meta-elements',
'script-elements',
'iframe-elements',
'initial-html',
'main-document-content',
'dobetterweb/appcache',
'dobetterweb/doctype',
'dobetterweb/domstats',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,20 @@ const Gatherer = require('./gatherer.js');
const NetworkAnalyzer = require('../../lib/dependency-graph/simulator/network-analyzer.js');

/**
* Collects the content of the initially-requested html document.
* Collects the content of the main html document.
*/
class InitialHtml extends Gatherer {
class MainDocumentContent extends Gatherer {
/**
* @param {LH.Gatherer.PassContext} passContext
* @param {LH.Gatherer.LoadData} loadData
* @return {Promise<LH.Artifacts['InitialHtml']>}
* @return {Promise<LH.Artifacts['MainDocumentContent']>}
*/
async afterPass(passContext, loadData) {
const mainResource = NetworkAnalyzer.findMainDocument(loadData.networkRecords, passContext.url);

const driver = passContext.driver;
const mainContent = await driver.getRequestContent(mainResource.requestId);

return mainContent;
return driver.getRequestContent(mainResource.requestId);
}
}

module.exports = InitialHtml;
module.exports = MainDocumentContent;
5 changes: 3 additions & 2 deletions lighthouse-core/test/results/artifacts/artifacts.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions types/artifacts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ declare global {
ConsoleMessages: Crdp.Log.EntryAddedEvent[];
/** All the iframe elements in the page.*/
IFrameElements: Artifacts.IFrameElement[];
/** The contents of the initial HTML document request. */
InitialHtml: string;
/** The contents of the main HTML document network resource. */
MainDocumentContent: string;
/** Information on size and loading for all the images in the page. Natural size information for `picture` and CSS images is only available if the image was one of the largest 50 images. */
ImageElements: Artifacts.ImageElement[];
/** All the link elements on the page or equivalently declared in `Link` headers. @see https://html.spec.whatwg.org/multipage/links.html */
Expand Down

0 comments on commit 4d99c78

Please sign in to comment.