more work on refining instrumentation

test-unit-sauce
Brian Ford 12 years ago
parent 6871f874f2
commit e2d2ba92f1

@ -118,7 +118,7 @@ var inject = function () {
applyPerf: {}, applyPerf: {},
scopes: {}, // map of scope.$ids --> scope objects scopes: {}, // map of scope.$ids --> scope objects
rootScopes: [], // array of refs to root scopes rootScopes: {}, // map of $ids --> refs to root scopes
deps: [] deps: []
}; };
@ -268,7 +268,6 @@ var inject = function () {
return ret; return ret;
}; };
} else { } else {
var thatScope = this;
watchExpression = function () { watchExpression = function () {
var start = window.performance.webkitNow(); var start = window.performance.webkitNow();
var ret = thatScope.$eval(w); var ret = thatScope.$eval(w);
@ -281,7 +280,7 @@ var inject = function () {
// patch applyFunction // patch applyFunction
// ------------------- // -------------------
if (applyFunction) { if (typeof applyFunction === 'function') {
var applyStr = applyFunction.toString(); var applyStr = applyFunction.toString();
var unpatchedApplyFunction = applyFunction; var unpatchedApplyFunction = applyFunction;
applyFunction = function () { applyFunction = function () {
@ -323,13 +322,17 @@ var inject = function () {
$delegate.__proto__.$new = function () { $delegate.__proto__.$new = function () {
var ret = _new.apply(this, arguments); var ret = _new.apply(this, arguments);
if (ret.$root) {
debug.rootScopes[ret.$root.$id] = ret.$root;
}
// create empty watchers array for this scope // create empty watchers array for this scope
if (!debug.watchers[ret.$id]) { if (!debug.watchers[ret.$id]) {
debug.watchers[ret.$id] = []; debug.watchers[ret.$id] = [];
} }
return ret; return ret;
} };
// patch apply // patch apply
// ----------- // -----------

@ -19,7 +19,9 @@ panelApp.factory('appContext', function (chromeExtension) {
} }
}, },
function (data) { function (data) {
_debugCache = data; if (data) {
_debugCache = data;
}
_pollListeners.forEach(function (fn) { _pollListeners.forEach(function (fn) {
fn(); fn();
}); });
@ -30,12 +32,6 @@ panelApp.factory('appContext', function (chromeExtension) {
}; };
getDebugData(); getDebugData();
// Helpers
// =======
// Public API // Public API
// ========== // ==========
return { return {
@ -83,7 +79,6 @@ panelApp.factory('appContext', function (chromeExtension) {
return _debugCache.deps; return _debugCache.deps;
}, },
getAngularVersion: function (cb) { getAngularVersion: function (cb) {
chromeExtension.eval(function () { chromeExtension.eval(function () {
return window.angular.version.full + return window.angular.version.full +
@ -157,7 +152,7 @@ panelApp.factory('appContext', function (chromeExtension) {
getDebug: function (cb) { getDebug: function (cb) {
chromeExtension.eval(function (window) { chromeExtension.eval(function (window) {
return document.cookie.indexOf('__ngDebug=true') != -1; return document.cookie.indexOf('__ngDebug=true') !== -1;
}, cb); }, cb);
}, },
@ -169,7 +164,7 @@ panelApp.factory('appContext', function (chromeExtension) {
'}'); '}');
}, },
// takes # of miliseconds // takes # of milliseconds
setPollInterval: function (setting) { setPollInterval: function (setting) {
_pollInterval = setting; _pollInterval = setting;
}, },