js/src/tests/ecma_3/RegExp/regress-100199.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: 17 September 2001
     8  *
     9  * SUMMARY: Regression test for Bugzilla bug 100199
    10  * See http://bugzilla.mozilla.org/show_bug.cgi?id=100199
    11  *
    12  * The empty character class [] is a valid RegExp construct: the condition
    13  * that a given character belong to a set containing no characters. As such,
    14  * it can never be met and is always FALSE. Similarly, [^] is a condition
    15  * that matches any given character and is always TRUE.
    16  *
    17  * Neither one of these conditions should cause syntax errors in a RegExp.
    18  */
    19 //-----------------------------------------------------------------------------
    20 var i = 0;
    21 var BUGNUMBER = 100199;
    22 var summary = '[], [^] are valid RegExp conditions. Should not cause errors -';
    23 var status = '';
    24 var statusmessages = new Array();
    25 var pattern = '';
    26 var patterns = new Array();
    27 var string = '';
    28 var strings = new Array();
    29 var actualmatch = '';
    30 var actualmatches = new Array();
    31 var expectedmatch = '';
    32 var expectedmatches = new Array();
    35 pattern = /[]/;
    36 string = 'abc';
    37 status = inSection(1);
    38 actualmatch = string.match(pattern);
    39 expectedmatch = null;
    40 addThis();
    42 string = '';
    43 status = inSection(2);
    44 actualmatch = string.match(pattern);
    45 expectedmatch = null;
    46 addThis();
    48 string = '[';
    49 status = inSection(3);
    50 actualmatch = string.match(pattern);
    51 expectedmatch = null;
    52 addThis();
    54 string = '/';
    55 status = inSection(4);
    56 actualmatch = string.match(pattern);
    57 expectedmatch = null;
    58 addThis();
    60 string = '[';
    61 status = inSection(5);
    62 actualmatch = string.match(pattern);
    63 expectedmatch = null;
    64 addThis();
    66 string = ']';
    67 status = inSection(6);
    68 actualmatch = string.match(pattern);
    69 expectedmatch = null;
    70 addThis();
    72 string = '[]';
    73 status = inSection(7);
    74 actualmatch = string.match(pattern);
    75 expectedmatch = null;
    76 addThis();
    78 string = '[ ]';
    79 status = inSection(8);
    80 actualmatch = string.match(pattern);
    81 expectedmatch = null;
    82 addThis();
    84 string = '][';
    85 status = inSection(9);
    86 actualmatch = string.match(pattern);
    87 expectedmatch = null;
    88 addThis();
    91 pattern = /a[]/;
    92 string = 'abc';
    93 status = inSection(10);
    94 actualmatch = string.match(pattern);
    95 expectedmatch = null;
    96 addThis();
    98 string = '';
    99 status = inSection(11);
   100 actualmatch = string.match(pattern);
   101 expectedmatch = null;
   102 addThis();
   104 string = 'a[';
   105 status = inSection(12);
   106 actualmatch = string.match(pattern);
   107 expectedmatch = null;
   108 addThis();
   110 string = 'a[]';
   111 status = inSection(13);
   112 actualmatch = string.match(pattern);
   113 expectedmatch = null;
   114 addThis();
   116 string = '[';
   117 status = inSection(14);
   118 actualmatch = string.match(pattern);
   119 expectedmatch = null;
   120 addThis();
   122 string = ']';
   123 status = inSection(15);
   124 actualmatch = string.match(pattern);
   125 expectedmatch = null;
   126 addThis();
   128 string = '[]';
   129 status = inSection(16);
   130 actualmatch = string.match(pattern);
   131 expectedmatch = null;
   132 addThis();
   134 string = '[ ]';
   135 status = inSection(17);
   136 actualmatch = string.match(pattern);
   137 expectedmatch = null;
   138 addThis();
   140 string = '][';
   141 status = inSection(18);
   142 actualmatch = string.match(pattern);
   143 expectedmatch = null;
   144 addThis();
   147 pattern = /[^]/;
   148 string = 'abc';
   149 status = inSection(19);
   150 actualmatch = string.match(pattern);
   151 expectedmatch = Array('a');
   152 addThis();
   154 string = '';
   155 status = inSection(20);
   156 actualmatch = string.match(pattern);
   157 expectedmatch = null; //there are no characters to test against the condition
   158 addThis();
   160 string = '\/';
   161 status = inSection(21);
   162 actualmatch = string.match(pattern);
   163 expectedmatch = Array('/');
   164 addThis();
   166 string = '\[';
   167 status = inSection(22);
   168 actualmatch = string.match(pattern);
   169 expectedmatch = Array('[');
   170 addThis();
   172 string = '[';
   173 status = inSection(23);
   174 actualmatch = string.match(pattern);
   175 expectedmatch = Array('[');
   176 addThis();
   178 string = ']';
   179 status = inSection(24);
   180 actualmatch = string.match(pattern);
   181 expectedmatch = Array(']');
   182 addThis();
   184 string = '[]';
   185 status = inSection(25);
   186 actualmatch = string.match(pattern);
   187 expectedmatch = Array('[');
   188 addThis();
   190 string = '[ ]';
   191 status = inSection(26);
   192 actualmatch = string.match(pattern);
   193 expectedmatch = Array('[');
   194 addThis();
   196 string = '][';
   197 status = inSection(27);
   198 actualmatch = string.match(pattern);
   199 expectedmatch = Array(']');
   200 addThis();
   203 pattern = /a[^]/;
   204 string = 'abc';
   205 status = inSection(28);
   206 actualmatch = string.match(pattern);
   207 expectedmatch = Array('ab');
   208 addThis();
   210 string = '';
   211 status = inSection(29);
   212 actualmatch = string.match(pattern);
   213 expectedmatch = null; //there are no characters to test against the condition
   214 addThis();
   216 string = 'a[';
   217 status = inSection(30);
   218 actualmatch = string.match(pattern);
   219 expectedmatch = Array('a[');
   220 addThis();
   222 string = 'a]';
   223 status = inSection(31);
   224 actualmatch = string.match(pattern);
   225 expectedmatch = Array('a]');
   226 addThis();
   228 string = 'a[]';
   229 status = inSection(32);
   230 actualmatch = string.match(pattern);
   231 expectedmatch = Array('a[');
   232 addThis();
   234 string = 'a[ ]';
   235 status = inSection(33);
   236 actualmatch = string.match(pattern);
   237 expectedmatch = Array('a[');
   238 addThis();
   240 string = 'a][';
   241 status = inSection(34);
   242 actualmatch = string.match(pattern);
   243 expectedmatch = Array('a]');
   244 addThis();
   249 //-----------------------------------------------------------------------------
   250 test();
   251 //-----------------------------------------------------------------------------
   255 function addThis()
   256 {
   257   statusmessages[i] = status;
   258   patterns[i] = pattern;
   259   strings[i] = string;
   260   actualmatches[i] = actualmatch;
   261   expectedmatches[i] = expectedmatch;
   262   i++;
   263 }
   266 function test()
   267 {
   268   enterFunc ('test');
   269   printBugNumber(BUGNUMBER);
   270   printStatus (summary);
   271   testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
   272   exitFunc ('test');
   273 }

mercurial