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: remove no-mutation-events audit & js callstack method #5509

Merged
merged 2 commits into from
Jun 18, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
37 changes: 0 additions & 37 deletions lighthouse-cli/test/fixtures/dobetterweb/dbw_tester.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,39 +208,6 @@ <h2>Do better web tester page</h2>
const db = openDatabase('mydb', '1.0', 'my first database', 1024);
}

function mutationEvenTest() {
// FAIL
document.addEventListener('DOMNodeInserted', function(e) {
console.log('DOMNodeInserted');
});

// FAIL
document.addEventListener('DOMNodeRemoved', function(e) {
console.log('DOMNodeRemoved');
});

// FAIL
document.body.addEventListener('DOMNodeInserted', function(e) {
console.log('DOMNodeInserted');
});

// FAIL
const el = document.querySelector('#touchmove-section');
el.addEventListener('DOMNodeInserted', function(e) {
console.log('DOMNodeInserted on element');
});

// FAIL
window.addEventListener('DOMNodeInserted', function(e) {
console.log('DOMNodeInserted');
});

// PASS - not MutationEvents
window.addEventListener('DOMContentLoaded', function(e) {
console.log('DOMContentLoaded');
});
}

function passiveEventsListenerTest() {
// FAIL
window.addEventListener('wheel', function(e) {
Expand Down Expand Up @@ -364,7 +331,6 @@ <h2>Do better web tester page</h2>
dateNowTest();
consoleTimeTest();
websqlTest();
mutationEvenTest();
passiveEventsListenerTest();
geolocationOnStartTest();
notificationOnStartTest();
Expand All @@ -387,9 +353,6 @@ <h2>Do better web tester page</h2>
if (params.has('websql')) {
websqlTest();
}
if (params.has('mutationEvents')) {
mutationEvenTest();
}
if (params.has('passiveEvents')) {
passiveEventsListenerTest();
}
Expand Down
7 changes: 0 additions & 7 deletions lighthouse-cli/test/fixtures/dobetterweb/dbw_tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ if (location.search === '' || params.has('dateNow')) {
const d = Date.now();
}

if (location.search === '' || params.has('mutationEvents')) {
// FAIL - MutationEvent usage in another file.
document.addEventListener('DOMNodeInserted', function(e) {
console.log('DOMNodeInserted');
});
}

if (location.search === '' || params.has('passiveEvents')) {
// FAIL - non-passive listener usage in another file.
document.addEventListener('wheel', e => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@ module.exports = [
},
},
},
'no-mutation-events': {
score: 0,
details: {
items: {
length: 6,
},
},
},
'no-vulnerable-libraries': {
score: 0,
details: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ module.exports = [
'no-document-write': {
score: 1,
},
'no-mutation-events': {
score: 1,
},
'no-websql': {
score: 1,
},
Expand Down
92 changes: 0 additions & 92 deletions lighthouse-core/audits/dobetterweb/no-mutation-events.js

This file was deleted.

3 changes: 0 additions & 3 deletions lighthouse-core/config/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ module.exports = {
'chrome-console-messages',
'image-usage',
'accessibility',
'dobetterweb/all-event-listeners',
'dobetterweb/anchors-with-no-rel-noopener',
'dobetterweb/appcache',
'dobetterweb/domstats',
Expand Down Expand Up @@ -166,7 +165,6 @@ module.exports = {
'dobetterweb/external-anchors-use-rel-noopener',
'dobetterweb/geolocation-on-start',
'dobetterweb/no-document-write',
'dobetterweb/no-mutation-events',
'dobetterweb/no-vulnerable-libraries',
'dobetterweb/no-websql',
'dobetterweb/notification-on-start',
Expand Down Expand Up @@ -371,7 +369,6 @@ module.exports = {
{id: 'is-on-https', weight: 1},
{id: 'uses-http2', weight: 1},
{id: 'uses-passive-event-listeners', weight: 1},
{id: 'no-mutation-events', weight: 1},
{id: 'no-document-write', weight: 1},
{id: 'external-anchors-use-rel-noopener', weight: 1},
{id: 'geolocation-on-start', weight: 1},
Expand Down
32 changes: 0 additions & 32 deletions lighthouse-core/gather/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -1077,38 +1077,6 @@ class Driver {
await this.evaluteScriptOnNewDocument(scriptStr);
}

/**
* Keeps track of calls to a JS function and returns a list of {url, line, col}
* of the usage. Should be called before page load (in beforePass).
* @param {string} funcName The function name to track ('Date.now', 'console.time').
* @return {function(): Promise<Array<{url: string, line: number, col: number}>>}
* Call this method when you want results.
*/
captureFunctionCallSites(funcName) {
const globalVarToPopulate = `window['__${funcName}StackTraces']`;
const collectUsage = () => {
return this.evaluateAsync(
`Array.from(${globalVarToPopulate}).map(item => JSON.parse(item))`)
.then(result => {
if (!Array.isArray(result)) {
throw new Error(
'Driver failure: Expected evaluateAsync results to be an array ' +
`but got "${JSON.stringify(result)}" instead.`);
}
// Filter out usage from extension content scripts.
return result.filter(item => !item.isExtension);
});
};

const funcBody = pageFunctions.captureJSCallUsage.toString();

this.evaluteScriptOnNewDocument(`
${globalVarToPopulate} = new Set();
(${funcName} = ${funcBody}(${funcName}, ${globalVarToPopulate}))`);

return collectUsage;
}

/**
* @param {Array<string>} urls URL patterns to block. Wildcards ('*') are allowed.
* @return {Promise<void>}
Expand Down
Loading