Fixes cirular references detection in PhantomReporter.js.

The logic which was in place to convert array-like objects to arrays
prevented the circular reference detection to work properly for arrays
and array-like objects.
This commit is contained in:
Felix Kling 2013-02-27 03:40:20 +00:00 committed by Jarrod Overson
parent dbe298a042
commit 8fc713fb13

View File

@ -105,7 +105,7 @@ phantom.sendMessage = function() {
function stringify(obj) {
if (typeof obj !== 'object') return obj;
var cache = [], keyMap = [], tempArray, index;
var cache = [], keyMap = [], index;
var string = JSON.stringify(obj, function(key, value) {
// Let json stringify falsy values
@ -122,9 +122,6 @@ phantom.sendMessage = function() {
if (typeof value === 'object' && value !== null) {
// Check to see if we have a pseudo array that can be converted
if (value.length && (tempArray = Array.prototype.slice.call(value)).length === value.length) value = tempArray;
if (index = cache.indexOf(value) !== -1) {
// If we have it in cache, report the circle with the key we first found it in
return '[ Circular {' + (keyMap[index] || 'root') + '} ]';