js/src/tests/ecma_2/RegExp/hex-001.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.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 /**
     8  *  File Name:          RegExp/hex-001.js
     9  *  ECMA Section:       15.7.3.1
    10  *  Description:        Based on ECMA 2 Draft 7 February 1999
    11  *  Positive test cases for constructing a RegExp object
    12  *  Author:             christine@netscape.com
    13  *  Date:               19 February 1999
    14  */
    15 var SECTION = "RegExp/hex-001";
    16 var VERSION = "ECMA_2";
    17 var TITLE   = "RegExp patterns that contain HexicdecimalEscapeSequences";
    19 startTest();
    21 // These examples come from 15.7.1, HexidecimalEscapeSequence
    23 AddRegExpCases( new RegExp("\x41"),  "new RegExp('\\x41')",  "A",  "A", 1, 0, ["A"] );
    24 AddRegExpCases( new RegExp("\x412"),"new RegExp('\\x412')", "A2", "A2", 1, 0, ["A2"] );
    26 AddRegExpCases( new RegExp("A"),  "new RegExp('A')",  "\x41",  "\\x41",  1, 0, ["A"] );
    27 AddRegExpCases( new RegExp("A"),  "new RegExp('A')",  "\x412", "\\x412", 1, 0, ["A"] );
    28 AddRegExpCases( new RegExp("^x"), "new RegExp('^x')", "x412",  "x412",   1, 0, ["x"]);
    29 AddRegExpCases( new RegExp("A"),  "new RegExp('A')",  "A2",    "A2",     1, 0, ["A"] );
    31 test();
    33 function AddRegExpCases(
    34   regexp, str_regexp, pattern, str_pattern, length, index, matches_array ) {
    36   // prevent a runtime error
    38   if ( regexp.exec(pattern) == null || matches_array == null ) {
    39     AddTestCase(
    40       str_regexp + ".exec(" + pattern +")",
    41       matches_array,
    42       regexp.exec(pattern) );
    44     return;
    45   }
    47   AddTestCase(
    48     str_regexp + ".exec(" + str_pattern +").length",
    49     length,
    50     regexp.exec(pattern).length );
    52   AddTestCase(
    53     str_regexp + ".exec(" + str_pattern +").index",
    54     index,
    55     regexp.exec(pattern).index );
    57   AddTestCase(
    58     str_regexp + ".exec(" + str_pattern +").input",
    59     pattern,
    60     regexp.exec(pattern).input );
    62   for ( var matches = 0; matches < matches_array.length; matches++ ) {
    63     AddTestCase(
    64       str_regexp + ".exec(" + str_pattern +")[" + matches +"]",
    65       matches_array[matches],
    66       regexp.exec(pattern)[matches] );
    67   }
    68 }

mercurial