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 // Any copyright is dedicated to the Public Domain.
2 // http://creativecommons.org/licenses/publicdomain/
3 // Contributor: Jim Blandy
5 if (typeof findReferences == "function") {
6 function C() {}
7 var o = new C;
8 o.x = {}; // via ordinary property
9 o[42] = {}; // via numeric property
10 o[123456789] = {}; // via ridiculous numeric property
11 o.myself = o; // self-references should be reported
12 o.alsoMyself = o; // multiple self-references should all be reported
14 assertEq(referencesVia(o, 'type; type_proto', C.prototype), true);
15 assertEq(referencesVia(o, 'shape; base; parent', this), true);
16 assertEq(referencesVia(o, 'x', o.x), true);
17 assertEq(referencesVia(o, 'objectElements[42]', o[42]), true);
18 assertEq(referencesVia(o, '123456789', o[123456789]), true);
19 assertEq(referencesVia(o, 'myself', o), true);
20 assertEq(referencesVia(o, 'alsoMyself', o), true);
22 function g() { return 42; }
23 function s(v) { }
24 var p = Object.defineProperty({}, 'a', { get:g, set:s });
25 assertEq(referencesVia(p, 'shape; base; getter', g), true);
26 assertEq(referencesVia(p, 'shape; base; setter', s), true);
28 // If there are multiple objects with the same shape referring to a getter
29 // or setter, findReferences should get all of them, even though the shape
30 // gets 'marked' the first time we visit it.
31 var q = Object.defineProperty({}, 'a', { get:g, set:s });
32 assertEq(referencesVia(p, 'shape; base; getter', g), true);
33 assertEq(referencesVia(q, 'shape; base; getter', g), true);
35 // If we extend each object's shape chain, both should still be able to
36 // reach the getter, even though the two shapes are each traversed twice.
37 p.b = 9;
38 q.b = 9;
39 assertEq(referencesVia(p, 'shape; parent; base; getter', g), true);
40 assertEq(referencesVia(q, 'shape; parent; base; getter', g), true);
42 // These are really just ordinary own property references.
43 assertEq(referencesVia(C, 'prototype', Object.getPrototypeOf(o)), true);
44 assertEq(referencesVia(Object.getPrototypeOf(o), 'constructor', C), true);
46 // Dense arrays should work, too.
47 a = [];
48 a[1] = o;
49 assertEq(referencesVia(a, 'objectElements[1]', o), true);
51 reportCompare(true, true);
52 } else {
53 reportCompare(true, true, "test skipped: findReferences is not a function");
54 }