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.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /*
michael@0 7 * Date: 06 February 2001
michael@0 8 *
michael@0 9 * SUMMARY: Arose from Bugzilla bug 67773:
michael@0 10 * "Regular subexpressions followed by + failing to run to completion"
michael@0 11 *
michael@0 12 * See http://bugzilla.mozilla.org/show_bug.cgi?id=67773
michael@0 13 * See http://bugzilla.mozilla.org/show_bug.cgi?id=69989
michael@0 14 */
michael@0 15 //-----------------------------------------------------------------------------
michael@0 16 var i = 0;
michael@0 17 var BUGNUMBER = 67773;
michael@0 18 var summary = 'Testing regular subexpressions followed by ? or +\n';
michael@0 19 var cnSingleSpace = ' ';
michael@0 20 var status = '';
michael@0 21 var statusmessages = new Array();
michael@0 22 var pattern = '';
michael@0 23 var patterns = new Array();
michael@0 24 var string = '';
michael@0 25 var strings = new Array();
michael@0 26 var actualmatch = '';
michael@0 27 var actualmatches = new Array();
michael@0 28 var expectedmatch = '';
michael@0 29 var expectedmatches = new Array();
michael@0 30
michael@0 31
michael@0 32 pattern = /^(\S+)?( ?)(B+)$/; //single space before second ? character
michael@0 33 status = inSection(1);
michael@0 34 string = 'AAABBB AAABBB '; //single space at middle and at end -
michael@0 35 actualmatch = string.match(pattern);
michael@0 36 expectedmatch = null;
michael@0 37 addThis();
michael@0 38
michael@0 39 status = inSection(2);
michael@0 40 string = 'AAABBB BBB'; //single space in the middle
michael@0 41 actualmatch = string.match(pattern);
michael@0 42 expectedmatch = Array(string, 'AAABBB', cnSingleSpace, 'BBB');
michael@0 43 addThis();
michael@0 44
michael@0 45 status = inSection(3);
michael@0 46 string = 'AAABBB AAABBB'; //single space in the middle
michael@0 47 actualmatch = string.match(pattern);
michael@0 48 expectedmatch = null;
michael@0 49 addThis();
michael@0 50
michael@0 51
michael@0 52 pattern = /^(A+B)+$/;
michael@0 53 status = inSection(4);
michael@0 54 string = 'AABAAB';
michael@0 55 actualmatch = string.match(pattern);
michael@0 56 expectedmatch = Array(string, 'AAB');
michael@0 57 addThis();
michael@0 58
michael@0 59 status = inSection(5);
michael@0 60 string = 'ABAABAAAAAAB';
michael@0 61 actualmatch = string.match(pattern);
michael@0 62 expectedmatch = Array(string, 'AAAAAAB');
michael@0 63 addThis();
michael@0 64
michael@0 65 status = inSection(6);
michael@0 66 string = 'ABAABAABAB';
michael@0 67 actualmatch = string.match(pattern);
michael@0 68 expectedmatch = Array(string, 'AB');
michael@0 69 addThis();
michael@0 70
michael@0 71 status = inSection(7);
michael@0 72 string = 'ABAABAABABB';
michael@0 73 actualmatch = string.match(pattern);
michael@0 74 expectedmatch = null; // because string doesn't match at end
michael@0 75 addThis();
michael@0 76
michael@0 77
michael@0 78 pattern = /^(A+1)+$/;
michael@0 79 status = inSection(8);
michael@0 80 string = 'AA1AA1';
michael@0 81 actualmatch = string.match(pattern);
michael@0 82 expectedmatch = Array(string, 'AA1');
michael@0 83 addThis();
michael@0 84
michael@0 85
michael@0 86 pattern = /^(\w+\-)+$/;
michael@0 87 status = inSection(9);
michael@0 88 string = '';
michael@0 89 actualmatch = string.match(pattern);
michael@0 90 expectedmatch = null;
michael@0 91 addThis();
michael@0 92
michael@0 93 status = inSection(10);
michael@0 94 string = 'bla-';
michael@0 95 actualmatch = string.match(pattern);
michael@0 96 expectedmatch = Array(string, string);
michael@0 97 addThis();
michael@0 98
michael@0 99 status = inSection(11);
michael@0 100 string = 'bla-bla'; // hyphen missing at end -
michael@0 101 actualmatch = string.match(pattern);
michael@0 102 expectedmatch = null; //because string doesn't match at end
michael@0 103 addThis();
michael@0 104
michael@0 105 status = inSection(12);
michael@0 106 string = 'bla-bla-';
michael@0 107 actualmatch = string.match(pattern);
michael@0 108 expectedmatch = Array(string, 'bla-');
michael@0 109 addThis();
michael@0 110
michael@0 111
michael@0 112 pattern = /^(\S+)+(A+)$/;
michael@0 113 status = inSection(13);
michael@0 114 string = 'asdldflkjAAA';
michael@0 115 actualmatch = string.match(pattern);
michael@0 116 expectedmatch = Array(string, 'asdldflkjAA', 'A');
michael@0 117 addThis();
michael@0 118
michael@0 119 status = inSection(14);
michael@0 120 string = 'asdldflkj AAA'; // space in middle
michael@0 121 actualmatch = string.match(pattern);
michael@0 122 expectedmatch = null; //because of the space
michael@0 123 addThis();
michael@0 124
michael@0 125
michael@0 126 pattern = /^(\S+)+(\d+)$/;
michael@0 127 status = inSection(15);
michael@0 128 string = 'asdldflkj122211';
michael@0 129 actualmatch = string.match(pattern);
michael@0 130 expectedmatch = Array(string, 'asdldflkj12221', '1');
michael@0 131 addThis();
michael@0 132
michael@0 133 status = inSection(16);
michael@0 134 string = 'asdldflkj1111111aaa1';
michael@0 135 actualmatch = string.match(pattern);
michael@0 136 expectedmatch = Array(string, 'asdldflkj1111111aaa', '1');
michael@0 137 addThis();
michael@0 138
michael@0 139
michael@0 140 /*
michael@0 141 * This one comes from Stephen Ostermiller.
michael@0 142 * See http://bugzilla.mozilla.org/show_bug.cgi?id=69989
michael@0 143 */
michael@0 144 pattern = /^[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)+$/;
michael@0 145 status = inSection(17);
michael@0 146 string = 'some.host.tld';
michael@0 147 actualmatch = string.match(pattern);
michael@0 148 expectedmatch = Array(string, '.tld', '.');
michael@0 149 addThis();
michael@0 150
michael@0 151
michael@0 152
michael@0 153 //-------------------------------------------------------------------------------------------------
michael@0 154 test();
michael@0 155 //-------------------------------------------------------------------------------------------------
michael@0 156
michael@0 157
michael@0 158
michael@0 159 function addThis()
michael@0 160 {
michael@0 161 statusmessages[i] = status;
michael@0 162 patterns[i] = pattern;
michael@0 163 strings[i] = string;
michael@0 164 actualmatches[i] = actualmatch;
michael@0 165 expectedmatches[i] = expectedmatch;
michael@0 166 i++;
michael@0 167 }
michael@0 168
michael@0 169
michael@0 170 function test()
michael@0 171 {
michael@0 172 enterFunc ('test');
michael@0 173 printBugNumber(BUGNUMBER);
michael@0 174 printStatus (summary);
michael@0 175 testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
michael@0 176 exitFunc ('test');
michael@0 177 }

mercurial