Skip to content

Commit

Permalink
Revert "core(fr): use frame url in gather context (GoogleChrome#13699)"
Browse files Browse the repository at this point in the history
This reverts commit 74bf436.
  • Loading branch information
Robert98MG authored Feb 26, 2022
1 parent 74bf436 commit 847fc79
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 75 deletions.
23 changes: 0 additions & 23 deletions lighthouse-cli/test/fixtures/redirects-self.html

This file was deleted.

2 changes: 0 additions & 2 deletions lighthouse-cli/test/smokehouse/core-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import redirectsHistoryPushState from './test-definitions/redirects-history-push
import redirectsMultipleServer from './test-definitions/redirects-multiple-server.js';
import redirectsSingleClient from './test-definitions/redirects-single-client.js';
import redirectsSingleServer from './test-definitions/redirects-single-server.js';
import redirectsSelf from './test-definitions/redirects-self.js';
import screenshot from './test-definitions/screenshot.js';
import seoFailing from './test-definitions/seo-failing.js';
import seoPassing from './test-definitions/seo-passing.js';
Expand Down Expand Up @@ -112,7 +111,6 @@ const smokeTests = [
redirectsMultipleServer,
redirectsSingleClient,
redirectsSingleServer,
redirectsSelf,
screenshot,
seoFailing,
seoPassing,
Expand Down
30 changes: 0 additions & 30 deletions lighthouse-cli/test/smokehouse/test-definitions/redirects-self.js

This file was deleted.

2 changes: 0 additions & 2 deletions lighthouse-core/fraggle-rock/gather/navigation-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ async function _computeNavigationResult(
async function _navigation(navigationContext) {
const artifactState = getEmptyArtifactState();
const phaseState = {
url: await navigationContext.driver.url(),
gatherMode: /** @type {const} */ ('navigation'),
driver: navigationContext.driver,
computedCache: navigationContext.computedCache,
Expand All @@ -224,7 +223,6 @@ async function _navigation(navigationContext) {
await collectPhaseArtifacts({phase: 'startInstrumentation', ...phaseState});
await collectPhaseArtifacts({phase: 'startSensitiveInstrumentation', ...phaseState});
const navigateResult = await _navigate(navigationContext);
phaseState.url = navigateResult.finalUrl;
await collectPhaseArtifacts({phase: 'stopSensitiveInstrumentation', ...phaseState});
await collectPhaseArtifacts({phase: 'stopInstrumentation', ...phaseState});
await _cleanupNavigation(navigationContext);
Expand Down
4 changes: 1 addition & 3 deletions lighthouse-core/fraggle-rock/gather/runner-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* @property {LH.Gatherer.GatherMode} gatherMode
* @property {Map<string, LH.ArbitraryEqualityMap>} computedCache
* @property {LH.Config.Settings} settings
* @property {string} url
*/

/** @typedef {Record<string, Promise<any>>} IntermediateArtifacts */
Expand Down Expand Up @@ -75,7 +74,6 @@ async function collectPhaseArtifacts(options) {
gatherMode,
computedCache,
settings,
url,
} = options;
const priorPhase = phaseToPriorPhase[phase];
const priorPhaseArtifacts = (priorPhase && artifactState[priorPhase]) || {};
Expand All @@ -92,7 +90,7 @@ async function collectPhaseArtifacts(options) {
: /** @type {Dependencies} */ ({});

return gatherer[phase]({
url,
url: await driver.url(),
gatherMode,
driver,
baseArtifacts,
Expand Down
3 changes: 1 addition & 2 deletions lighthouse-core/fraggle-rock/gather/snapshot-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function snapshot(options) {

/** @type {Map<string, LH.ArbitraryEqualityMap>} */
const computedCache = new Map();
const url = await driver.url();
const url = await options.page.url();

const runnerOptions = {config, computedCache};
const artifacts = await Runner.gather(
Expand All @@ -39,7 +39,6 @@ async function snapshot(options) {
const artifactDefinitions = config.artifacts || [];
const artifactState = getEmptyArtifactState();
await collectPhaseArtifacts({
url,
phase: 'getArtifact',
gatherMode: 'snapshot',
driver,
Expand Down
7 changes: 2 additions & 5 deletions lighthouse-core/fraggle-rock/gather/timespan-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ async function startTimespan(options) {
/** @type {Map<string, LH.ArbitraryEqualityMap>} */
const computedCache = new Map();
const artifactDefinitions = config.artifacts || [];
const requestedUrl = await driver.url();
const requestedUrl = await options.page.url();
const baseArtifacts = await getBaseArtifacts(config, driver, {gatherMode: 'timespan'});
const artifactState = getEmptyArtifactState();
/** @type {Omit<import('./runner-helpers.js').CollectPhaseArtifactOptions, 'phase'>} */
const phaseOptions = {
url: requestedUrl,
driver,
artifactDefinitions,
artifactState,
Expand All @@ -53,9 +52,7 @@ async function startTimespan(options) {

return {
async endTimespan() {
const finalUrl = await driver.url();
phaseOptions.url = finalUrl;

const finalUrl = await options.page.url();
const runnerOptions = {config, computedCache};
const artifacts = await Runner.gather(
async () => {
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/test/fraggle-rock/gather/mock-driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function createMockDriver() {
_page: page,
_executionContext: context,
_session: session,
url: jest.fn(() => page.url()),
url: () => page.url(),
defaultSession: session,
connect: jest.fn(),
disconnect: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ describe('collectPhaseArtifacts', () => {
it(`should run the ${phase} phase of gatherers in ${gatherMode} mode`, async () => {
const {artifactDefinitions, gatherers} = createGathererSet();
await helpers.collectPhaseArtifacts({
url: 'https://example.com',
driver,
artifactDefinitions,
artifactState,
Expand All @@ -157,7 +156,6 @@ describe('collectPhaseArtifacts', () => {
it('should gather the artifacts', async () => {
const {artifactDefinitions} = createGathererSet();
await helpers.collectPhaseArtifacts({
url: 'https://example.com',
driver,
artifactDefinitions,
artifactState,
Expand Down Expand Up @@ -190,7 +188,6 @@ describe('collectPhaseArtifacts', () => {
];

await helpers.collectPhaseArtifacts({
url: 'https://example.com',
driver,
artifactDefinitions,
artifactState,
Expand Down Expand Up @@ -224,7 +221,6 @@ describe('collectPhaseArtifacts', () => {

const {artifactDefinitions, gatherers} = createGathererSet();
await helpers.collectPhaseArtifacts({
url: 'https://example.com',
driver,
artifactDefinitions,
artifactState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Snapshot Runner', () => {
});

it('should collect base artifacts', async () => {
mockDriver.url.mockResolvedValue('https://lighthouse.example.com/');
mockPage.url.mockResolvedValue('https://lighthouse.example.com/');

await snapshot({page, config});
const artifacts = await mockRunner.gather.mock.calls[0][0]();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ describe('Timespan Runner', () => {
});

it('should collect base artifacts', async () => {
mockDriver.url.mockResolvedValue('https://start.example.com/');
mockPage.url.mockResolvedValue('https://start.example.com/');

const timespan = await startTimespan({page, config});

mockDriver.url.mockResolvedValue('https://end.example.com/');
mockPage.url.mockResolvedValue('https://end.example.com/');

await timespan.endTimespan();
const artifacts = await mockRunner.gather.mock.calls[0][0]();
Expand Down

0 comments on commit 847fc79

Please sign in to comment.