Skip to content

Commit

Permalink
core(preload): remove blob protocol from preload audit (#5409)
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet authored and patrickhulce committed Jul 11, 2018
1 parent 9e0341a commit 82505a1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
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`, () => {
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

0 comments on commit 82505a1

Please sign in to comment.