chrome/test/unit/test_bug380398.js

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

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

mercurial