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 a RegExp object to a RegExp() constructor. |
michael@0 | 11 | *This test arose from Bugzilla bug 61266. The ECMA3 section is: |
michael@0 | 12 | * |
michael@0 | 13 | * 15.10.4.1 new RegExp(pattern, flags) |
michael@0 | 14 | * |
michael@0 | 15 | * If pattern is an object R whose [[Class]] property is "RegExp" and |
michael@0 | 16 | * flags is undefined, then let P be the pattern used to construct R |
michael@0 | 17 | * and let F be the flags used to construct R. If pattern is an object R |
michael@0 | 18 | * whose [[Class]] property is "RegExp" and flags is not undefined, |
michael@0 | 19 | * then throw a TypeError exception. Otherwise, let P be the empty string |
michael@0 | 20 | * if pattern is undefined and ToString(pattern) otherwise, and let F be |
michael@0 | 21 | * the empty string if flags is undefined and ToString(flags) otherwise. |
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 | * We check that a new RegExp object obj2 defined from these parameters |
michael@0 | 30 | * is morally the same as the original RegExp object obj1. Of course, they |
michael@0 | 31 | * can't be equal as objects - so we check their enumerable properties... |
michael@0 | 32 | * |
michael@0 | 33 | * In this test, the initial RegExp object obj1 will not include a |
michael@0 | 34 | * flag. The flags parameter for obj2 will be undefined in the sense |
michael@0 | 35 | * of not being provided. |
michael@0 | 36 | */ |
michael@0 | 37 | //----------------------------------------------------------------------------- |
michael@0 | 38 | var BUGNUMBER = '61266'; |
michael@0 | 39 | var summary = 'Passing a RegExp object to a RegExp() constructor'; |
michael@0 | 40 | var statprefix = 'Applying RegExp() twice to pattern '; |
michael@0 | 41 | var statsuffix = '; testing property '; |
michael@0 | 42 | var singlequote = "'"; |
michael@0 | 43 | var i = -1; var s = ''; |
michael@0 | 44 | var obj1 = {}; var obj2 = {}; |
michael@0 | 45 | var status = ''; var actual = ''; var expect = ''; var msg = ''; |
michael@0 | 46 | var patterns = new Array(); |
michael@0 | 47 | |
michael@0 | 48 | |
michael@0 | 49 | // various regular expressions to try - |
michael@0 | 50 | patterns[0] = ''; |
michael@0 | 51 | patterns[1] = 'abc'; |
michael@0 | 52 | patterns[2] = '(.*)(3-1)\s\w'; |
michael@0 | 53 | patterns[3] = '(.*)(...)\\s\\w'; |
michael@0 | 54 | patterns[4] = '[^A-Za-z0-9_]'; |
michael@0 | 55 | patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; |
michael@0 | 56 | |
michael@0 | 57 | |
michael@0 | 58 | |
michael@0 | 59 | //----------------------------------------------------------------------------- |
michael@0 | 60 | test(); |
michael@0 | 61 | //----------------------------------------------------------------------------- |
michael@0 | 62 | |
michael@0 | 63 | |
michael@0 | 64 | function test() |
michael@0 | 65 | { |
michael@0 | 66 | enterFunc ('test'); |
michael@0 | 67 | printBugNumber(BUGNUMBER); |
michael@0 | 68 | printStatus (summary); |
michael@0 | 69 | |
michael@0 | 70 | for (i in patterns) |
michael@0 | 71 | { |
michael@0 | 72 | s = patterns[i]; |
michael@0 | 73 | status =getStatus(s); |
michael@0 | 74 | obj1 = new RegExp(s); |
michael@0 | 75 | obj2 = new RegExp(obj1); |
michael@0 | 76 | |
michael@0 | 77 | reportCompare (obj1 + '', obj2 + '', status); |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | exitFunc ('test'); |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | |
michael@0 | 84 | function getStatus(regexp) |
michael@0 | 85 | { |
michael@0 | 86 | return (statprefix + quote(regexp) + statsuffix); |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | |
michael@0 | 90 | function quote(text) |
michael@0 | 91 | { |
michael@0 | 92 | return (singlequote + text + singlequote); |
michael@0 | 93 | } |