reviver-mutates-holder-array-ccw.js (916B)
1 /* 2 * Any copyright is dedicated to the Public Domain. 3 * http://creativecommons.org/licenses/publicdomain/ 4 * Contributor: 5 * Jeff Walden <jwalden+code@mit.edu> 6 */ 7 8 //----------------------------------------------------------------------------- 9 var BUGNUMBER = 901351; 10 var summary = "Behavior when the JSON.parse reviver mutates the holder array"; 11 12 print(BUGNUMBER + ": " + summary); 13 14 /************** 15 * BEGIN TEST * 16 **************/ 17 18 var proxyObj = null; 19 20 var arr = JSON.parse('[0, 1]', function(prop, v) { 21 if (prop === "0") 22 { 23 proxyObj = newGlobal().evaluate("({ c: 17, d: 42 })"); 24 this[1] = proxyObj; 25 } 26 return v; 27 }); 28 29 assertEq(arr[0], 0); 30 assertEq(arr[1], proxyObj); 31 assertEq(arr[1].c, 17); 32 assertEq(arr[1].d, 42); 33 34 /******************************************************************************/ 35 36 if (typeof reportCompare === "function") 37 reportCompare(true, true); 38 39 print("Tests complete");