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.
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 | /** |
michael@0 | 8 | * File Name: String/match-001.js |
michael@0 | 9 | * ECMA Section: 15.6.4.9 |
michael@0 | 10 | * Description: Based on ECMA 2 Draft 7 February 1999 |
michael@0 | 11 | * |
michael@0 | 12 | * Author: christine@netscape.com |
michael@0 | 13 | * Date: 19 February 1999 |
michael@0 | 14 | */ |
michael@0 | 15 | |
michael@0 | 16 | /* |
michael@0 | 17 | * String.match( regexp ) |
michael@0 | 18 | * |
michael@0 | 19 | * If regexp is not an object of type RegExp, it is replaced with result |
michael@0 | 20 | * of the expression new RegExp(regexp). Let string denote the result of |
michael@0 | 21 | * converting the this value to a string. If regexp.global is false, |
michael@0 | 22 | * return the result obtained by invoking RegExp.prototype.exec (see |
michael@0 | 23 | * section 15.7.5.3) on regexp with string as parameter. |
michael@0 | 24 | * |
michael@0 | 25 | * Otherwise, set the regexp.lastIndex property to 0 and invoke |
michael@0 | 26 | * RegExp.prototype.exec repeatedly until there is no match. If there is a |
michael@0 | 27 | * match with an empty string (in other words, if the value of |
michael@0 | 28 | * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. |
michael@0 | 29 | * The value returned is an array with the properties 0 through n-1 |
michael@0 | 30 | * corresponding to the first element of the result of each matching |
michael@0 | 31 | * invocation of RegExp.prototype.exec. |
michael@0 | 32 | * |
michael@0 | 33 | * Note that the match function is intentionally generic; it does not |
michael@0 | 34 | * require that its this value be a string object. Therefore, it can be |
michael@0 | 35 | * transferred to other kinds of objects for use as a method. |
michael@0 | 36 | */ |
michael@0 | 37 | |
michael@0 | 38 | var SECTION = "String/match-001.js"; |
michael@0 | 39 | var VERSION = "ECMA_2"; |
michael@0 | 40 | var TITLE = "String.prototype.match( regexp )"; |
michael@0 | 41 | |
michael@0 | 42 | startTest(); |
michael@0 | 43 | |
michael@0 | 44 | // the regexp argument is not a RegExp object |
michael@0 | 45 | // this is not a string object |
michael@0 | 46 | |
michael@0 | 47 | // cases in which the regexp global property is false |
michael@0 | 48 | |
michael@0 | 49 | AddRegExpCases( 3, "3", "1234567890", 1, 2, ["3"] ); |
michael@0 | 50 | |
michael@0 | 51 | // cases in which the regexp object global property is true |
michael@0 | 52 | |
michael@0 | 53 | AddGlobalRegExpCases( /34/g, "/34/g", "343443444", 3, ["34", "34", "34"] ); |
michael@0 | 54 | AddGlobalRegExpCases( /\d{1}/g, "/d{1}/g", "123456abcde7890", 10, |
michael@0 | 55 | ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] ); |
michael@0 | 56 | |
michael@0 | 57 | AddGlobalRegExpCases( /\d{2}/g, "/d{2}/g", "123456abcde7890", 5, |
michael@0 | 58 | ["12", "34", "56", "78", "90"] ); |
michael@0 | 59 | |
michael@0 | 60 | AddGlobalRegExpCases( /\D{2}/g, "/d{2}/g", "123456abcde7890", 2, |
michael@0 | 61 | ["ab", "cd"] ); |
michael@0 | 62 | |
michael@0 | 63 | test(); |
michael@0 | 64 | |
michael@0 | 65 | |
michael@0 | 66 | function AddRegExpCases( |
michael@0 | 67 | regexp, str_regexp, string, length, index, matches_array ) { |
michael@0 | 68 | |
michael@0 | 69 | AddTestCase( |
michael@0 | 70 | "( " + string + " ).match(" + str_regexp +").length", |
michael@0 | 71 | length, |
michael@0 | 72 | string.match(regexp).length ); |
michael@0 | 73 | |
michael@0 | 74 | AddTestCase( |
michael@0 | 75 | "( " + string + " ).match(" + str_regexp +").index", |
michael@0 | 76 | index, |
michael@0 | 77 | string.match(regexp).index ); |
michael@0 | 78 | |
michael@0 | 79 | AddTestCase( |
michael@0 | 80 | "( " + string + " ).match(" + str_regexp +").input", |
michael@0 | 81 | string, |
michael@0 | 82 | string.match(regexp).input ); |
michael@0 | 83 | |
michael@0 | 84 | for ( var matches = 0; matches < matches_array.length; matches++ ) { |
michael@0 | 85 | AddTestCase( |
michael@0 | 86 | "( " + string + " ).match(" + str_regexp +")[" + matches +"]", |
michael@0 | 87 | matches_array[matches], |
michael@0 | 88 | string.match(regexp)[matches] ); |
michael@0 | 89 | } |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | function AddGlobalRegExpCases( |
michael@0 | 93 | regexp, str_regexp, string, length, matches_array ) { |
michael@0 | 94 | |
michael@0 | 95 | AddTestCase( |
michael@0 | 96 | "( " + string + " ).match(" + str_regexp +").length", |
michael@0 | 97 | length, |
michael@0 | 98 | string.match(regexp).length ); |
michael@0 | 99 | |
michael@0 | 100 | for ( var matches = 0; matches < matches_array.length; matches++ ) { |
michael@0 | 101 | AddTestCase( |
michael@0 | 102 | "( " + string + " ).match(" + str_regexp +")[" + matches +"]", |
michael@0 | 103 | matches_array[matches], |
michael@0 | 104 | string.match(regexp)[matches] ); |
michael@0 | 105 | } |
michael@0 | 106 | } |