js/xpconnect/tests/mochitest/file_bug802557.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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

mercurial