Improve scroll bottlenecks rules

This commit is contained in:
Gaël Métais
2015-05-07 17:10:01 +02:00
parent 8c79f39389
commit f8f792645b
5 changed files with 40 additions and 12 deletions
@@ -41,7 +41,7 @@ exports.module = function(phantomas) {
// count window.addEventListener('scroll', ...) - issue #508
if (eventType === 'scroll' && (path === 'window' || path === '#document')) {
phantomas.incrMetric('eventsScrollBound');
phantomas.addOffender('eventsScrollBound', 'bound by %s', phantomas.getBacktrace());
phantomas.addOffender('eventsScrollBound', 'bound by %s on %s', phantomas.getBacktrace(), path);
}
}
@@ -67,4 +67,16 @@ exports.module = function(phantomas) {
})(window.__phantomas);
});
});
phantomas.on('report', function() {
phantomas.evaluate(function() {
(function(phantomas) {
// Check if a window.onscroll function is defined
if (typeof(window.onscroll) === "function") {
phantomas.incrMetric('eventsScrollBound');
phantomas.addOffender('eventsScrollBound', 'bound by %s on %s', '', 'window.onscroll');
}
}(window.__phantomas));
});
});
};