Fix #39 Error 1001 when using the Node module

This commit is contained in:
Gaël Métais
2015-01-15 12:34:47 +01:00
parent 6521d24925
commit 0f00111373
5 changed files with 59 additions and 33 deletions
+3 -2
View File
@@ -93,7 +93,9 @@ module.exports = function(grunt) {
coverage: {
files: [
{src: ['test/**'], dest: 'coverage/'},
{src: ['lib/metadata/**'], dest: 'coverage/'}
{src: ['lib/metadata/**'], dest: 'coverage/'},
{src: ['node_modules/phantomas/**'], dest: 'coverage/'},
{src: ['lib/tools/phantomas/custom_modules/**'], dest: 'coverage/'}
]
},
build: {
@@ -336,7 +338,6 @@ module.exports = function(grunt) {
]);
grunt.registerTask('test-current-work', [
'build',
'jshint',
'express:testSuite',
'clean:coverage',
@@ -289,7 +289,7 @@ exports.module = function(phantomas) {
// count DOM queries by either ID, tag name, class name and selector query
// @see https://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-doctype
var Collection = require('../../../../../../node_modules/phantomas/lib/collection'),
var Collection = require('../../util/collection'),
DOMqueries = new Collection();
phantomas.on('domQuery', function(type, query, fnName, context) {
@@ -276,7 +276,7 @@ exports.module = function(phantomas) {
// count Sizzle calls to detect duplicated queries
var Collection = require('../../../../../../node_modules/phantomas/lib/collection'),
var Collection = require('../../util/collection'),
sizzleCalls = new Collection(),
jQueryLoading = new Collection();
@@ -1,29 +0,0 @@
/**
* Meters the number of page errors, and provides traces as offenders for "jsErrors" metric
*/
exports.version = '0.0';
exports.module = function(phantomas) {
'use strict';
/*phantomas.on('recv', function(entry, res) {
if (!entry.isJS) {
return;
}
// Yeah, this is weird, i'm sending the information back to the browser...
phantomas.evaluate(function(url) {
(function(phantomas) {
phantomas.pushContext({
type: 'script loaded',
callDetails: {
arguments: [url]
}
});
})(window.__phantomas);
}, entry.url);
});*/
};
@@ -0,0 +1,54 @@
/**
* Push items and count them
*/
function collection() {
/* jshint validthis: true */
this.items = {};
}
collection.prototype = {
push: function(item) {
if (typeof this.items[item] === 'undefined') {
this.items[item] = {
cnt: 1
};
} else {
this.items[item].cnt++;
}
},
sort: function() {
var newItems = {},
sortedKeys;
// sort in descending order (by cnt)
sortedKeys = Object.keys(this.items).sort((function(a, b) {
return this.items[b].cnt - this.items[a].cnt;
}).bind(this));
// build new items dictionary
sortedKeys.forEach(function(key) {
newItems[key] = this.items[key];
}, this);
this.items = newItems;
return this;
},
forEach: function(callback) {
Object.keys(this.items).forEach(function(key) {
callback(key, this.items[key].cnt);
}, this);
},
has: function(item) {
return (typeof this.items[item] !== 'undefined');
},
getLength: function() {
return Object.keys(this.items).length;
}
};
module.exports = collection;