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 | * This test is identical to test 15.10.3.1-1.js, except here we do: |
michael@0 | 30 | * |
michael@0 | 31 | * RegExp(R, undefined); |
michael@0 | 32 | * |
michael@0 | 33 | * instead of: |
michael@0 | 34 | * |
michael@0 | 35 | * RegExp(R); |
michael@0 | 36 | * |
michael@0 | 37 | * |
michael@0 | 38 | * We check that RegExp(R, undefined) returns R - |
michael@0 | 39 | */ |
michael@0 | 40 | //----------------------------------------------------------------------------- |
michael@0 | 41 | var BUGNUMBER = '61266'; |
michael@0 | 42 | var summary = 'Passing (RegExp object,flag) to RegExp() function'; |
michael@0 | 43 | var statprefix = 'RegExp(new RegExp('; |
michael@0 | 44 | var comma = ', '; var singlequote = "'"; var closeparens = '))'; |
michael@0 | 45 | var cnSUCCESS = 'RegExp() returned the supplied RegExp object'; |
michael@0 | 46 | var cnFAILURE = 'RegExp() did NOT return the supplied RegExp object'; |
michael@0 | 47 | var i = -1; var j = -1; var s = ''; var f = ''; |
michael@0 | 48 | var obj = {}; |
michael@0 | 49 | var status = ''; var actual = ''; var expect = ''; |
michael@0 | 50 | var patterns = new Array(); |
michael@0 | 51 | var flags = new Array(); |
michael@0 | 52 | |
michael@0 | 53 | |
michael@0 | 54 | // various regular expressions to try - |
michael@0 | 55 | patterns[0] = ''; |
michael@0 | 56 | patterns[1] = 'abc'; |
michael@0 | 57 | patterns[2] = '(.*)(3-1)\s\w'; |
michael@0 | 58 | patterns[3] = '(.*)(...)\\s\\w'; |
michael@0 | 59 | patterns[4] = '[^A-Za-z0-9_]'; |
michael@0 | 60 | patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; |
michael@0 | 61 | |
michael@0 | 62 | // various flags to try - |
michael@0 | 63 | flags[0] = 'i'; |
michael@0 | 64 | flags[1] = 'g'; |
michael@0 | 65 | flags[2] = 'm'; |
michael@0 | 66 | flags[3] = undefined; |
michael@0 | 67 | |
michael@0 | 68 | |
michael@0 | 69 | |
michael@0 | 70 | //------------------------------------------------------------------------------------------------- |
michael@0 | 71 | test(); |
michael@0 | 72 | //------------------------------------------------------------------------------------------------- |
michael@0 | 73 | |
michael@0 | 74 | |
michael@0 | 75 | function test() |
michael@0 | 76 | { |
michael@0 | 77 | enterFunc ('test'); |
michael@0 | 78 | printBugNumber(BUGNUMBER); |
michael@0 | 79 | printStatus (summary); |
michael@0 | 80 | |
michael@0 | 81 | for (i in patterns) |
michael@0 | 82 | { |
michael@0 | 83 | s = patterns[i]; |
michael@0 | 84 | |
michael@0 | 85 | for (j in flags) |
michael@0 | 86 | { |
michael@0 | 87 | f = flags[j]; |
michael@0 | 88 | status = getStatus(s, f); |
michael@0 | 89 | obj = new RegExp(s, f); |
michael@0 | 90 | |
michael@0 | 91 | actual = (obj == RegExp(obj, undefined))? cnSUCCESS : cnFAILURE ; |
michael@0 | 92 | expect = cnSUCCESS; |
michael@0 | 93 | reportCompare (expect, actual, status); |
michael@0 | 94 | } |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | exitFunc ('test'); |
michael@0 | 98 | } |
michael@0 | 99 | |
michael@0 | 100 | |
michael@0 | 101 | function getStatus(regexp, flag) |
michael@0 | 102 | { |
michael@0 | 103 | return (statprefix + quote(regexp) + comma + flag + closeparens); |
michael@0 | 104 | } |
michael@0 | 105 | |
michael@0 | 106 | |
michael@0 | 107 | function quote(text) |
michael@0 | 108 | { |
michael@0 | 109 | return (singlequote + text + singlequote); |
michael@0 | 110 | } |