B2G/gecko/browser/components/places/tests/unit/test_leftpane_corruption_handling.js
/**
 * Compare the JSON representation of 2 nodes, skipping everchanging properties
 * like dates.
 */
Compare the JSON representation of 2 nodes, skipping everchanging properties
like dates.
Compare the JSON representation of 2 nodes skipping everchanging properties like dates .
function compareJSON(aNodeJSON_1, aNodeJSON_2) {
  let node1 = JSON.parse(aNodeJSON_1);
  let node2 = JSON.parse(aNodeJSON_2);
  const SKIP_PROPS = ["dateAdded", "lastModified", "id"];
  function compareObjects(obj1, obj2) {
    function count(o) { var n = 0; for (let p in o) n++; return n; }
    do_check_eq(count(obj1), count(obj2));
    for (let prop in obj1) {
      if (SKIP_PROPS.indexOf(prop) != -1)
        continue;
      if (!obj1[prop])
        continue;
      if (typeof(obj1[prop]) == "object")
        return compareObjects(obj1[prop], obj2[prop]);
      if (obj1[prop] !== obj2[prop]) {
        print(prop + ": " + obj1[prop] + "!=" + obj2[prop]);
        return false;
      }
    }
    return true;
  }
  return compareObjects(node1, node2);
}
function compareJSON ( aNodeJSON_1 , aNodeJSON_2 ) { let node1 = JSON . parse ( aNodeJSON_1 ) ; let node2 = JSON . parse ( aNodeJSON_2 ) ; const SKIP_PROPS = [ "dateAdded" , "lastModified" , "id" ] ; function compareObjects ( obj1 , obj2 ) { function count ( o ) { var n = 0 ; for ( let p in o ) n ++ ; return n ; } do_check_eq ( count ( obj1 ) , count ( obj2 ) ) ; for ( let prop in obj1 ) { if ( SKIP_PROPS . indexOf ( prop ) != - 1 ) continue ; if ( ! obj1 [ prop ] ) continue ; if ( typeof ( obj1 [ prop ] ) == "object" ) return compareObjects ( obj1 [ prop ] , obj2 [ prop ] ) ; if ( obj1 [ prop ] !== obj2 [ prop ] ) { print ( prop + ": " + obj1 [ prop ] + "!=" + obj2 [ prop ] ) ; return false ; } } return true ; } return compareObjects ( node1 , node2 ) ; }
Compare the JSON representation of 2 nodes, skipping everchanging properties
 like dates.
Compare the JSON representation of 2 nodes skipping everchanging properties like dates .
// List of properties we should not compare (expected to be different). // Skip everchanging values. // Skip undefined objects, otherwise we hang on them.