1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_5/eval/line-terminator-paragraph-terminator.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,73 @@ 1.4 +// Any copyright is dedicated to the Public Domain. 1.5 +// http://creativecommons.org/licenses/publicdomain/ 1.6 + 1.7 +//----------------------------------------------------------------------------- 1.8 +var BUGNUMBER = 657367; 1.9 +var summary = "eval must not parse strings containing U+2028 or U+2029"; 1.10 + 1.11 +print(BUGNUMBER + ": " + summary); 1.12 + 1.13 +/************** 1.14 + * BEGIN TEST * 1.15 + **************/ 1.16 + 1.17 +function esc(s) 1.18 +{ 1.19 + return s.split("").map(function(v) 1.20 + { 1.21 + var code = 1.22 + ("000" + v.charCodeAt(0).toString(16)).slice(-4); 1.23 + return "\\u" + code; 1.24 + }).join(""); 1.25 +} 1.26 + 1.27 +try 1.28 +{ 1.29 + var r = eval('"\u2028"'); 1.30 + throw new Error("\"\\u2028\" didn't throw, returned " + esc(r)); 1.31 +} 1.32 +catch (e) 1.33 +{ 1.34 + assertEq(e instanceof SyntaxError, true, 1.35 + "U+2028 is not a valid string character"); 1.36 +} 1.37 + 1.38 +try 1.39 +{ 1.40 + var r = eval('("\u2028")'); 1.41 + throw new Error("(\"\\u2028\") didn't throw, returned " + esc(r)); 1.42 +} 1.43 +catch (e) 1.44 +{ 1.45 + assertEq(e instanceof SyntaxError, true, 1.46 + "U+2028 is not a valid string character"); 1.47 +} 1.48 + 1.49 +try 1.50 +{ 1.51 + var r = eval('"\u2029"'); 1.52 + throw new Error("\"\\u2029\" didn't throw, returned " + esc(r)); 1.53 +} 1.54 +catch (e) 1.55 +{ 1.56 + assertEq(e instanceof SyntaxError, true, 1.57 + "U+2029 is not a valid string character"); 1.58 +} 1.59 + 1.60 +try 1.61 +{ 1.62 + var r = eval('("\u2029")'); 1.63 + throw new Error("(\"\\u2029\") didn't throw, returned " + esc(r)); 1.64 +} 1.65 +catch (e) 1.66 +{ 1.67 + assertEq(e instanceof SyntaxError, true, 1.68 + "U+2029 is not a valid string character"); 1.69 +} 1.70 + 1.71 +/******************************************************************************/ 1.72 + 1.73 +if (typeof reportCompare === "function") 1.74 + reportCompare(true, true); 1.75 + 1.76 +print("Tests complete!");