Skip to content

Commit

Permalink
Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ebidel committed Sep 24, 2016
1 parent 05bb06c commit 1edb38d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
8 changes: 5 additions & 3 deletions lighthouse-core/audits/dobetterweb/uses-http2.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class UsesHTTP2Audit extends Audit {
return {
category: 'Performance',
name: 'uses-http2',
description: 'Site resources use HTTP/2',
helpText: 'See <a href="https://http2.github.io/faq/" target="_blank">HTTP2 FAQ</a>.',
description: 'Site uses HTTP/2 for its own resources',
helpText: 'h2 offers many benefits over its predecessor HTTP/1.1: binary, multiplexing, server push, etc. See <a href="https://http2.github.io/faq/" target="_blank">this FAQ</a> for more information.',
requiredArtifacts: ['SameOriginResources']
};
}
Expand All @@ -53,7 +53,9 @@ class UsesHTTP2Audit extends Audit {
});
}

// Filter the non http/2 resources.
console.log(artifacts.SameOriginResources.map(r => r.protocol))

// Filter the non h2 resources.
const resources = artifacts.SameOriginResources.filter(record => {
return /HTTP\/[01][\.\d]?/i.test(record.protocol);
});
Expand Down
7 changes: 6 additions & 1 deletion lighthouse-core/formatters/url-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ class UrlList extends Formatter {
if (!Array.isArray(resources)) {
return '';
}
// TODO

let output = '';
resources.forEach(resource => {
output += ` ${resource.url} (${resource.protocol})\n`;
});
return output;
};

case 'html':
Expand Down
9 changes: 3 additions & 6 deletions lighthouse-core/gather/gatherers/same-origin-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,12 @@ class SameOriginResources extends Gatherer {
const initialHost = url.parse(options.initialUrl).host;

// Find requests that are on the same origin as the page.
const results = tracingData.networkRecords.reduce((prev, record) => {
const results = tracingData.networkRecords.filter(record => {
const requestHost = url.parse(record.url).host;
const sameOrigin = requestHost === finalHost ||
requestHost === initialHost;
if (sameOrigin) {
prev.push(record);
}
return prev;
}, []);
return sameOrigin;
});

this.artifact = results;
}
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-core/test/audits/dobetterweb/uses-http2-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ describe('Resources are fetched over http/2', () => {
it('passes when all resources were requested via http/2', () => {
const auditResult = UsesHTTP2Audit.audit({
SameOriginResources: [
{url: 'http://example.com/one', protocol: 'http/2'},
{url: 'http://example.com/two', protocol: 'http/2.0'}
{url: 'http://example.com/one', protocol: 'h2'},
{url: 'http://example.com/two', protocol: 'h2'}
]
});
assert.equal(auditResult.rawValue, true);
Expand Down

0 comments on commit 1edb38d

Please sign in to comment.