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 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=914405 |
michael@0 | 5 | |
michael@0 | 6 | Debugger.prototype.makeGlobalObjectReference should dereference WindowProxy |
michael@0 | 7 | (outer window) objects. |
michael@0 | 8 | --> |
michael@0 | 9 | <head> |
michael@0 | 10 | <meta charset="utf-8"> |
michael@0 | 11 | <title>Mozilla Bug 914405</title> |
michael@0 | 12 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 13 | <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> |
michael@0 | 14 | </head> |
michael@0 | 15 | <body> |
michael@0 | 16 | <pre id="test"> |
michael@0 | 17 | <script> |
michael@0 | 18 | |
michael@0 | 19 | Components.utils.import("resource://gre/modules/jsdebugger.jsm"); |
michael@0 | 20 | addDebuggerToGlobal(this); |
michael@0 | 21 | |
michael@0 | 22 | window.onload = function () { |
michael@0 | 23 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 24 | |
michael@0 | 25 | var iframe = document.createElement("iframe"); |
michael@0 | 26 | iframe.src = "data:text/html,<html>The word 'smorgasbord', spoken by an adorably plump child, symbolizing prosperity</html>"; |
michael@0 | 27 | iframe.onload = iframeOnLoad; |
michael@0 | 28 | document.body.appendChild(iframe); |
michael@0 | 29 | |
michael@0 | 30 | function iframeOnLoad() { |
michael@0 | 31 | var dbg = new Debugger; |
michael@0 | 32 | |
michael@0 | 33 | var g1o = iframe.contentWindow; // 'o' for 'outer window' |
michael@0 | 34 | ok(!dbg.hasDebuggee(g1o), "iframe is not initially a debuggee"); |
michael@0 | 35 | |
michael@0 | 36 | // Like addDebuggee, makeGlobalObjectReference innerizes. |
michael@0 | 37 | // 'i' stands for 'inner window'. |
michael@0 | 38 | // 'DO' stands for 'Debugger.Object'. |
michael@0 | 39 | var g1iDO = dbg.makeGlobalObjectReference(g1o); |
michael@0 | 40 | ok(!dbg.hasDebuggee(g1o), "makeGlobalObjectReference does not add g1 as debuggee, designated via outer"); |
michael@0 | 41 | ok(!dbg.hasDebuggee(g1iDO), "makeGlobalObjectReference does not add g1 as debuggee, designated via D.O "); |
michael@0 | 42 | |
michael@0 | 43 | // Wrapping an object automatically outerizes it, so dereferencing an |
michael@0 | 44 | // inner object D.O gets you an outer object. |
michael@0 | 45 | // ('===' does distinguish inner and outer objects.) |
michael@0 | 46 | // (That's a capital '=', if you must know.) |
michael@0 | 47 | ok(g1iDO.unsafeDereference() === g1o, "g1iDO has the right referent"); |
michael@0 | 48 | |
michael@0 | 49 | // However, Debugger.Objects do distinguish inner and outer windows. |
michael@0 | 50 | var g1oDO = g1iDO.makeDebuggeeValue(g1o); |
michael@0 | 51 | ok(g1iDO !== g1oDO, "makeDebuggeeValue doesn't innerize"); |
michael@0 | 52 | ok(g1iDO.unsafeDereference() === g1oDO.unsafeDereference(), |
michael@0 | 53 | "unsafeDereference() outerizes, so inner and outer window D.Os both dereference to outer"); |
michael@0 | 54 | |
michael@0 | 55 | ok(dbg.addDebuggee(g1o) === g1iDO, "addDebuggee returns the inner window's D.O"); |
michael@0 | 56 | ok(dbg.hasDebuggee(g1o), "addDebuggee adds the correct global"); |
michael@0 | 57 | ok(dbg.hasDebuggee(g1iDO), "hasDebuggee can take a D.O referring to the inner window"); |
michael@0 | 58 | ok(dbg.hasDebuggee(g1oDO), "hasDebuggee can take a D.O referring to the outer window"); |
michael@0 | 59 | |
michael@0 | 60 | var iframe2 = document.createElement("iframe"); |
michael@0 | 61 | iframe2.src = "data:text/html,<html>Her retrospection, in hindsight, was prescient.</html>"; |
michael@0 | 62 | iframe2.onload = iframe2OnLoad; |
michael@0 | 63 | document.body.appendChild(iframe2); |
michael@0 | 64 | |
michael@0 | 65 | function iframe2OnLoad() { |
michael@0 | 66 | // makeGlobalObjectReference dereferences CCWs. |
michael@0 | 67 | var g2o = iframe2.contentWindow; |
michael@0 | 68 | g2o.g1o = g1o; |
michael@0 | 69 | |
michael@0 | 70 | var g2iDO = dbg.addDebuggee(g2o); |
michael@0 | 71 | var g2g1oDO = g2iDO.getOwnPropertyDescriptor('g1o').value; |
michael@0 | 72 | ok(g2g1oDO !== g1oDO, "g2's cross-compartment wrapper for g1o gets its own D.O"); |
michael@0 | 73 | ok(g2g1oDO.unwrap() === g1oDO, |
michael@0 | 74 | "unwrapping g2's cross-compartment wrapper for g1o gets the right D.O"); |
michael@0 | 75 | ok(dbg.makeGlobalObjectReference(g2g1oDO) === g1iDO, |
michael@0 | 76 | "makeGlobalObjectReference unwraps cross-compartment wrappers, and innerizes"); |
michael@0 | 77 | |
michael@0 | 78 | SimpleTest.finish(); |
michael@0 | 79 | } |
michael@0 | 80 | } |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | </script> |
michael@0 | 84 | </pre> |
michael@0 | 85 | </body> |
michael@0 | 86 | </html> |