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=732413 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 732413</title> |
michael@0 | 8 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=732413">Mozilla Bug 732413</a> |
michael@0 | 13 | <p id="display"></p> |
michael@0 | 14 | <div id="content" style="display: none"> |
michael@0 | 15 | |
michael@0 | 16 | </div> |
michael@0 | 17 | <pre id="test"> |
michael@0 | 18 | <script type="application/javascript"> |
michael@0 | 19 | |
michael@0 | 20 | /** Test for Bug 732413 |
michael@0 | 21 | Passing DISALLOW_INHERIT_PRINCIPAL flag should be effective even if |
michael@0 | 22 | aPrincipal is the system principal. |
michael@0 | 23 | **/ |
michael@0 | 24 | |
michael@0 | 25 | const nsIScriptSecurityManager = SpecialPowers.Ci.nsIScriptSecurityManager; |
michael@0 | 26 | var secMan = SpecialPowers.Cc["@mozilla.org/scriptsecuritymanager;1"] |
michael@0 | 27 | .getService(nsIScriptSecurityManager); |
michael@0 | 28 | var sysPrincipal = secMan.getSystemPrincipal(); |
michael@0 | 29 | isnot(sysPrincipal, undefined, "Should have a principal"); |
michael@0 | 30 | isnot(sysPrincipal, null, "Should have a non-null principal"); |
michael@0 | 31 | is(secMan.isSystemPrincipal(sysPrincipal), true, |
michael@0 | 32 | "Should have system principal here"); |
michael@0 | 33 | |
michael@0 | 34 | |
michael@0 | 35 | var ioService = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]. |
michael@0 | 36 | getService(SpecialPowers.Ci.nsIIOService); |
michael@0 | 37 | var inheritingURI = ioService.newURI("javascript:1+1", null, null); |
michael@0 | 38 | |
michael@0 | 39 | // First try a normal call to checkLoadURIWithPrincipal |
michael@0 | 40 | try { |
michael@0 | 41 | secMan.checkLoadURIWithPrincipal(sysPrincipal, inheritingURI, |
michael@0 | 42 | nsIScriptSecurityManager.STANDARD); |
michael@0 | 43 | ok(true, "checkLoadURI allowed the load"); |
michael@0 | 44 | } catch (e) { |
michael@0 | 45 | ok(false, "checkLoadURI failed unexpectedly: " + e); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | // Now call checkLoadURIWithPrincipal with DISALLOW_INHERIT_PRINCIPAL |
michael@0 | 49 | try { |
michael@0 | 50 | secMan.checkLoadURIWithPrincipal(sysPrincipal, inheritingURI, |
michael@0 | 51 | nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL); |
michael@0 | 52 | ok(false, "checkLoadURI allowed the load unexpectedly"); |
michael@0 | 53 | } catch (e) { |
michael@0 | 54 | ok(true, "checkLoadURI prevented load of principal-inheriting URI"); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | </script> |
michael@0 | 58 | </pre> |
michael@0 | 59 | </body> |
michael@0 | 60 | </html> |