Sat, 03 Jan 2015 20:18:00 +0100
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: String/match-003.js
9 * ECMA Section: 15.6.4.9
10 * Description: Based on ECMA 2 Draft 7 February 1999
11 *
12 * Author: christine@netscape.com
13 * Date: 19 February 1999
14 */
16 /*
17 * String.match( regexp )
18 *
19 * If regexp is not an object of type RegExp, it is replaced with result
20 * of the expression new RegExp(regexp). Let string denote the result of
21 * converting the this value to a string. If regexp.global is false,
22 * return the result obtained by invoking RegExp.prototype.exec (see
23 * section 15.7.5.3) on regexp with string as parameter.
24 *
25 * Otherwise, set the regexp.lastIndex property to 0 and invoke
26 * RegExp.prototype.exec repeatedly until there is no match. If there is a
27 * match with an empty string (in other words, if the value of
28 * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1.
29 * The value returned is an array with the properties 0 through n-1
30 * corresponding to the first element of the result of each matching
31 * invocation of RegExp.prototype.exec.
32 *
33 * Note that the match function is intentionally generic; it does not
34 * require that its this value be a string object. Therefore, it can be
35 * transferred to other kinds of objects for use as a method.
36 */
38 var SECTION = "String/match-003.js";
39 var VERSION = "ECMA_2";
40 var TITLE = "String.prototype.match( regexp )";
42 startTest();
44 // the regexp argument is not a RegExp object
45 // this is not a string object
48 // [if regexp.global is true] set the regexp.lastIndex property to 0 and
49 // invoke RegExp.prototype.exec repeatedly until there is no match. If
50 // there is a match with an empty string (in other words, if the value of
51 // regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1.
52 // The value returned is an array with the properties 0 through n-1
53 // corresponding to the first element of the result of each matching invocation
54 // of RegExp.prototype.exec.
57 // set the value of lastIndex
58 re = /([\d]{5})([-\ ]?[\d]{4})?$/g;
61 s = "Boston, MA 02134";
63 AddGlobalRegExpCases( re,
64 "re = " + re,
65 s,
66 ["02134" ]);
68 re.lastIndex = 0;
70 AddGlobalRegExpCases(
71 re,
72 "re = " + re + "; re.lastIndex = 0 ",
73 s,
74 ["02134"]);
77 re.lastIndex = s.length;
79 AddGlobalRegExpCases(
80 re,
81 "re = " + re + "; re.lastIndex = " + s.length,
82 s,
83 ["02134"] );
85 re.lastIndex = s.lastIndexOf("0");
87 AddGlobalRegExpCases(
88 re,
89 "re = "+ re +"; re.lastIndex = " + s.lastIndexOf("0"),
90 s,
91 ["02134"]);
93 re.lastIndex = s.lastIndexOf("0") + 1;
95 AddGlobalRegExpCases(
96 re,
97 "re = " +re+ "; re.lastIndex = " + (s.lastIndexOf("0") +1),
98 s,
99 ["02134"]);
101 test();
103 function AddGlobalRegExpCases(
104 regexp, str_regexp, string, matches_array ) {
106 // prevent a runtime error
108 if ( string.match(regexp) == null || matches_array == null ) {
109 AddTestCase(
110 string + ".match(" + str_regexp +")",
111 matches_array,
112 string.match(regexp) );
114 return;
115 }
117 AddTestCase(
118 "( " + string + " ).match(" + str_regexp +").length",
119 matches_array.length,
120 string.match(regexp).length );
122 var limit = matches_array.length > string.match(regexp).length ?
123 matches_array.length :
124 string.match(regexp).length;
126 for ( var matches = 0; matches < limit; matches++ ) {
127 AddTestCase(
128 "( " + string + " ).match(" + str_regexp +")[" + matches +"]",
129 matches_array[matches],
130 string.match(regexp)[matches] );
131 }
132 }