Adding totalWeight metric

This commit is contained in:
Gaël Métais
2015-05-29 16:13:32 +02:00
parent 040dba961a
commit c6c967f89c
7 changed files with 496 additions and 5 deletions
@@ -0,0 +1,23 @@
/**
* Retries download on every request to get the real file size
*
*/
exports.version = '0.1';
exports.module = function(phantomas) {
'use strict';
phantomas.setMetric('requestsList');
var requests = [];
phantomas.on('recv', function(entry, res) {
requests.push(entry);
});
phantomas.on('report', function() {
phantomas.setMetric('requestsList', true, true);
phantomas.addOffender('requestsList', JSON.stringify(requests));
});
};
+2 -2
View File
@@ -67,7 +67,7 @@ var PhantomasWrapper = function() {
if (value === true) {
optionsString += ' ' + '--' + opt;
} else if (value === false || value === null) {
} else if (value === false || value === null || value === undefined) {
// Nothing
} else {
optionsString += ' ' + '--' + opt + '=' + value;
@@ -122,7 +122,7 @@ var PhantomasWrapper = function() {
}
debug('Returning from Phantomas');
debug('Returning from Phantomas with error %s', err);
// Adding some YellowLabTools errors here
if (json && json.metrics && (!json.metrics.javascriptExecutionTree || !json.offenders.javascriptExecutionTree)) {