js/src/tests/ecma_3/extensions/regress-188206-02.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 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 //-----------------------------------------------------------------------------
michael@0 7 var UBound = 0;
michael@0 8 var BUGNUMBER = 188206;
michael@0 9 var summary = 'Invalid use of regexp quantifiers should generate SyntaxErrors';
michael@0 10 var CHECK_PASSED = 'Should not generate an error';
michael@0 11 var CHECK_FAILED = 'Generated an error!';
michael@0 12 var status = '';
michael@0 13 var statusitems = [];
michael@0 14 var actual = '';
michael@0 15 var actualvalues = [];
michael@0 16 var expect= '';
michael@0 17 var expectedvalues = [];
michael@0 18
michael@0 19
michael@0 20 /*
michael@0 21 * Misusing the {DecmalDigits} quantifier - according to ECMA,
michael@0 22 * but not according to Perl.
michael@0 23 *
michael@0 24 * ECMA-262 Edition 3 prohibits the use of unescaped braces in
michael@0 25 * regexp patterns, unless they form part of a quantifier.
michael@0 26 *
michael@0 27 * Hovever, Perl does not prohibit this. If not used as part
michael@0 28 * of a quantifer, Perl treats braces literally.
michael@0 29 *
michael@0 30 * We decided to follow Perl on this for backward compatibility.
michael@0 31 * See http://bugzilla.mozilla.org/show_bug.cgi?id=190685.
michael@0 32 *
michael@0 33 * Therefore NONE of the following ECMA violations should generate
michael@0 34 * a SyntaxError. Note we use checkThis() instead of testThis().
michael@0 35 */
michael@0 36 status = inSection(13);
michael@0 37 checkThis(' /a*{/ ');
michael@0 38
michael@0 39 status = inSection(14);
michael@0 40 checkThis(' /a{}/ ');
michael@0 41
michael@0 42 status = inSection(15);
michael@0 43 checkThis(' /{a/ ');
michael@0 44
michael@0 45 status = inSection(16);
michael@0 46 checkThis(' /}a/ ');
michael@0 47
michael@0 48 status = inSection(17);
michael@0 49 checkThis(' /x{abc}/ ');
michael@0 50
michael@0 51 status = inSection(18);
michael@0 52 checkThis(' /{{0}/ ');
michael@0 53
michael@0 54 status = inSection(19);
michael@0 55 checkThis(' /{{1}/ ');
michael@0 56
michael@0 57 status = inSection(20);
michael@0 58 checkThis(' /x{{0}/ ');
michael@0 59
michael@0 60 status = inSection(21);
michael@0 61 checkThis(' /x{{1}/ ');
michael@0 62
michael@0 63 status = inSection(22);
michael@0 64 checkThis(' /x{{0}}/ ');
michael@0 65
michael@0 66 status = inSection(23);
michael@0 67 checkThis(' /x{{1}}/ ');
michael@0 68
michael@0 69 status = inSection(24);
michael@0 70 checkThis(' /x{{0}}/ ');
michael@0 71
michael@0 72 status = inSection(25);
michael@0 73 checkThis(' /x{{1}}/ ');
michael@0 74
michael@0 75 status = inSection(26);
michael@0 76 checkThis(' /x{{0}}/ ');
michael@0 77
michael@0 78 status = inSection(27);
michael@0 79 checkThis(' /x{{1}}/ ');
michael@0 80
michael@0 81
michael@0 82 //-----------------------------------------------------------------------------
michael@0 83 test();
michael@0 84 //-----------------------------------------------------------------------------
michael@0 85
michael@0 86
michael@0 87
michael@0 88 /*
michael@0 89 * Allowed syntax shouldn't generate any errors
michael@0 90 */
michael@0 91 function checkThis(sAllowedSyntax)
michael@0 92 {
michael@0 93 expect = CHECK_PASSED;
michael@0 94 actual = CHECK_PASSED;
michael@0 95
michael@0 96 try
michael@0 97 {
michael@0 98 eval(sAllowedSyntax);
michael@0 99 }
michael@0 100 catch(e)
michael@0 101 {
michael@0 102 actual = CHECK_FAILED;
michael@0 103 }
michael@0 104
michael@0 105 statusitems[UBound] = status;
michael@0 106 expectedvalues[UBound] = expect;
michael@0 107 actualvalues[UBound] = actual;
michael@0 108 UBound++;
michael@0 109 }
michael@0 110
michael@0 111
michael@0 112 function test()
michael@0 113 {
michael@0 114 enterFunc('test');
michael@0 115 printBugNumber(BUGNUMBER);
michael@0 116 printStatus(summary);
michael@0 117
michael@0 118 for (var i=0; i<UBound; i++)
michael@0 119 {
michael@0 120 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
michael@0 121 }
michael@0 122
michael@0 123 exitFunc ('test');
michael@0 124 }

mercurial