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=812415 |
michael@0 | 6 | --> |
michael@0 | 7 | <window title="Mozilla Bug 812415" |
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=812415" |
michael@0 | 14 | target="_blank">Mozilla Bug 812415</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 | /** Test for Bug 812415 and Bug 823348 **/ |
michael@0 | 21 | |
michael@0 | 22 | const Cu = Components.utils; |
michael@0 | 23 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 24 | |
michael@0 | 25 | function testWaiving(iwin, sb) { |
michael@0 | 26 | sb.win = iwin; |
michael@0 | 27 | is(Cu.evalInSandbox('win', sb), iwin, "Basic identity works"); |
michael@0 | 28 | is(Cu.evalInSandbox('win.wrappedJSObject', sb), iwin.wrappedJSObject, "Waivers work via .wrappedJSObject"); |
michael@0 | 29 | is(Cu.evalInSandbox('XPCNativeWrapper.unwrap(win)', sb), iwin.wrappedJSObject, "Waivers work via XPCNativeWrapper.unwrap"); |
michael@0 | 30 | is(Cu.evalInSandbox('win.wrappedJSObject.document', sb), iwin.document.wrappedJSObject, "Waivers are deep"); |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | function checkThrows(expression, sb, msg) { |
michael@0 | 34 | var result = Cu.evalInSandbox('(function() { try { ' + expression + '; return "allowed"; } catch (e) { return e.toString(); }})();', sb); |
michael@0 | 35 | ok(!!/denied/.exec(result), msg); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function testAsymmetric(regular, expanded) { |
michael@0 | 39 | |
michael@0 | 40 | // Set up objects. |
michael@0 | 41 | expanded.regFun = Cu.evalInSandbox('function reg() { return 42; }; reg', regular); |
michael@0 | 42 | expanded.regObj = Cu.evalInSandbox('new Object({foo: 2})', regular); |
michael@0 | 43 | regular.expFun = Cu.evalInSandbox('function exp() { return 41; }; exp', expanded); |
michael@0 | 44 | regular.expObj = Cu.evalInSandbox('new Object({bar: 3})', expanded); |
michael@0 | 45 | |
michael@0 | 46 | // Check objects. |
michael@0 | 47 | is(Cu.evalInSandbox('regObj.foo', expanded), 2, "Expanded can see regular object prop"); |
michael@0 | 48 | checkThrows('expObj.bar', regular, "Regular shouldn't read properties"); |
michael@0 | 49 | Cu.evalInSandbox('regObj.foo = 20', expanded); |
michael@0 | 50 | is(expanded.regObj.foo, 20, "Expanded can set properties"); |
michael@0 | 51 | checkThrows('expFun.bar = 0', regular, "Regular shouldn't write properties"); |
michael@0 | 52 | |
michael@0 | 53 | // Check functions. |
michael@0 | 54 | is(Cu.evalInSandbox('regFun()', expanded), 42, "Expanded can call regular function"); |
michael@0 | 55 | checkThrows('expFun()', regular, "Regular cannot call expanded function"); |
michael@0 | 56 | is(Cu.evalInSandbox('regFun.name', expanded), 'reg', "Expanded can see regular function's name"); |
michael@0 | 57 | checkThrows('expFun.name', regular, "Regular can't see expanded function's name"); |
michael@0 | 58 | Cu.evalInSandbox('regFun.expando = 30', expanded); |
michael@0 | 59 | is(expanded.regFun.expando, 30, "Expanded can set expandos"); |
michael@0 | 60 | checkThrows('expFun.expando = 29', regular, "Regular can't set expandos"); |
michael@0 | 61 | |
michael@0 | 62 | // Check __proto__ stuff. |
michael@0 | 63 | is(Cu.evalInSandbox('regFun.__proto__', expanded), regular.Function.prototype, "expanded can get __proto__"); |
michael@0 | 64 | checkThrows('expFun.__proto__', regular, "regular can't use __proto__"); |
michael@0 | 65 | checkThrows('expFun.__proto__ = {}', regular, "regular can't mutate __proto__"); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | function go() { |
michael@0 | 69 | var iwin = document.getElementById('ifr').contentWindow; |
michael@0 | 70 | |
michael@0 | 71 | // Make our sandboxes. We pass wantXrays=false for the nsEP to ensure that |
michael@0 | 72 | // the Xrays we get are the result of being an nsEP, not from the wantXrays |
michael@0 | 73 | // flag. |
michael@0 | 74 | var regular = new Components.utils.Sandbox(iwin); |
michael@0 | 75 | var expanded = new Components.utils.Sandbox([iwin], {wantXrays: false}); |
michael@0 | 76 | |
michael@0 | 77 | // Because of the crazy secret life of wantXrays, passing wantXrays=false |
michael@0 | 78 | // has the side effect of waiving Xrays on the returned sandbox. Undo that. |
michael@0 | 79 | expanded = XPCNativeWrapper(expanded); |
michael@0 | 80 | |
michael@0 | 81 | testWaiving(iwin, regular); |
michael@0 | 82 | testWaiving(iwin, expanded); |
michael@0 | 83 | testAsymmetric(regular, expanded); |
michael@0 | 84 | SimpleTest.finish(); |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | ]]> |
michael@0 | 88 | </script> |
michael@0 | 89 | <iframe id="ifr" onload="go();" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" /> |
michael@0 | 90 | </window> |