Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / chrome / test / unit / test_bug564667.js
blob7ee5229827df462d99e63c9feb14049accea27e9
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  */
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(
10   Ci.nsIChromeRegistry
14  * Checks that a mapping was added
15  */
16 function test_mapping(chromeURL, target) {
17   var uri = Services.io.newURI(chromeURL);
19   try {
20     var result = gCR.convertChromeURL(uri);
21     Assert.equal(result.spec, target);
22   } catch (ex) {
23     do_throw(chromeURL + " not Registered");
24   }
28  * Checks that a mapping was removed
29  */
30 function test_removed_mapping(chromeURL, target) {
31   var uri = Services.io.newURI(chromeURL);
32   try {
33     gCR.convertChromeURL(uri);
34     do_throw(chromeURL + " not removed");
35   } catch (ex) {
36     // This should throw
37   }
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");
77 function run_test() {
78   // Test an unpackaged addon
79   testManifest(UNPACKAGED_ADDON, Services.io.newFileURI(UNPACKAGED_ADDON).spec);
81   // Test a packaged addon
82   testManifest(
83     PACKAGED_ADDON,
84     "jar:" + Services.io.newFileURI(PACKAGED_ADDON).spec + "!/"
85   );