1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_5/eval/strict-eval-json-object-repeated-property-name.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,44 @@ 1.4 +// Any copyright is dedicated to the Public Domain. 1.5 +// http://creativecommons.org/licenses/publicdomain/ 1.6 +"use strict"; 1.7 + 1.8 +//----------------------------------------------------------------------------- 1.9 +var BUGNUMBER = 657713; 1.10 +var summary = 1.11 + "eval JSON parser hack misfires in strict mode, for objects with duplicate " + 1.12 + "property names"; 1.13 + 1.14 +print(BUGNUMBER + ": " + summary); 1.15 + 1.16 +/************** 1.17 + * BEGIN TEST * 1.18 + **************/ 1.19 + 1.20 +try 1.21 +{ 1.22 + var r = eval('({"a": 2, "a": 3})'); 1.23 + throw new Error("didn't throw, returned " + r); 1.24 +} 1.25 +catch (e) 1.26 +{ 1.27 + assertEq(e instanceof SyntaxError, true, 1.28 + "strict mode forbids objects with duplicated property names: " + e); 1.29 +} 1.30 + 1.31 +try 1.32 +{ 1.33 + var r = Function("'use strict'; return eval('({\"a\": 2, \"a\": 3})');")(); 1.34 + throw new Error("didn't throw, returned " + r); 1.35 +} 1.36 +catch (e) 1.37 +{ 1.38 + assertEq(e instanceof SyntaxError, true, 1.39 + "strict mode forbids objects with duplicated property names: " + e); 1.40 +} 1.41 + 1.42 +/******************************************************************************/ 1.43 + 1.44 +if (typeof reportCompare === "function") 1.45 + reportCompare(true, true); 1.46 + 1.47 +print("Tests complete!");