Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- Manifest: chrome/test/unit/xpcshell.toml
/* 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
*/
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) {
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 Adding Locale URL
// Test Adding Skin URL
// Test Adding Manifest URL
// Test Adding Override
// ------------------ Remove manifest file ------------------------
Components.manager.removeBootstrappedManifestLocation(manifestPath);
// Test Removing Content URL
// Test Removing Content URL
// Test Removing Skin URL
// Test Removing Manifest URL
}
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 + "!/"
);
}