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 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: sw=2 ts=2 sts=2 tw=78 expandtab :
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 let manifests = [
8 do_get_file("data/test_data_protocol_registration.manifest"),
9 ];
10 registerManifests(manifests);
12 let XULAppInfoFactory = {
13 // These two are used when we register all our factories (and unregister)
14 CID: XULAPPINFO_CID,
15 scheme: "XULAppInfo",
16 contractID: XULAPPINFO_CONTRACTID,
17 createInstance: function (outer, iid) {
18 if (outer != null)
19 throw Cr.NS_ERROR_NO_AGGREGATION;
20 return XULAppInfo.QueryInterface(iid);
21 }
22 };
24 function run_test()
25 {
26 // Add our XULAppInfo factory
27 let factories = [XULAppInfoFactory];
29 // Register our factories
30 for (let i = 0; i < factories.length; i++) {
31 let factory = factories[i];
32 Components.manager.QueryInterface(Ci.nsIComponentRegistrar)
33 .registerFactory(factory.CID, "test-" + factory.scheme,
34 factory.contractID, factory);
35 }
37 // Check for new chrome
38 let cr = Cc["@mozilla.org/chrome/chrome-registry;1"].
39 getService(Ci.nsIChromeRegistry);
40 cr.checkForNewChrome();
42 // Check that our override worked
43 let expectedURI = "data:application/vnd.mozilla.xul+xml,";
44 let sourceURI = "chrome://good-package/content/test.xul";
45 try {
46 let ios = Cc["@mozilla.org/network/io-service;1"].
47 getService(Ci.nsIIOService);
48 sourceURI = ios.newURI(sourceURI, null, null);
49 // this throws for packages that are not registered
50 let uri = cr.convertChromeURL(sourceURI).spec;
52 do_check_eq(expectedURI, uri);
53 }
54 catch (e) {
55 dump(e + "\n");
56 do_throw("Should have registered our URI!");
57 }
59 // Unregister our factories so we do not leak
60 for (let i = 0; i < factories.length; i++) {
61 let factory = factories[i];
62 Components.manager.QueryInterface(Ci.nsIComponentRegistrar)
63 .unregisterFactory(factory.CID, factory);
64 }
65 }