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