michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, you can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: var EXPORTED_SYMBOLS = ['getLength', ];//'compare']; michael@0: michael@0: var getLength = function (obj) { michael@0: var len = 0; michael@0: for (i in obj) { michael@0: len++; michael@0: } michael@0: michael@0: return len; michael@0: } michael@0: michael@0: // var logging = {}; Components.utils.import('resource://mozmill/stdlib/logging.js', logging); michael@0: michael@0: // var objectsLogger = logging.getLogger('objectsLogger'); michael@0: michael@0: // var compare = function (obj1, obj2, depth, recursion) { michael@0: // if (depth == undefined) { michael@0: // var depth = 4; michael@0: // } michael@0: // if (recursion == undefined) { michael@0: // var recursion = 0; michael@0: // } michael@0: // michael@0: // if (recursion > depth) { michael@0: // return true; michael@0: // } michael@0: // michael@0: // if (typeof(obj1) != typeof(obj2)) { michael@0: // return false; michael@0: // } michael@0: // michael@0: // if (typeof(obj1) == "object" && typeof(obj2) == "object") { michael@0: // if ([x for (x in obj1)].length != [x for (x in obj2)].length) { michael@0: // return false; michael@0: // } michael@0: // for (i in obj1) { michael@0: // recursion++; michael@0: // var result = compare(obj1[i], obj2[i], depth, recursion); michael@0: // objectsLogger.info(i+' in recursion '+result); michael@0: // if (result == false) { michael@0: // return false; michael@0: // } michael@0: // } michael@0: // } else { michael@0: // if (obj1 != obj2) { michael@0: // return false; michael@0: // } michael@0: // } michael@0: // return true; michael@0: // }