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

core(oopifs): surface oopifs in audits #7795

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class OptimizedImages extends Gatherer {
/** @type {Set<string>} */
const seenUrls = new Set();
return networkRecords.reduce((prev, record) => {
// Skip records that we've seen before, never finished, or came from OOPIFs.
if (seenUrls.has(record.url) || !record.finished || record.sessionId) {
// Skip records that we've seen before or never finished
if (seenUrls.has(record.url) || !record.finished) {
return prev;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ class ResponseCompression extends Gatherer {
const unoptimizedResponses = [];

networkRecords.forEach(record => {
// Ignore records from OOPIFs
if (record.sessionId) return;

const mimeType = record.mimeType;
const resourceType = record.resourceType || NetworkRequest.TYPES.Other;
const resourceSize = record.resourceSize;
Expand Down
2 changes: 0 additions & 2 deletions lighthouse-core/gather/gatherers/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ class Scripts extends Gatherer {
}

const scriptRecords = loadData.networkRecords
// Ignore records from OOPIFs
.filter(record => !record.sessionId)
// Only get the content of script requests
.filter(record => record.resourceType === NetworkRequest.TYPES.Script);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,19 @@ const traceData = {
content: '1234567',
finished: true,
},
// This is an OOPIF request
{
url: 'http://google.com/index.json',
url: 'http://google.com/oopif.json',
_statusCode: 200,
mimeType: 'application/json',
requestId: 27,
resourceSize: 7,
transferSize: 8,
resourceType: 'XHR',
responseHeaders: [],
content: '1234567',
content: '12345678',
finished: true,
sessionId: 'oopif', // ignore for being from oopif
sessionId: 'oopif',
},
{
url: 'http://google.com/index.json',
Expand Down Expand Up @@ -125,7 +126,7 @@ describe('Optimized responses', () => {
responseCompression = new ResponseCompression();
const driver = Object.assign({}, mockDriver, {
getRequestContent(id) {
return Promise.resolve(traceData.networkRecords[id].content);
return Promise.resolve(traceData.networkRecords.find(rec => rec.requestId === id).content);
},
});

Expand All @@ -138,7 +139,7 @@ describe('Optimized responses', () => {
it('returns only text and non encoded responses', () => {
return responseCompression.afterPass(options, createNetworkRequests(traceData))
.then(artifact => {
assert.equal(artifact.length, 2);
assert.equal(artifact.length, 3);
assert.ok(/index\.css$/.test(artifact[0].url));
assert.ok(/index\.json$/.test(artifact[1].url));
});
Expand All @@ -147,7 +148,7 @@ describe('Optimized responses', () => {
it('computes sizes', () => {
return responseCompression.afterPass(options, createNetworkRequests(traceData))
.then(artifact => {
assert.equal(artifact.length, 2);
assert.equal(artifact.length, 3);
assert.equal(artifact[0].resourceSize, 6);
assert.equal(artifact[0].gzipSize, 26);
});
Expand All @@ -157,7 +158,7 @@ describe('Optimized responses', () => {
options.driver.getRequestContent = () => Promise.reject(new Error('Failed'));
return responseCompression.afterPass(options, createNetworkRequests(traceData))
.then(artifact => {
assert.equal(artifact.length, 2);
assert.equal(artifact.length, 3);
assert.equal(artifact[0].resourceSize, 6);
assert.equal(artifact[0].gzipSize, undefined);
});
Expand Down Expand Up @@ -201,14 +202,7 @@ describe('Optimized responses', () => {
// Change into SDK.networkRequest when examples are ready
function createNetworkRequests(traceData) {
traceData.networkRecords = traceData.networkRecords.map(record => {
record.url = record.url;
record.statusCode = record._statusCode;
record.mimeType = record.mimeType;
record.resourceSize = record.resourceSize;
record.transferSize = record.transferSize;
record.responseHeaders = record.responseHeaders;
record.requestId = record.requestId;

return record;
});

Expand Down