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 | * Date: 26 November 2000 |
michael@0 | 8 | * |
michael@0 | 9 | * |
michael@0 | 10 | * SUMMARY: Passing (RegExp object, flag) to RegExp() function. |
michael@0 | 11 | * This test arose from Bugzilla bug 61266. The ECMA3 section is: |
michael@0 | 12 | * |
michael@0 | 13 | * 15.10.3 The RegExp Constructor Called as a Function |
michael@0 | 14 | * |
michael@0 | 15 | * 15.10.3.1 RegExp(pattern, flags) |
michael@0 | 16 | * |
michael@0 | 17 | * If pattern is an object R whose [[Class]] property is "RegExp" |
michael@0 | 18 | * and flags is undefined, then return R unchanged. Otherwise |
michael@0 | 19 | * call the RegExp constructor (section 15.10.4.1), passing it the |
michael@0 | 20 | * pattern and flags arguments and return the object constructed |
michael@0 | 21 | * by that constructor. |
michael@0 | 22 | * |
michael@0 | 23 | * |
michael@0 | 24 | * The current test will check the first scenario outlined above: |
michael@0 | 25 | * |
michael@0 | 26 | * "pattern" is itself a RegExp object R |
michael@0 | 27 | * "flags" is undefined |
michael@0 | 28 | * |
michael@0 | 29 | * The flags parameter will be undefined in the sense of not being |
michael@0 | 30 | * provided. We check that RegExp(R) returns R - |
michael@0 | 31 | */ |
michael@0 | 32 | //----------------------------------------------------------------------------- |
michael@0 | 33 | var BUGNUMBER = '61266'; |
michael@0 | 34 | var summary = 'Passing (RegExp object,flag) to RegExp() function'; |
michael@0 | 35 | var statprefix = 'RegExp(new RegExp('; |
michael@0 | 36 | var comma = ', '; var singlequote = "'"; var closeparens = '))'; |
michael@0 | 37 | var cnSUCCESS = 'RegExp() returned the supplied RegExp object'; |
michael@0 | 38 | var cnFAILURE = 'RegExp() did NOT return the supplied RegExp object'; |
michael@0 | 39 | var i = -1; var j = -1; var s = ''; var f = ''; |
michael@0 | 40 | var obj = {}; |
michael@0 | 41 | var status = ''; var actual = ''; var expect = ''; |
michael@0 | 42 | var patterns = new Array(); |
michael@0 | 43 | var flags = new Array(); |
michael@0 | 44 | |
michael@0 | 45 | |
michael@0 | 46 | // various regular expressions to try - |
michael@0 | 47 | patterns[0] = ''; |
michael@0 | 48 | patterns[1] = 'abc'; |
michael@0 | 49 | patterns[2] = '(.*)(3-1)\s\w'; |
michael@0 | 50 | patterns[3] = '(.*)(...)\\s\\w'; |
michael@0 | 51 | patterns[4] = '[^A-Za-z0-9_]'; |
michael@0 | 52 | patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; |
michael@0 | 53 | |
michael@0 | 54 | // various flags to try - |
michael@0 | 55 | flags[0] = 'i'; |
michael@0 | 56 | flags[1] = 'g'; |
michael@0 | 57 | flags[2] = 'm'; |
michael@0 | 58 | flags[3] = undefined; |
michael@0 | 59 | |
michael@0 | 60 | |
michael@0 | 61 | |
michael@0 | 62 | //------------------------------------------------------------------------------------------------- |
michael@0 | 63 | test(); |
michael@0 | 64 | //------------------------------------------------------------------------------------------------- |
michael@0 | 65 | |
michael@0 | 66 | |
michael@0 | 67 | function test() |
michael@0 | 68 | { |
michael@0 | 69 | enterFunc ('test'); |
michael@0 | 70 | printBugNumber(BUGNUMBER); |
michael@0 | 71 | printStatus (summary); |
michael@0 | 72 | |
michael@0 | 73 | for (i in patterns) |
michael@0 | 74 | { |
michael@0 | 75 | s = patterns[i]; |
michael@0 | 76 | |
michael@0 | 77 | for (j in flags) |
michael@0 | 78 | { |
michael@0 | 79 | f = flags[j]; |
michael@0 | 80 | status = getStatus(s, f); |
michael@0 | 81 | obj = new RegExp(s, f); |
michael@0 | 82 | |
michael@0 | 83 | actual = (obj == RegExp(obj))? cnSUCCESS : cnFAILURE; |
michael@0 | 84 | expect = cnSUCCESS; |
michael@0 | 85 | reportCompare (expect, actual, status); |
michael@0 | 86 | } |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | exitFunc ('test'); |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | |
michael@0 | 93 | function getStatus(regexp, flag) |
michael@0 | 94 | { |
michael@0 | 95 | return (statprefix + quote(regexp) + comma + flag + closeparens); |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | |
michael@0 | 99 | function quote(text) |
michael@0 | 100 | { |
michael@0 | 101 | return (singlequote + text + singlequote); |
michael@0 | 102 | } |