chrome/test/unit/test_bug397073.js

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

mercurial