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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 4 | */ |
michael@0 | 5 | |
michael@0 | 6 | var MANIFESTS = [ |
michael@0 | 7 | do_get_file("data/test_bug399707.manifest") |
michael@0 | 8 | ]; |
michael@0 | 9 | |
michael@0 | 10 | registerManifests(MANIFESTS); |
michael@0 | 11 | |
michael@0 | 12 | var XULAppInfo = { |
michael@0 | 13 | vendor: "Mozilla", |
michael@0 | 14 | name: "XPCShell", |
michael@0 | 15 | ID: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}", |
michael@0 | 16 | version: "5", |
michael@0 | 17 | appBuildID: "2007010101", |
michael@0 | 18 | platformVersion: "1.9", |
michael@0 | 19 | platformBuildID: "2007010101", |
michael@0 | 20 | inSafeMode: false, |
michael@0 | 21 | logConsoleErrors: true, |
michael@0 | 22 | OS: "XPCShell", |
michael@0 | 23 | XPCOMABI: "noarch-spidermonkey", |
michael@0 | 24 | |
michael@0 | 25 | QueryInterface: function QueryInterface(iid) { |
michael@0 | 26 | if (iid.equals(Ci.nsIXULAppInfo) |
michael@0 | 27 | || iid.equals(Ci.nsIXULRuntime) |
michael@0 | 28 | || iid.equals(Ci.nsISupports)) |
michael@0 | 29 | return this; |
michael@0 | 30 | |
michael@0 | 31 | throw Components.results.NS_ERROR_NO_INTERFACE; |
michael@0 | 32 | } |
michael@0 | 33 | }; |
michael@0 | 34 | |
michael@0 | 35 | var XULAppInfoFactory = { |
michael@0 | 36 | createInstance: function (outer, iid) { |
michael@0 | 37 | if (outer != null) |
michael@0 | 38 | throw Components.results.NS_ERROR_NO_AGGREGATION; |
michael@0 | 39 | return XULAppInfo.QueryInterface(iid); |
michael@0 | 40 | } |
michael@0 | 41 | }; |
michael@0 | 42 | var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); |
michael@0 | 43 | registrar.registerFactory(XULAPPINFO_CID, "XULAppInfo", |
michael@0 | 44 | XULAPPINFO_CONTRACTID, XULAppInfoFactory); |
michael@0 | 45 | |
michael@0 | 46 | var gIOS = Cc["@mozilla.org/network/io-service;1"] |
michael@0 | 47 | .getService(Ci.nsIIOService); |
michael@0 | 48 | var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"] |
michael@0 | 49 | .getService(Ci.nsIChromeRegistry); |
michael@0 | 50 | chromeReg.checkForNewChrome(); |
michael@0 | 51 | |
michael@0 | 52 | var target = gIOS.newFileURI(do_get_file("data")); |
michael@0 | 53 | target = target.spec + "test/test.xul"; |
michael@0 | 54 | |
michael@0 | 55 | function test_succeeded_mapping(namespace) |
michael@0 | 56 | { |
michael@0 | 57 | var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul", |
michael@0 | 58 | null, null); |
michael@0 | 59 | try { |
michael@0 | 60 | var result = chromeReg.convertChromeURL(uri); |
michael@0 | 61 | do_check_eq(result.spec, target); |
michael@0 | 62 | } |
michael@0 | 63 | catch (ex) { |
michael@0 | 64 | do_throw(namespace); |
michael@0 | 65 | } |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | function test_failed_mapping(namespace) |
michael@0 | 69 | { |
michael@0 | 70 | var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul", |
michael@0 | 71 | null, null); |
michael@0 | 72 | try { |
michael@0 | 73 | var result = chromeReg.convertChromeURL(uri); |
michael@0 | 74 | do_throw(namespace); |
michael@0 | 75 | } |
michael@0 | 76 | catch (ex) { |
michael@0 | 77 | } |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | function run_test() |
michael@0 | 81 | { |
michael@0 | 82 | test_succeeded_mapping("test1"); |
michael@0 | 83 | test_succeeded_mapping("test2"); |
michael@0 | 84 | test_succeeded_mapping("test3"); |
michael@0 | 85 | test_failed_mapping("test4"); |
michael@0 | 86 | test_failed_mapping("test5"); |
michael@0 | 87 | test_failed_mapping("test6"); |
michael@0 | 88 | test_failed_mapping("test7"); |
michael@0 | 89 | test_failed_mapping("test8"); |
michael@0 | 90 | } |