js/src/tests/ecma_3/RegExp/regress-216591.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/. */
     6 /*
     7  *
     8  * Date:    19 August 2003
     9  * SUMMARY: Regexp conformance test
    10  *
    11  * See http://bugzilla.mozilla.org/show_bug.cgi?id=216591
    12  *
    13  */
    14 //-----------------------------------------------------------------------------
    15 var i = 0;
    16 var BUGNUMBER = 216591;
    17 var summary = 'Regexp conformance test';
    18 var status = '';
    19 var statusmessages = new Array();
    20 var pattern = '';
    21 var patterns = new Array();
    22 var string = '';
    23 var strings = new Array();
    24 var actualmatch = '';
    25 var actualmatches = new Array();
    26 var expectedmatch = '';
    27 var expectedmatches = new Array();
    30 status = inSection(1);
    31 string = 'a {result.data.DATA} b';
    32 pattern = /\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}/i;
    33 actualmatch = string.match(pattern);
    34 expectedmatch = Array('{result.data.DATA}', 'result.data.', 'data.', 'DATA');
    35 addThis();
    37 /*
    38  * Add a global flag to the regexp. In Perl 5, this gives the same results as above. Compare:
    39  *
    40  * [ ] perl -e '"a {result.data.DATA} b" =~ /\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}/i;  print("$&, $1, $2, $3");'
    41  * {result.data.DATA}, result.data., data., DATA
    42  *
    43  * [ ] perl -e '"a {result.data.DATA} b" =~ /\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}/gi; print("$&, $1, $2, $3");'
    44  * {result.data.DATA}, result.data., data., DATA
    45  *
    46  *
    47  * But in JavaScript, there will no longer be any sub-captures:
    48  */
    49 status = inSection(2);
    50 string = 'a {result.data.DATA} b';
    51 pattern = /\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}/gi;
    52 actualmatch = string.match(pattern);
    53 expectedmatch = Array('{result.data.DATA}');
    54 addThis();
    59 //-----------------------------------------------------------------------------
    60 test();
    61 //-----------------------------------------------------------------------------
    65 function addThis()
    66 {
    67   statusmessages[i] = status;
    68   patterns[i] = pattern;
    69   strings[i] = string;
    70   actualmatches[i] = actualmatch;
    71   expectedmatches[i] = expectedmatch;
    72   i++;
    73 }
    76 function test()
    77 {
    78   enterFunc ('test');
    79   printBugNumber(BUGNUMBER);
    80   printStatus (summary);
    81   testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
    82   exitFunc ('test');
    83 }

mercurial