Add spy on getComputedStyle()
This commit is contained in:
@@ -6,6 +6,14 @@ var jsExecutionTransformer = function() {
|
||||
|
||||
this.transform = function(data) {
|
||||
var javascriptExecutionTree = {};
|
||||
|
||||
var metrics = {
|
||||
domManipulations: 0,
|
||||
queriesWithoutResults: 0,
|
||||
jQueryCalls: 0,
|
||||
jQueryCallsOnEmptyObject: 0
|
||||
|
||||
};
|
||||
|
||||
debug('Starting JS execution transformation');
|
||||
|
||||
@@ -56,7 +64,7 @@ var jsExecutionTransformer = function() {
|
||||
node.data.callDetails.context.elements = node.data.callDetails.context.elements.map(offendersHelpers.domPathToDomElementObj, offendersHelpers);
|
||||
}
|
||||
|
||||
if (node.data.type === 'appendChild' || node.data.type === 'insertBefore') {
|
||||
if (node.data.type === 'appendChild' || node.data.type === 'insertBefore' || node.data.type === 'getComputedStyle') {
|
||||
node.data.callDetails.arguments[0] = offendersHelpers.domPathToDomElementObj(node.data.callDetails.arguments[0]);
|
||||
}
|
||||
|
||||
@@ -73,7 +81,12 @@ var jsExecutionTransformer = function() {
|
||||
throw err;
|
||||
}
|
||||
|
||||
return javascriptExecutionTree;
|
||||
data.javascriptExecutionTree = javascriptExecutionTree;
|
||||
data.toolsResults.jsExecutionTransformer = {
|
||||
metrics: metrics
|
||||
};
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
function treeRecursiveParser(node, fn) {
|
||||
|
||||
@@ -323,6 +323,22 @@ exports.module = function(phantomas) {
|
||||
phantomas.leaveContext();
|
||||
});
|
||||
|
||||
|
||||
phantomas.spy(window, 'getComputedStyle', function(element, pseudoElement) {
|
||||
var target = phantomas.getDOMPath(element);
|
||||
|
||||
phantomas.enterContext({
|
||||
type: 'getComputedStyle',
|
||||
callDetails: {
|
||||
arguments: [target, pseudoElement]
|
||||
},
|
||||
backtrace: phantomas.getBacktrace()
|
||||
});
|
||||
|
||||
}, function(result, args) {
|
||||
phantomas.leaveContext();
|
||||
});
|
||||
|
||||
})(window.__phantomas);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user