js/src/tests/ecma_2/RegExp/properties-002.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/properties-002.js
     9  *  ECMA Section:       15.7.6.js
    10  *  Description:        Based on ECMA 2 Draft 7 February 1999
    11  *
    12  *  Author:             christine@netscape.com
    13  *  Date:               19 February 1999
    14  */
    15 //-----------------------------------------------------------------------------
    16 var SECTION = "RegExp/properties-002.js";
    17 var VERSION = "ECMA_2";
    18 var TITLE   = "Properties of RegExp Instances";
    19 var BUGNUMBER ="124339";
    21 startTest();
    23 re_1 = /\cA?/g;
    24 re_1.lastIndex = Math.pow(2,31);
    25 AddRegExpCases( re_1, "\\cA?", true, false, false, Math.pow(2,31) );
    27 re_2 = /\w*/i;
    28 re_2.lastIndex = Math.pow(2,32) -1;
    29 AddRegExpCases( re_2, "\\w*", false, true, false, Math.pow(2,32)-1 );
    31 re_3 = /\*{0,80}/m;
    32 re_3.lastIndex = Math.pow(2,31) -1;
    33 AddRegExpCases( re_3, "\\*{0,80}", false, false, true, Math.pow(2,31) -1 );
    35 re_4 = /^./gim;
    36 re_4.lastIndex = Math.pow(2,30) -1;
    37 AddRegExpCases( re_4, "^.", true, true, true, Math.pow(2,30) -1 );
    39 re_5 = /\B/;
    40 re_5.lastIndex = Math.pow(2,30);
    41 AddRegExpCases( re_5, "\\B", false, false, false, Math.pow(2,30) );
    43 /*
    44  * Brendan: "need to test cases Math.pow(2,32) and greater to see
    45  * whether they round-trip." Reason: thanks to the work done in
    46  * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, lastIndex
    47  * is now stored as a double instead of a uint32_t (unsigned integer).
    48  *
    49  * Note 2^32 -1 is the upper bound for uint32's, but doubles can go
    50  * all the way up to Number.MAX_VALUE. So that's why we need cases
    51  * between those two numbers.
    52  *
    53  */
    54 re_6 = /\B/;
    55 re_6.lastIndex = Math.pow(2,32);
    56 AddRegExpCases( re_6, "\\B", false, false, false, Math.pow(2,32) );
    58 re_7 = /\B/;
    59 re_7.lastIndex = Math.pow(2,32) + 1;
    60 AddRegExpCases( re_7, "\\B", false, false, false, Math.pow(2,32) + 1 );
    62 re_8 = /\B/;
    63 re_8.lastIndex = Math.pow(2,32) * 2;
    64 AddRegExpCases( re_8, "\\B", false, false, false, Math.pow(2,32) * 2 );
    66 re_9 = /\B/;
    67 re_9.lastIndex = Math.pow(2,40);
    68 AddRegExpCases( re_9, "\\B", false, false, false, Math.pow(2,40) );
    70 re_10 = /\B/;
    71 re_10.lastIndex = Number.MAX_VALUE;
    72 AddRegExpCases( re_10, "\\B", false, false, false, Number.MAX_VALUE );
    76 //-----------------------------------------------------------------------------
    77 test();
    78 //-----------------------------------------------------------------------------
    82 function AddRegExpCases( re, s, g, i, m, l ){
    84   AddTestCase( re + ".test == RegExp.prototype.test",
    85 	       true,
    86 	       re.test == RegExp.prototype.test );
    88   AddTestCase( re + ".toString == RegExp.prototype.toString",
    89 	       true,
    90 	       re.toString == RegExp.prototype.toString );
    92   AddTestCase( re + ".contructor == RegExp.prototype.constructor",
    93 	       true,
    94 	       re.constructor == RegExp.prototype.constructor );
    96   AddTestCase( re + ".compile == RegExp.prototype.compile",
    97 	       true,
    98 	       re.compile == RegExp.prototype.compile );
   100   AddTestCase( re + ".exec == RegExp.prototype.exec",
   101 	       true,
   102 	       re.exec == RegExp.prototype.exec );
   104   // properties
   106   AddTestCase( re + ".source",
   107 	       s,
   108 	       re.source );
   110   AddTestCase( re + ".toString()",
   111 	       "/" + s +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""),
   112 	       re.toString() );
   114   AddTestCase( re + ".global",
   115 	       g,
   116 	       re.global );
   118   AddTestCase( re + ".ignoreCase",
   119 	       i,
   120 	       re.ignoreCase );
   122   AddTestCase( re + ".multiline",
   123 	       m,
   124 	       re.multiline);
   126   AddTestCase( re + ".lastIndex",
   127 	       l,
   128 	       re.lastIndex  );
   129 }

mercurial