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/.
6 const UNPACKAGED_ADDON = do_get_file("data/test_bug564667");
7 const PACKAGED_ADDON = do_get_file("data/test_bug564667.xpi");
9 var gCR = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(
14 * Checks that a mapping was added
16 function test_mapping(chromeURL, target) {
17 var uri = Services.io.newURI(chromeURL);
20 var result = gCR.convertChromeURL(uri);
21 Assert.equal(result.spec, target);
23 do_throw(chromeURL + " not Registered");
28 * Checks that a mapping was removed
30 function test_removed_mapping(chromeURL) {
31 var uri = Services.io.newURI(chromeURL);
33 gCR.convertChromeURL(uri);
34 do_throw(chromeURL + " not removed");
40 function testManifest(manifestPath, baseURI) {
41 // ------------------ Add manifest file ------------------------
42 Components.manager.addBootstrappedManifestLocation(manifestPath);
44 // Test Adding Content URL
45 test_mapping("chrome://test1/content", baseURI + "test/test1.xul");
47 // Test Adding Locale URL
48 test_mapping("chrome://test1/locale", baseURI + "test/test1.dtd");
50 // Test Adding Skin URL
51 test_mapping("chrome://test1/skin", baseURI + "test/test1.css");
53 // Test Adding Manifest URL
54 test_mapping("chrome://test2/content", baseURI + "test/test2.xul");
55 test_mapping("chrome://test2/locale", baseURI + "test/test2.dtd");
57 // Test Adding Override
58 test_mapping("chrome://testOverride/content", "file:///test1/override");
60 // ------------------ Remove manifest file ------------------------
61 Components.manager.removeBootstrappedManifestLocation(manifestPath);
63 // Test Removing Content URL
64 test_removed_mapping("chrome://test1/content", baseURI + "test/test1.xul");
66 // Test Removing Content URL
67 test_removed_mapping("chrome://test1/locale", baseURI + "test/test1.dtd");
69 // Test Removing Skin URL
70 test_removed_mapping("chrome://test1/skin", baseURI + "test/test1.css");
72 // Test Removing Manifest URL
73 test_removed_mapping("chrome://test2/content", baseURI + "test/test2.xul");
74 test_removed_mapping("chrome://test2/locale", baseURI + "test/test2.dtd");
78 // Test an unpackaged addon
79 testManifest(UNPACKAGED_ADDON, Services.io.newFileURI(UNPACKAGED_ADDON).spec);
81 // Test a packaged addon
84 "jar:" + Services.io.newFileURI(PACKAGED_ADDON).spec + "!/"