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_bug399707.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 target = gIOS.newFileURI(do_get_file("data"));
53 target = target.spec + "test/test.xul";
55 function test_succeeded_mapping(namespace)
56 {
57 var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul",
58 null, null);
59 try {
60 var result = chromeReg.convertChromeURL(uri);
61 do_check_eq(result.spec, target);
62 }
63 catch (ex) {
64 do_throw(namespace);
65 }
66 }
68 function test_failed_mapping(namespace)
69 {
70 var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul",
71 null, null);
72 try {
73 var result = chromeReg.convertChromeURL(uri);
74 do_throw(namespace);
75 }
76 catch (ex) {
77 }
78 }
80 function run_test()
81 {
82 test_succeeded_mapping("test1");
83 test_succeeded_mapping("test2");
84 test_succeeded_mapping("test3");
85 test_failed_mapping("test4");
86 test_failed_mapping("test5");
87 test_failed_mapping("test6");
88 test_failed_mapping("test7");
89 test_failed_mapping("test8");
90 }