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 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet type="text/css" href="chrome://global/skin"?> |
michael@0 | 3 | <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> |
michael@0 | 4 | <!-- |
michael@0 | 5 | https://bugzilla.mozilla.org/show_bug.cgi?id=732665 |
michael@0 | 6 | --> |
michael@0 | 7 | <window title="Mozilla Bug 732665" |
michael@0 | 8 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 9 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
michael@0 | 10 | |
michael@0 | 11 | <!-- test results are displayed in the html:body --> |
michael@0 | 12 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 13 | <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=732665" |
michael@0 | 14 | target="_blank">Mozilla Bug 732665</a> |
michael@0 | 15 | </body> |
michael@0 | 16 | |
michael@0 | 17 | <!-- test code goes here --> |
michael@0 | 18 | <script type="application/javascript"> |
michael@0 | 19 | <![CDATA[ |
michael@0 | 20 | |
michael@0 | 21 | // |
michael@0 | 22 | // Important! If this test starts failing after a tricky platform-y change, |
michael@0 | 23 | // the stack quota numbers in XPCJSRuntime probably need twiddling. We want |
michael@0 | 24 | // to maintain the invariants in this test (at least to some approximation) |
michael@0 | 25 | // for security reasons. |
michael@0 | 26 | // |
michael@0 | 27 | |
michael@0 | 28 | // Executes f() d steps from the probed native stack limit, and returns |
michael@0 | 29 | // the number of steps to the recursion limit from the caller. |
michael@0 | 30 | function nearNativeStackLimit(d, f) { |
michael@0 | 31 | f = f || function() {}; |
michael@0 | 32 | function inner() { |
michael@0 | 33 | try { |
michael@0 | 34 | with ({}) { // keep things predictable -- stay in the interpreter |
michael@0 | 35 | var stepsFromLimit = eval("inner()"); // Use eval to force a number of native stackframes to be created. |
michael@0 | 36 | } |
michael@0 | 37 | if (stepsFromLimit == d) { |
michael@0 | 38 | try { f(); } catch(e) { ok(false, 'nearNativeStackLimit callback threw: ' + e); } |
michael@0 | 39 | } |
michael@0 | 40 | return stepsFromLimit + 1; |
michael@0 | 41 | } catch(e) { |
michael@0 | 42 | // It would be nice to check here that the exception is actually an |
michael@0 | 43 | // over-recursion here. But doing so would require toString()ing the |
michael@0 | 44 | // exception, which we may not have the stack space to do. |
michael@0 | 45 | return 0; |
michael@0 | 46 | } |
michael@0 | 47 | } |
michael@0 | 48 | return inner(); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | const Cu = Components.utils; |
michael@0 | 52 | var contentSb = new Cu.Sandbox('http://www.example.com'); |
michael@0 | 53 | var chromeSb = new Cu.Sandbox(window); |
michael@0 | 54 | chromeSb.ok = contentSb.ok = ok; |
michael@0 | 55 | Cu.evalInSandbox(nearNativeStackLimit.toSource(), chromeSb); |
michael@0 | 56 | Cu.evalInSandbox(nearNativeStackLimit.toSource(), contentSb); |
michael@0 | 57 | var chromeLimit = Cu.evalInSandbox("nearNativeStackLimit(0);", chromeSb); |
michael@0 | 58 | var contentLimit = Cu.evalInSandbox("nearNativeStackLimit(0)", contentSb); |
michael@0 | 59 | ok(chromeLimit >= contentLimit + 10, |
michael@0 | 60 | "Chrome should be able to have at least 10 heavy frames more stack than content: " + chromeLimit + ", " + contentLimit); |
michael@0 | 61 | |
michael@0 | 62 | // Exhaust the stack space in content, and then make sure we can still get 10 |
michael@0 | 63 | // heavy frames in chrome. |
michael@0 | 64 | // |
michael@0 | 65 | // Note that sometimes, if we pass |0| to nearNativeStackLimit, we can end up |
michael@0 | 66 | // so close to the border in content that we can't even get ourselves together |
michael@0 | 67 | // enough to make the cross-compartment call. So rather than exhausting the |
michael@0 | 68 | // stack entirely and then checking for 10 chrome frames, we leave ourselves |
michael@0 | 69 | // one frame's worth, and check for 11. |
michael@0 | 70 | contentSb.nnslChrome = chromeSb.nearNativeStackLimit; |
michael@0 | 71 | var nestedLimit = Cu.evalInSandbox("nearNativeStackLimit(1, function() { nestedLimit = nnslChrome(0);}); nestedLimit;", contentSb); |
michael@0 | 72 | ok(nestedLimit >= 11, "Chrome should be invokable from content script with an exhausted stack: " + nestedLimit); |
michael@0 | 73 | |
michael@0 | 74 | ]]> |
michael@0 | 75 | </script> |
michael@0 | 76 | </window> |