js/src/tests/ecma_2/RegExp/multiline-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/multiline-001.js
     9  *  ECMA Section:
    10  *  Description:        Based on ECMA 2 Draft 7 February 1999
    11  *
    12  *  Date:               19 February 1999
    13  */
    15 var SECTION = "RegExp/multiline-001";
    16 var VERSION = "ECMA_2";
    17 var TITLE   = "RegExp: multiline flag";
    18 var BUGNUMBER="343901";
    20 startTest();
    22 var woodpeckers = "ivory-billed\ndowny\nhairy\nacorn\nyellow-bellied sapsucker\n" +
    23   "northern flicker\npileated\n";
    25 AddRegExpCases( /.*[y]$/m, woodpeckers, woodpeckers.indexOf("downy"), ["downy"] );
    27 AddRegExpCases( /.*[d]$/m, woodpeckers, woodpeckers.indexOf("ivory-billed"), ["ivory-billed"] );
    29 test();
    32 function AddRegExpCases
    33 ( regexp, pattern, index, matches_array ) {
    35   // prevent a runtime error
    37   if ( regexp.exec(pattern) == null || matches_array == null ) {
    38     AddTestCase(
    39       regexp + ".exec(" + pattern +")",
    40       matches_array,
    41       regexp.exec(pattern) );
    43     return;
    44   }
    46   AddTestCase(
    47     regexp.toString() + ".exec(" + pattern +").length",
    48     matches_array.length,
    49     regexp.exec(pattern).length );
    51   AddTestCase(
    52     regexp.toString() + ".exec(" + pattern +").index",
    53     index,
    54     regexp.exec(pattern).index );
    56   AddTestCase(
    57     regexp + ".exec(" + pattern +").input",
    58     pattern,
    59     regexp.exec(pattern).input );
    62   for ( var matches = 0; matches < matches_array.length; matches++ ) {
    63     AddTestCase(
    64       regexp + ".exec(" + pattern +")[" + matches +"]",
    65       matches_array[matches],
    66       regexp.exec(pattern)[matches] );
    67   }
    68 }

mercurial