Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: update network target type expectations #15916

Merged
merged 3 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions cli/test/smokehouse/test-definitions/oopif-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,32 @@ const expectations = {
'network-requests': {
details: {
items: {
// Multiple session attach handling fixed in M105
// https://chromiumdash.appspot.com/commit/f42337f1d623ec913397610ccf01b5526e9e919d
_minChromiumVersion: '105',
_includes: [
{url: 'http://localhost:10200/oopif-scripts.html'},
{url: 'http://localhost:10200/oopif-simple-page.html'},
{url: 'http://localhost:10503/oopif-simple-page.html'},
// simple-script.js is included many times
// 2 * (1 from <script>, 1 from fetch) = 4
// Note, the network records from the workers are _not_ captured! If they
// were, then we would see 8 simple-script.js
{url: 'http://localhost:10200/simple-script.js', resourceType: 'Script'},
{url: 'http://localhost:10503/simple-script.js', resourceType: 'Script'},
{url: 'http://localhost:10200/simple-script.js', resourceType: 'Fetch'},
{url: 'http://localhost:10503/simple-script.js', resourceType: 'Fetch'},
{url: 'http://localhost:10200/simple-worker.js'},
{url: 'http://localhost:10503/simple-worker.js'},
{url: 'http://localhost:10200/simple-worker.mjs'},
{url: 'http://localhost:10503/simple-worker.mjs'},
// Requests from worker targets
{url: 'http://localhost:10200/simple-script.js?esm', resourceType: 'Script'},
{url: 'http://localhost:10503/simple-script.js?esm', resourceType: 'Script'},
{url: 'http://localhost:10200/simple-script.js?importScripts', resourceType: 'Other'},
{url: 'http://localhost:10503/simple-script.js?importScripts', resourceType: 'Other'},
{url: 'http://localhost:10200/oopif-scripts.html', sessionTargetType: 'page'},
{url: 'http://localhost:10200/oopif-simple-page.html', sessionTargetType: 'page'},
{url: 'http://localhost:10503/oopif-simple-page.html', sessionTargetType: 'iframe'},

// From in-process iframe
{url: 'http://localhost:10200/simple-script.js', resourceType: 'Script', sessionTargetType: 'page'},
{url: 'http://localhost:10200/simple-script.js', resourceType: 'Fetch', sessionTargetType: 'page'},
{url: 'http://localhost:10200/simple-worker.js', sessionTargetType: 'page'},
// This target type can vary depending on if Chrome's field trial config is being used
{url: 'http://localhost:10200/simple-worker.mjs', sessionTargetType: /(page|worker)/},
// From in-process iframe -> simple-worker.js
{url: 'http://localhost:10200/simple-script.js?importScripts', resourceType: 'Other', sessionTargetType: 'worker'},
// From in-process iframe -> simple-worker.mjs
{url: 'http://localhost:10200/simple-script.js?esm', resourceType: 'Script', sessionTargetType: 'worker'},

// From OOPIF
{url: 'http://localhost:10503/simple-script.js', resourceType: 'Script', sessionTargetType: 'iframe'},
{url: 'http://localhost:10503/simple-script.js', resourceType: 'Fetch', sessionTargetType: 'iframe'},
{url: 'http://localhost:10503/simple-worker.js', sessionTargetType: 'iframe'},
// This target type can vary depending on if Chrome's field trial config is being used
{url: 'http://localhost:10503/simple-worker.mjs', sessionTargetType: /(iframe|worker)/},
// From OOPIF -> simple-worker.js
{url: 'http://localhost:10503/simple-script.js?importScripts', resourceType: 'Other', sessionTargetType: 'worker'},
// From OOPIF -> simple-worker.mjs
{url: 'http://localhost:10503/simple-script.js?esm', resourceType: 'Script', sessionTargetType: 'worker'},
],
// Ensure the above is exhaustive (except for favicon, which won't be fetched in devtools/LR).
_excludes: [
Expand Down
12 changes: 8 additions & 4 deletions core/test/scenarios/api-test-pptr.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,8 @@ describe('Individual modes API', function() {
expect(erroredAudits).toHaveLength(0);
});

// TODO: unskip https://github.com/GoogleChrome/lighthouse/issues/15654
// eslint-disable-next-line max-len
it.skip('should know target type of network requests from frames created before timespan', async () => {
it('should know target type of network requests from frames created before timespan', async () => {
const spy = jestMock.spyOn(TargetManager.prototype, '_onExecutionContextCreated');
state.server.baseDir = `${LH_ROOT}/cli/test/fixtures`;
const {page, serverBaseUrl} = state;
Expand All @@ -190,6 +189,11 @@ describe('Individual modes API', function() {
.map((r) => ({url: r.url, sessionTargetType: r.sessionTargetType}))
// @ts-expect-error
.sort((a, b) => a.url.localeCompare(b.url));

// These results will differ slightly from `yarn smoke oopif-scripts`
// The main worker requests will be assigned to the worker instead of the worker's parent
// This is because this test launches Chrome using puppeteer instead of Chrome launcher,
// and Puppeteer uses the flag `--disable-field-trial-config`
expect(networkRequests).toMatchInlineSnapshot(`
Array [
Object {
Expand All @@ -209,7 +213,7 @@ Array [
"url": "http://localhost:10200/simple-worker.js",
},
Object {
"sessionTargetType": "page",
"sessionTargetType": "worker",
"url": "http://localhost:10200/simple-worker.mjs",
},
Object {
Expand All @@ -229,7 +233,7 @@ Array [
"url": "http://localhost:10503/simple-worker.js",
},
Object {
"sessionTargetType": "iframe",
"sessionTargetType": "worker",
"url": "http://localhost:10503/simple-worker.mjs",
},
]
Expand Down
Loading