js/src/tests/ecma_3/RegExp/regress-67773.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  * Date: 06 February 2001
     8  *
     9  * SUMMARY:  Arose from Bugzilla bug 67773:
    10  * "Regular subexpressions followed by + failing to run to completion"
    11  *
    12  * See http://bugzilla.mozilla.org/show_bug.cgi?id=67773
    13  * See http://bugzilla.mozilla.org/show_bug.cgi?id=69989
    14  */
    15 //-----------------------------------------------------------------------------
    16 var i = 0;
    17 var BUGNUMBER = 67773;
    18 var summary = 'Testing regular subexpressions followed by ? or +\n';
    19 var cnSingleSpace = ' ';
    20 var status = '';
    21 var statusmessages = new Array();
    22 var pattern = '';
    23 var patterns = new Array();
    24 var string = '';
    25 var strings = new Array();
    26 var actualmatch = '';
    27 var actualmatches = new Array();
    28 var expectedmatch = '';
    29 var expectedmatches = new Array();
    32 pattern = /^(\S+)?( ?)(B+)$/;  //single space before second ? character
    33 status = inSection(1);
    34 string = 'AAABBB AAABBB ';  //single space at middle and at end -
    35 actualmatch = string.match(pattern);
    36 expectedmatch = null;
    37 addThis();
    39 status = inSection(2);
    40 string = 'AAABBB BBB';  //single space in the middle
    41 actualmatch = string.match(pattern);
    42 expectedmatch = Array(string,  'AAABBB', cnSingleSpace,  'BBB');
    43 addThis();
    45 status = inSection(3);
    46 string = 'AAABBB AAABBB';  //single space in the middle
    47 actualmatch = string.match(pattern);
    48 expectedmatch = null;
    49 addThis();
    52 pattern = /^(A+B)+$/;
    53 status = inSection(4);
    54 string = 'AABAAB';
    55 actualmatch = string.match(pattern);
    56 expectedmatch = Array(string,  'AAB');
    57 addThis();
    59 status = inSection(5);
    60 string = 'ABAABAAAAAAB';
    61 actualmatch = string.match(pattern);
    62 expectedmatch = Array(string,  'AAAAAAB');
    63 addThis();
    65 status = inSection(6);
    66 string = 'ABAABAABAB';
    67 actualmatch = string.match(pattern);
    68 expectedmatch = Array(string,  'AB');
    69 addThis();
    71 status = inSection(7);
    72 string = 'ABAABAABABB';
    73 actualmatch = string.match(pattern);
    74 expectedmatch = null;   // because string doesn't match at end
    75 addThis();
    78 pattern = /^(A+1)+$/;
    79 status = inSection(8);
    80 string = 'AA1AA1';
    81 actualmatch = string.match(pattern);
    82 expectedmatch = Array(string,  'AA1');
    83 addThis();
    86 pattern = /^(\w+\-)+$/;
    87 status = inSection(9);
    88 string = '';
    89 actualmatch = string.match(pattern);
    90 expectedmatch = null;
    91 addThis();
    93 status = inSection(10);
    94 string = 'bla-';
    95 actualmatch = string.match(pattern);
    96 expectedmatch = Array(string, string);
    97 addThis();
    99 status = inSection(11);
   100 string = 'bla-bla';  // hyphen missing at end -
   101 actualmatch = string.match(pattern);
   102 expectedmatch = null;  //because string doesn't match at end
   103 addThis();
   105 status = inSection(12);
   106 string = 'bla-bla-';
   107 actualmatch = string.match(pattern);
   108 expectedmatch = Array(string, 'bla-');
   109 addThis();
   112 pattern = /^(\S+)+(A+)$/;
   113 status = inSection(13);
   114 string = 'asdldflkjAAA';
   115 actualmatch = string.match(pattern);
   116 expectedmatch = Array(string, 'asdldflkjAA', 'A');
   117 addThis();
   119 status = inSection(14);
   120 string = 'asdldflkj AAA'; // space in middle
   121 actualmatch = string.match(pattern);
   122 expectedmatch = null;  //because of the space
   123 addThis();
   126 pattern = /^(\S+)+(\d+)$/;
   127 status = inSection(15);
   128 string = 'asdldflkj122211';
   129 actualmatch = string.match(pattern);
   130 expectedmatch = Array(string, 'asdldflkj12221', '1');
   131 addThis();
   133 status = inSection(16);
   134 string = 'asdldflkj1111111aaa1';
   135 actualmatch = string.match(pattern);
   136 expectedmatch = Array(string, 'asdldflkj1111111aaa', '1');
   137 addThis();
   140 /*
   141  * This one comes from Stephen Ostermiller.
   142  * See http://bugzilla.mozilla.org/show_bug.cgi?id=69989
   143  */
   144 pattern = /^[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)+$/;
   145 status = inSection(17);
   146 string = 'some.host.tld';
   147 actualmatch = string.match(pattern);
   148 expectedmatch = Array(string, '.tld', '.');
   149 addThis();
   153 //-------------------------------------------------------------------------------------------------
   154 test();
   155 //-------------------------------------------------------------------------------------------------
   159 function addThis()
   160 {
   161   statusmessages[i] = status;
   162   patterns[i] = pattern;
   163   strings[i] = string;
   164   actualmatches[i] = actualmatch;
   165   expectedmatches[i] = expectedmatch;
   166   i++;
   167 }
   170 function test()
   171 {
   172   enterFunc ('test');
   173   printBugNumber(BUGNUMBER);
   174   printStatus (summary);
   175   testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
   176   exitFunc ('test');
   177 }

mercurial