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(resource-summary): ignore /favicon.ico #10190

Merged
merged 3 commits into from
Jan 13, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ module.exports = [
audits: {
'resource-summary': {
score: null,
displayValue: '11 requests • 164 KB',
displayValue: '10 requests • 164 KB',
details: {
items: [
{resourceType: 'total', requestCount: 11, size: '168000±1000'},
{resourceType: 'total', requestCount: 10, size: '168000±1000'},
{resourceType: 'font', requestCount: 2, size: '80000±1000'},
{resourceType: 'script', requestCount: 3, size: '55000±1000'},
{resourceType: 'image', requestCount: 2, size: '28000±1000'},
{resourceType: 'document', requestCount: 1, size: '2200±100'},
{resourceType: 'other', requestCount: 2, size: '1300±50'},
{resourceType: 'other', requestCount: 1, size: '1000±50'},
{resourceType: 'stylesheet', requestCount: 1, size: '450±100'},
{resourceType: 'media', requestCount: 0, size: 0},
{resourceType: 'third-party', requestCount: 0, size: 0},
Expand All @@ -95,7 +95,7 @@ module.exports = [
items: [
{
resourceType: 'total',
countOverBudget: '3 requests',
countOverBudget: '2 requests',
sizeOverBudget: '65000±1000',
},
{
Expand Down Expand Up @@ -130,7 +130,7 @@ module.exports = [
},
{
resourceType: 'other',
countOverBudget: '1 request',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we change other budget to 0 to preserve this result? IMO we already exercise the different possible permutations enough but we thought we needed to set an other budget initially so... :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i considered that, but what a strange budget ...

countOverBudget: undefined,
sizeOverBudget: undefined,
},
{
Expand Down
6 changes: 6 additions & 0 deletions lighthouse-core/computed/resource-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ class ResourceSummary {

for (const record of networkRecords) {
const type = this.determineResourceType(record);
if (type === 'other' && record.url.endsWith('/favicon.ico')) {
// Headless Chrome does not request /favicon.ico, so don't consider this request.
// Makes resource summary consistent across LR / other channels.
continue;
}

resourceSummary[type].count++;
resourceSummary[type].size += record.transferSize;

Expand Down
11 changes: 11 additions & 0 deletions lighthouse-core/test/computed/resource-summary-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ describe('Resource summary computed', () => {
assert.equal(result.other.size, 50);
});

it('ignores /favicon.ico', async () => {
artifacts = mockArtifacts([
{url: 'http://example.com/file.html', resourceType: 'Document', transferSize: 30},
{url: 'http://example.com/favicon.ico', resourceType: 'Other', transferSize: 10},
]);
const result = await ComputedResourceSummary.request(artifacts, context);

assert.equal(result.total.count, 1);
assert.equal(result.total.size, 30);
});

describe('determining third-party resources', () => {
it('with a third-party resource', async () => {
artifacts = mockArtifacts([
Expand Down
30 changes: 15 additions & 15 deletions lighthouse-core/test/results/sample_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -1357,17 +1357,17 @@
{
"resourceType": "total",
"label": "Total",
"requestCount": 18,
"size": 160738,
"countOverBudget": "8 requests",
"sizeOverBudget": 58338
"requestCount": 17,
"size": 160517,
"countOverBudget": "7 requests",
"sizeOverBudget": 58117
},
{
"resourceType": "other",
"label": "Other",
"requestCount": 2,
"size": 12861,
"sizeOverBudget": 7741
"requestCount": 1,
"size": 12640,
"sizeOverBudget": 7520
},
{
"resourceType": "third-party",
Expand Down Expand Up @@ -1419,7 +1419,7 @@
"description": "To set budgets for the quantity and size of page resources, add a budget.json file. [Learn more](https://developers.google.com/web/tools/lighthouse/audits/budgets).",
"score": null,
"scoreDisplayMode": "informative",
"displayValue": "18 requests • 157 KB",
"displayValue": "17 requests • 157 KB",
"details": {
"type": "table",
"headings": [
Expand All @@ -1443,8 +1443,8 @@
{
"resourceType": "total",
"label": "Total",
"requestCount": 18,
"size": 160738
"requestCount": 17,
"size": 160517
},
{
"resourceType": "script",
Expand All @@ -1467,8 +1467,8 @@
{
"resourceType": "other",
"label": "Other",
"requestCount": 2,
"size": 12861
"requestCount": 1,
"size": 12640
},
{
"resourceType": "stylesheet",
Expand Down Expand Up @@ -5761,7 +5761,7 @@
},
{
"values": {
"count": 8
"count": 7
},
"path": "audits[performance-budget].details.items[1].countOverBudget"
},
Expand Down Expand Up @@ -5825,8 +5825,8 @@
"lighthouse-core/audits/resource-summary.js | displayValue": [
{
"values": {
"requestCount": 18,
"byteCount": 160738
"requestCount": 17,
"byteCount": 160517
},
"path": "audits[resource-summary].displayValue"
}
Expand Down
24 changes: 12 additions & 12 deletions proto/sample_v2_round_trip.json
Original file line number Diff line number Diff line change
Expand Up @@ -2208,19 +2208,19 @@
"sizeOverBudget": 72955.0
},
{
"countOverBudget": "8 requests",
"countOverBudget": "7 requests",
"label": "Total",
"requestCount": 18.0,
"requestCount": 17.0,
"resourceType": "total",
"size": 160738.0,
"sizeOverBudget": 58338.0
"size": 160517.0,
"sizeOverBudget": 58117.0
},
{
"label": "Other",
"requestCount": 2.0,
"requestCount": 1.0,
"resourceType": "other",
"size": 12861.0,
"sizeOverBudget": 7741.0
"size": 12640.0,
"sizeOverBudget": 7520.0
},
{
"countOverBudget": "1 request",
Expand Down Expand Up @@ -2405,9 +2405,9 @@
"items": [
{
"label": "Total",
"requestCount": 18.0,
"requestCount": 17.0,
"resourceType": "total",
"size": 160738.0
"size": 160517.0
},
{
"label": "Script",
Expand All @@ -2429,9 +2429,9 @@
},
{
"label": "Other",
"requestCount": 2.0,
"requestCount": 1.0,
"resourceType": "other",
"size": 12861.0
"size": 12640.0
},
{
"label": "Stylesheet",
Expand Down Expand Up @@ -2460,7 +2460,7 @@
],
"type": "table"
},
"displayValue": "18 requests \u2022 157 KB",
"displayValue": "17 requests \u2022 157 KB",
"id": "resource-summary",
"score": null,
"scoreDisplayMode": "informative",
Expand Down