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(preload): remove blob protocol from preload audit #5409

Merged
merged 4 commits into from
Jul 11, 2018
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
2 changes: 1 addition & 1 deletion lighthouse-core/audits/uses-rel-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class UsesRelPreloadAudit extends Audit {
* @return {boolean}
*/
static shouldPreload(request, mainResource) {
if (request.isLinkPreload || request.protocol === 'data') {
if (request.isLinkPreload || URL.NON_NETWORK_PROTOCOLS.includes(request.protocol)) {
return false;
}

Expand Down
2 changes: 2 additions & 0 deletions lighthouse-core/lib/url-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ URLShim.URL = URL;
URLShim.URLSearchParams = (typeof self !== 'undefined' && self.URLSearchParams) ||
require('url').URLSearchParams;

URLShim.NON_NETWORK_PROTOCOLS = ['blob', 'data'];

URLShim.INVALID_URL_DEBUG_STRING =
'Lighthouse was unable to determine the URL of some script executions. ' +
'It\'s possible a Chrome extension or other eval\'d code is the source.';
Expand Down
30 changes: 30 additions & 0 deletions lighthouse-core/test/audits/uses-rel-preload-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,36 @@ describe('Performance: uses-rel-preload audit', () => {
});
});

it(`shouldn't suggest preload for protocol blob`, () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this test fail without the fix? seems like it wouldn't have wastedMs anyhow

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe let's just leave a TODO to make creating fake lantern graphs easier, it's inline with the other tests in the file for now

const networkRecords = [
{
requestId: '3',
protocol: 'blob',
_startTime: 10,
},
];

const chains = {
'1': {
children: {
'2': {
children: {
'3': {
request: networkRecords[0],
children: {},
},
},
},
},
},
};

return UsesRelPreload.audit(mockArtifacts(networkRecords, chains), {}).then(output => {
assert.equal(output.rawValue, 0);
assert.equal(output.details.items.length, 0);
});
});

it('does not throw on a real trace/devtools log', async () => {
const artifacts = Object.assign({
URL: {finalUrl: 'https://pwa.rocks/'},
Expand Down