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 <!DOCTYPE html>
2 <html>
3 <head>
4 <script>
5 var gTS = window.location.toString;
6 var gGHR = Object.__lookupGetter__.call(window.location, 'href');
7 function getTests(fromOuter) {
9 function loc() fromOuter ? window.location : location;
10 return {
11 getLocationImplicit: function() {
12 return loc() + "";
13 },
14 getLocationExplicit: function() {
15 return loc().toString();
16 },
17 getLocationApply1: function() {
18 return gTS.call(loc());
19 },
20 getLocationApply2: function() {
21 return gTS.apply(loc(), []);
22 },
23 getLocationApply3: function() {
24 return Function.call.apply(gTS, [loc()]);
25 },
26 getLocationViaPrototype: function() {
27 return Location.prototype.toString.call(loc());
28 },
29 getHref: function() {
30 return loc().href;
31 },
32 getHrefViaApply: function() {
33 return Function.call.apply(gGHR, [loc()]);
34 },
35 getHrefViaPrototype: function() {
36 return Object.getOwnPropertyDescriptor(Location.prototype, 'href').get.call(loc());
37 }
38 }
39 };
41 function mungeNames(obj, suffix) {
42 var rv = {};
43 Object.getOwnPropertyNames(obj)
44 .forEach(function (name) rv[name + suffix] = obj[name]);
45 return rv;
46 }
48 function mergeObjects(a, b) {
49 var rv = {};
50 Object.getOwnPropertyNames(a).forEach(function(name) rv[name] = a[name]);
51 Object.getOwnPropertyNames(b).forEach(function(name) rv[name] = b[name]);
52 return rv;
53 }
55 function getAllTests() {
56 var innerTests = getTests(false);
57 var outerTests = getTests(true);
58 return mergeObjects(mungeNames(innerTests, '_inner'),
59 mungeNames(outerTests, '_outer'));
60 }
62 </script>
63 </head>
64 <body>
65 </body>
66 </html>