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=995943 |
michael@0 | 6 | --> |
michael@0 | 7 | <window title="Mozilla Bug 995943" |
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=995943" |
michael@0 | 14 | target="_blank">Mozilla Bug 995943</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 | const Cu = Components.utils; |
michael@0 | 21 | const Cc = Components.classes; |
michael@0 | 22 | const Ci = Components.interfaces; |
michael@0 | 23 | Cu.import("resource://gre/modules/Services.jsm"); |
michael@0 | 24 | function debug(msg) { info(msg); } |
michael@0 | 25 | |
michael@0 | 26 | /** Test for CAPS file:// URI prefs. **/ |
michael@0 | 27 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 28 | SimpleTest.requestCompleteLog(); |
michael@0 | 29 | if (Services.appinfo.OS == "Darwin") // See bug 1067022 |
michael@0 | 30 | SimpleTest.expectAssertions(0, 1); |
michael@0 | 31 | |
michael@0 | 32 | var rootdir = Services.appinfo.OS == "WINNT" ? "file:///C:" : "file:///"; |
michael@0 | 33 | |
michael@0 | 34 | function checkLoadFileURI(domain, shouldLoad) { |
michael@0 | 35 | debug("Invoking checkLoadFileURI with domain: " + domain + ", shouldLoad: " + shouldLoad); |
michael@0 | 36 | return new Promise(function(resolve, reject) { |
michael@0 | 37 | $('ifr').addEventListener('load', function l1() { |
michael@0 | 38 | debug("Invoked l1 for " + domain); |
michael@0 | 39 | $('ifr').removeEventListener('load', l1); |
michael@0 | 40 | function l2() { |
michael@0 | 41 | debug("Invoked l2 for " + domain); |
michael@0 | 42 | $('ifr').removeEventListener('load', l2); |
michael@0 | 43 | ok(shouldLoad, "Successfully loaded file:// URI for domain: " + domain); |
michael@0 | 44 | resolve(); |
michael@0 | 45 | } |
michael@0 | 46 | $('ifr').addEventListener('load', l2); |
michael@0 | 47 | try { |
michael@0 | 48 | window[0].wrappedJSObject.location = rootdir; |
michael@0 | 49 | debug("Successfully navigated for " + domain); |
michael@0 | 50 | } catch (e) { |
michael@0 | 51 | ok(!shouldLoad && /denied|insecure/.test(e), |
michael@0 | 52 | "Prevented loading of file:// URI for domain: " + domain + " - " + e); |
michael@0 | 53 | $('ifr').removeEventListener('load', l2); |
michael@0 | 54 | resolve(); |
michael@0 | 55 | } |
michael@0 | 56 | }); |
michael@0 | 57 | let targetURI = domain + '/tests/js/xpconnect/tests/mochitest/file_empty.html'; |
michael@0 | 58 | debug("Navigating iframe to " + targetURI); |
michael@0 | 59 | $('ifr').contentWindow.location = targetURI; |
michael@0 | 60 | }); |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | function pushPrefs(prefs) { |
michael@0 | 64 | return new Promise(function(resolve) { SpecialPowers.pushPrefEnv({ set: prefs }, resolve); }); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | function popPrefs() { |
michael@0 | 68 | return new Promise(function(resolve) { SpecialPowers.popPrefEnv(resolve); }); |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | var gGoCount = 0; |
michael@0 | 72 | function go() { |
michael@0 | 73 | debug("Invoking go for window with id: " + window.getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID); |
michael@0 | 74 | is(++gGoCount, 1, "Should only call go once!"); |
michael@0 | 75 | checkLoadFileURI('http://example.com', false).then( |
michael@0 | 76 | pushPrefs.bind(null, [['capability.policy.policynames', ' somepolicy '], |
michael@0 | 77 | ['capability.policy.somepolicy.checkloaduri.enabled', 'AlLAcCeSs'], |
michael@0 | 78 | ['capability.policy.somepolicy.sites', 'http://example.com']])) |
michael@0 | 79 | .then(checkLoadFileURI.bind(null, 'http://example.com', true)) |
michael@0 | 80 | .then(popPrefs) |
michael@0 | 81 | .then(checkLoadFileURI.bind(null, 'http://example.com', false)) |
michael@0 | 82 | .then( |
michael@0 | 83 | pushPrefs.bind(null, [['capability.policy.policynames', ',somepolicy, someotherpolicy, '], |
michael@0 | 84 | ['capability.policy.somepolicy.checkloaduri.enabled', 'allaccess'], |
michael@0 | 85 | ['capability.policy.someotherpolicy.checkloaduri.enabled', 'nope'], |
michael@0 | 86 | ['capability.policy.somepolicy.sites', ' http://example.org test1.example.com https://test2.example.com '], |
michael@0 | 87 | ['capability.policy.someotherpolicy.sites', 'http://example.net ']])) |
michael@0 | 88 | .then(checkLoadFileURI.bind(null, 'http://example.org', true)) |
michael@0 | 89 | .then(checkLoadFileURI.bind(null, 'http://test2.example.com', false)) |
michael@0 | 90 | .then(checkLoadFileURI.bind(null, 'https://test2.example.com', true)) |
michael@0 | 91 | .then(checkLoadFileURI.bind(null, 'http://sub1.test2.example.com', false)) |
michael@0 | 92 | .then(checkLoadFileURI.bind(null, 'https://sub1.test2.example.com', true)) |
michael@0 | 93 | .then(checkLoadFileURI.bind(null, 'http://example.net', false)) |
michael@0 | 94 | .then(checkLoadFileURI.bind(null, 'http://test1.example.com', true)) |
michael@0 | 95 | .then(checkLoadFileURI.bind(null, 'https://test1.example.com', true)) |
michael@0 | 96 | .then(checkLoadFileURI.bind(null, 'http://sub1.test1.example.com', true)) |
michael@0 | 97 | .then(checkLoadFileURI.bind(null, 'https://sub1.test1.example.com', true)) |
michael@0 | 98 | .then(pushPrefs.bind(null, [['capability.policy.someotherpolicy.checkloaduri.enabled', 'allAccess']])) |
michael@0 | 99 | .then(checkLoadFileURI.bind(null, 'http://example.net', true)) |
michael@0 | 100 | .then(popPrefs) |
michael@0 | 101 | .then(popPrefs) |
michael@0 | 102 | .then(checkLoadFileURI.bind(null, 'http://example.net', false)) |
michael@0 | 103 | .then(SimpleTest.finish.bind(SimpleTest)); |
michael@0 | 104 | |
michael@0 | 105 | } |
michael@0 | 106 | addLoadEvent(go); |
michael@0 | 107 | |
michael@0 | 108 | ]]> |
michael@0 | 109 | </script> |
michael@0 | 110 | <iframe id="ifr" type="content" /> |
michael@0 | 111 | </window> |