js/src/tests/ecma_5/Expressions/string-literal-escape-sequences.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 // Any copyright is dedicated to the Public Domain.
michael@0 2 // http://creativecommons.org/licenses/publicdomain/
michael@0 3
michael@0 4 //-----------------------------------------------------------------------------
michael@0 5 var BUGNUMBER = 663300;
michael@0 6 var summary =
michael@0 7 "\\u and \\x must be followed by the appropriate number of hex digits or " +
michael@0 8 "else it is a syntax error";
michael@0 9
michael@0 10 print(BUGNUMBER + ": " + summary);
michael@0 11
michael@0 12 /**************
michael@0 13 * BEGIN TEST *
michael@0 14 **************/
michael@0 15
michael@0 16 function expectSyntaxError(str)
michael@0 17 {
michael@0 18 try
michael@0 19 {
michael@0 20 eval(str);
michael@0 21 }
michael@0 22 catch (e)
michael@0 23 {
michael@0 24 assertEq(e instanceof SyntaxError, true,
michael@0 25 "no syntax error evaluating " + str);
michael@0 26 }
michael@0 27 }
michael@0 28
michael@0 29 expectSyntaxError('"\\x"');
michael@0 30 expectSyntaxError('"\\x0"');
michael@0 31 expectSyntaxError('"\\x1"');
michael@0 32 expectSyntaxError('"\\x2"');
michael@0 33 expectSyntaxError('"\\x3"');
michael@0 34 expectSyntaxError('"\\x4"');
michael@0 35 expectSyntaxError('"\\x5"');
michael@0 36 expectSyntaxError('"\\x6"');
michael@0 37 expectSyntaxError('"\\x7"');
michael@0 38 expectSyntaxError('"\\x8"');
michael@0 39 expectSyntaxError('"\\x9"');
michael@0 40 expectSyntaxError('"\\xA"');
michael@0 41 expectSyntaxError('"\\xB"');
michael@0 42 expectSyntaxError('"\\xC"');
michael@0 43 expectSyntaxError('"\\xD"');
michael@0 44 expectSyntaxError('"\\xE"');
michael@0 45 expectSyntaxError('"\\xF"');
michael@0 46 expectSyntaxError('"\\xG"');
michael@0 47 expectSyntaxError('"\\x0G"');
michael@0 48 expectSyntaxError('"\\x1G"');
michael@0 49 expectSyntaxError('"\\x2G"');
michael@0 50 expectSyntaxError('"\\x3G"');
michael@0 51 expectSyntaxError('"\\x4G"');
michael@0 52 expectSyntaxError('"\\x5G"');
michael@0 53 expectSyntaxError('"\\x6G"');
michael@0 54 expectSyntaxError('"\\x7G"');
michael@0 55 expectSyntaxError('"\\x8G"');
michael@0 56 expectSyntaxError('"\\x9G"');
michael@0 57 expectSyntaxError('"\\xAG"');
michael@0 58 expectSyntaxError('"\\xBG"');
michael@0 59 expectSyntaxError('"\\xCG"');
michael@0 60 expectSyntaxError('"\\xDG"');
michael@0 61 expectSyntaxError('"\\xEG"');
michael@0 62 expectSyntaxError('"\\xFG"');
michael@0 63 expectSyntaxError('"\\xGG"');
michael@0 64
michael@0 65 expectSyntaxError('"\\u"');
michael@0 66 expectSyntaxError('"\\u0"');
michael@0 67 expectSyntaxError('"\\u1"');
michael@0 68 expectSyntaxError('"\\u2"');
michael@0 69 expectSyntaxError('"\\u3"');
michael@0 70 expectSyntaxError('"\\u4"');
michael@0 71 expectSyntaxError('"\\u5"');
michael@0 72 expectSyntaxError('"\\u6"');
michael@0 73 expectSyntaxError('"\\u7"');
michael@0 74 expectSyntaxError('"\\u8"');
michael@0 75 expectSyntaxError('"\\u9"');
michael@0 76 expectSyntaxError('"\\uA"');
michael@0 77 expectSyntaxError('"\\uB"');
michael@0 78 expectSyntaxError('"\\uC"');
michael@0 79 expectSyntaxError('"\\uD"');
michael@0 80 expectSyntaxError('"\\uE"');
michael@0 81 expectSyntaxError('"\\uF"');
michael@0 82 expectSyntaxError('"\\uG"');
michael@0 83 expectSyntaxError('"\\u00"');
michael@0 84 expectSyntaxError('"\\u11"');
michael@0 85 expectSyntaxError('"\\u22"');
michael@0 86 expectSyntaxError('"\\u33"');
michael@0 87 expectSyntaxError('"\\u44"');
michael@0 88 expectSyntaxError('"\\u55"');
michael@0 89 expectSyntaxError('"\\u66"');
michael@0 90 expectSyntaxError('"\\u77"');
michael@0 91 expectSyntaxError('"\\u88"');
michael@0 92 expectSyntaxError('"\\u99"');
michael@0 93 expectSyntaxError('"\\uAA"');
michael@0 94 expectSyntaxError('"\\uBB"');
michael@0 95 expectSyntaxError('"\\uCC"');
michael@0 96 expectSyntaxError('"\\uDD"');
michael@0 97 expectSyntaxError('"\\uEE"');
michael@0 98 expectSyntaxError('"\\uFF"');
michael@0 99 expectSyntaxError('"\\uGG"');
michael@0 100 expectSyntaxError('"\\u000"');
michael@0 101 expectSyntaxError('"\\u111"');
michael@0 102 expectSyntaxError('"\\u222"');
michael@0 103 expectSyntaxError('"\\u333"');
michael@0 104 expectSyntaxError('"\\u444"');
michael@0 105 expectSyntaxError('"\\u555"');
michael@0 106 expectSyntaxError('"\\u666"');
michael@0 107 expectSyntaxError('"\\u777"');
michael@0 108 expectSyntaxError('"\\u888"');
michael@0 109 expectSyntaxError('"\\u999"');
michael@0 110 expectSyntaxError('"\\uAAA"');
michael@0 111 expectSyntaxError('"\\uBBB"');
michael@0 112 expectSyntaxError('"\\uCCC"');
michael@0 113 expectSyntaxError('"\\uDDD"');
michael@0 114 expectSyntaxError('"\\uEEE"');
michael@0 115 expectSyntaxError('"\\uFFF"');
michael@0 116 expectSyntaxError('"\\uGGG"');
michael@0 117 expectSyntaxError('"\\u000G"');
michael@0 118 expectSyntaxError('"\\u111G"');
michael@0 119 expectSyntaxError('"\\u222G"');
michael@0 120 expectSyntaxError('"\\u333G"');
michael@0 121 expectSyntaxError('"\\u444G"');
michael@0 122 expectSyntaxError('"\\u555G"');
michael@0 123 expectSyntaxError('"\\u666G"');
michael@0 124 expectSyntaxError('"\\u777G"');
michael@0 125 expectSyntaxError('"\\u888G"');
michael@0 126 expectSyntaxError('"\\u999G"');
michael@0 127 expectSyntaxError('"\\uAAAG"');
michael@0 128 expectSyntaxError('"\\uBBBG"');
michael@0 129 expectSyntaxError('"\\uCCCG"');
michael@0 130 expectSyntaxError('"\\uDDDG"');
michael@0 131 expectSyntaxError('"\\uEEEG"');
michael@0 132 expectSyntaxError('"\\uFFFG"');
michael@0 133 expectSyntaxError('"\\uGGGG"');
michael@0 134
michael@0 135 assertEq(eval('"a\\\rb"'), "ab");
michael@0 136 assertEq(eval('"a\\\nb"'), "ab");
michael@0 137 assertEq(eval('"a\\\r\nb"'), "ab");
michael@0 138 assertEq(eval('"a\\\u2028b"'), "ab");
michael@0 139 assertEq(eval('"a\\\u2029b"'), "ab");
michael@0 140
michael@0 141 /******************************************************************************/
michael@0 142
michael@0 143 if (typeof reportCompare === "function")
michael@0 144 reportCompare(true, true);
michael@0 145
michael@0 146 print("All tests passed!");

mercurial