Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test for Bug 949549</title> |
michael@0 | 5 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 7 | </head> |
michael@0 | 8 | <body> |
michael@0 | 9 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=949549">Mozilla Bug 949549</a> |
michael@0 | 10 | <div id="content" style="display: none"></div> |
michael@0 | 11 | <pre id="test"> |
michael@0 | 12 | <script type="application/javascript;version=1.8"> |
michael@0 | 13 | "use strict"; |
michael@0 | 14 | |
michael@0 | 15 | // Ensure that `setRequestContext` doesn't throw with app:// URLs |
michael@0 | 16 | |
michael@0 | 17 | const csp = SpecialPowers.Cc["@mozilla.org/contentsecuritypolicy;1"] |
michael@0 | 18 | .createInstance(SpecialPowers.Ci.nsIContentSecurityPolicy); |
michael@0 | 19 | |
michael@0 | 20 | const gManifestURL = "http://www.example.com/chrome/dom/tests/mochitest/webapps/apps/basic.webapp"; |
michael@0 | 21 | |
michael@0 | 22 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 23 | var app; |
michael@0 | 24 | |
michael@0 | 25 | function setupTest() { |
michael@0 | 26 | // We have to install an app in order for the app URL to be valid |
michael@0 | 27 | // (otherwise we get a "DummyChannel" that throws NS_NOT_IMPLEMENTED) |
michael@0 | 28 | SpecialPowers.setAllAppsLaunchable(true); |
michael@0 | 29 | SpecialPowers.addPermission("webapps-manage", true, document); |
michael@0 | 30 | SpecialPowers.autoConfirmAppInstall(function () { |
michael@0 | 31 | let req = navigator.mozApps.install(gManifestURL); |
michael@0 | 32 | req.onsuccess = function () { |
michael@0 | 33 | app = this.result; |
michael@0 | 34 | runTest(); |
michael@0 | 35 | } |
michael@0 | 36 | }); |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | function runTest() { |
michael@0 | 40 | // We have to use a mochitest to test app:// urls, |
michael@0 | 41 | // as app channels can't be instanciated in xpcshell. |
michael@0 | 42 | // Because app protocol depends on webapps.jsm, |
michael@0 | 43 | // which doesn't instanciate properly on xpcshell without many hacks |
michael@0 | 44 | let appchan = SpecialPowers.Services.io.newChannel(gManifestURL, null, null); |
michael@0 | 45 | |
michael@0 | 46 | try { |
michael@0 | 47 | csp.setRequestContext(null, null, null, appchan); |
michael@0 | 48 | ok(true, "setRequestContext hasn't thown"); |
michael@0 | 49 | } catch(e) { |
michael@0 | 50 | ok(false, "setRequestContext throws"); |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | cleanup() |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | function cleanup() { |
michael@0 | 57 | let req = navigator.mozApps.mgmt.uninstall(app); |
michael@0 | 58 | req.onsuccess = function () { |
michael@0 | 59 | SimpleTest.finish(); |
michael@0 | 60 | }; |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | setupTest(); |
michael@0 | 64 | </script> |
michael@0 | 65 | </pre> |
michael@0 | 66 | </body> |
michael@0 | 67 | </html> |