summaryrefslogtreecommitdiffstats
path: root/chrome/test/unit/test_bug564667.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /chrome/test/unit/test_bug564667.js
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'chrome/test/unit/test_bug564667.js')
-rw-r--r--chrome/test/unit/test_bug564667.js86
1 files changed, 86 insertions, 0 deletions
diff --git a/chrome/test/unit/test_bug564667.js b/chrome/test/unit/test_bug564667.js
new file mode 100644
index 0000000000..7ee5229827
--- /dev/null
+++ b/chrome/test/unit/test_bug564667.js
@@ -0,0 +1,86 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+const UNPACKAGED_ADDON = do_get_file("data/test_bug564667");
+const PACKAGED_ADDON = do_get_file("data/test_bug564667.xpi");
+
+var gCR = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(
+ Ci.nsIChromeRegistry
+);
+
+/*
+ * Checks that a mapping was added
+ */
+function test_mapping(chromeURL, target) {
+ var uri = Services.io.newURI(chromeURL);
+
+ try {
+ var result = gCR.convertChromeURL(uri);
+ Assert.equal(result.spec, target);
+ } catch (ex) {
+ do_throw(chromeURL + " not Registered");
+ }
+}
+
+/*
+ * Checks that a mapping was removed
+ */
+function test_removed_mapping(chromeURL, target) {
+ var uri = Services.io.newURI(chromeURL);
+ try {
+ gCR.convertChromeURL(uri);
+ do_throw(chromeURL + " not removed");
+ } catch (ex) {
+ // This should throw
+ }
+}
+
+function testManifest(manifestPath, baseURI) {
+ // ------------------ Add manifest file ------------------------
+ Components.manager.addBootstrappedManifestLocation(manifestPath);
+
+ // Test Adding Content URL
+ test_mapping("chrome://test1/content", baseURI + "test/test1.xul");
+
+ // Test Adding Locale URL
+ test_mapping("chrome://test1/locale", baseURI + "test/test1.dtd");
+
+ // Test Adding Skin URL
+ test_mapping("chrome://test1/skin", baseURI + "test/test1.css");
+
+ // Test Adding Manifest URL
+ test_mapping("chrome://test2/content", baseURI + "test/test2.xul");
+ test_mapping("chrome://test2/locale", baseURI + "test/test2.dtd");
+
+ // Test Adding Override
+ test_mapping("chrome://testOverride/content", "file:///test1/override");
+
+ // ------------------ Remove manifest file ------------------------
+ Components.manager.removeBootstrappedManifestLocation(manifestPath);
+
+ // Test Removing Content URL
+ test_removed_mapping("chrome://test1/content", baseURI + "test/test1.xul");
+
+ // Test Removing Content URL
+ test_removed_mapping("chrome://test1/locale", baseURI + "test/test1.dtd");
+
+ // Test Removing Skin URL
+ test_removed_mapping("chrome://test1/skin", baseURI + "test/test1.css");
+
+ // Test Removing Manifest URL
+ test_removed_mapping("chrome://test2/content", baseURI + "test/test2.xul");
+ test_removed_mapping("chrome://test2/locale", baseURI + "test/test2.dtd");
+}
+
+function run_test() {
+ // Test an unpackaged addon
+ testManifest(UNPACKAGED_ADDON, Services.io.newFileURI(UNPACKAGED_ADDON).spec);
+
+ // Test a packaged addon
+ testManifest(
+ PACKAGED_ADDON,
+ "jar:" + Services.io.newFileURI(PACKAGED_ADDON).spec + "!/"
+ );
+}