Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 // head_crtestutils.js doesn't get included in the child by default
7 if (typeof registerManifests === "undefined") {
8 load("../unit/head_crtestutils.js");
9 }
11 let manifestFile = do_get_file("../unit/data/test_resolve_uris.manifest");
13 let manifests = [ manifestFile ];
14 registerManifests(manifests);
16 let ios = Cc["@mozilla.org/network/io-service;1"].
17 getService(Ci.nsIIOService);
19 function do_run_test()
20 {
21 let cr = Cc["@mozilla.org/chrome/chrome-registry;1"].
22 getService(Ci.nsIChromeRegistry);
24 // If we don't have libxul or e10s then we don't have process separation, so
25 // we don't need to worry about checking for new chrome.
26 var appInfo = Cc["@mozilla.org/xre/app-info;1"];
27 if (!appInfo ||
28 (appInfo.getService(Ci.nsIXULRuntime).processType ==
29 Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT)) {
30 cr.checkForNewChrome();
31 }
33 // See if our various things were able to register
34 let registrationTypes = [
35 "content",
36 "locale",
37 "skin",
38 "override",
39 "resource",
40 ];
42 for (let j = 0; j < registrationTypes.length; j++) {
43 let type = registrationTypes[j];
44 dump("Testing type '" + type + "'\n");
45 let expectedURI = "resource://foo/foo-" + type + "/";
46 let sourceURI = "chrome://foo/" + type + "/";
47 switch (type) {
48 case "content":
49 expectedURI += "foo.xul";
50 break;
51 case "locale":
52 expectedURI += "foo.dtd";
53 break;
54 case "skin":
55 expectedURI += "foo.css";
56 break;
57 case "override":
58 sourceURI = "chrome://good-package/content/override-me.xul";
59 expectedURI += "override-me.xul";
60 break;
61 case "resource":
62 expectedURI = ios.newFileURI(manifestFile.parent).spec;
63 sourceURI = "resource://foo/";
64 break;
65 };
66 try {
67 sourceURI = ios.newURI(sourceURI, null, null);
68 let uri;
69 if (type == "resource") {
70 // resources go about a slightly different way than everything else
71 let rph = ios.getProtocolHandler("resource").
72 QueryInterface(Ci.nsIResProtocolHandler);
73 uri = rph.resolveURI(sourceURI);
74 }
75 else {
76 uri = cr.convertChromeURL(sourceURI).spec;
77 }
79 do_check_eq(expectedURI, uri);
80 }
81 catch (e) {
82 dump(e + "\n");
83 do_throw("Should have registered a handler for type '" +
84 type + "'\n");
85 }
86 }
87 }
89 if (typeof run_test === "undefined") {
90 run_test = function() {
91 do_run_test();
92 };
93 }