summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js')
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js63
1 files changed, 21 insertions, 42 deletions
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js b/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js
index 1dd05064e..a6f9c8052 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js
@@ -19,8 +19,6 @@ userExtDir.append("extensions2");
userExtDir.append(gAppInfo.ID);
registerDirectory("XREUSysExt", userExtDir.parent);
-BootstrapMonitor.init();
-
function TestProvider(result) {
this.result = result;
}
@@ -33,7 +31,7 @@ TestProvider.prototype = {
if (aURI.spec === this.uri.spec) {
return this.id;
}
- throw Components.Exception("Not mapped", this.result);
+ throw Components.Exception("Not mapped", result);
}
};
@@ -52,6 +50,18 @@ function check_mapping(uri, id) {
do_check_eq(val.value, id);
}
+function resetPrefs() {
+ Services.prefs.setIntPref("bootstraptest.active_version", -1);
+}
+
+function waitForPref(aPref, aCallback) {
+ function prefChanged() {
+ Services.prefs.removeObserver(aPref, prefChanged);
+ aCallback();
+ }
+ Services.prefs.addObserver(aPref, prefChanged, false);
+}
+
function getActiveVersion() {
return Services.prefs.getIntPref("bootstraptest.active_version");
}
@@ -59,6 +69,8 @@ function getActiveVersion() {
function run_test() {
do_test_pending();
+ resetPrefs();
+
run_test_early();
}
@@ -83,10 +95,8 @@ function run_test_early() {
"resource://gre/modules/addons/XPIProvider.jsm", {});
// Make the early API call.
- // AddonManager still misses its provider and so doesn't work yet.
+ do_check_null(s.XPIProvider.mapURIToAddonID(uri));
do_check_null(AddonManager.mapURIToAddonID(uri));
- // But calling XPIProvider directly works immediately
- do_check_eq(s.XPIProvider.mapURIToAddonID(uri), id);
// Actually start up the manager.
startupManager(false);
@@ -138,7 +148,7 @@ function run_test_1() {
let uri = addon.getResourceURI(".");
check_mapping(uri, addon.id);
- BootstrapMonitor.promiseAddonStartup("bootstrap1@tests.mozilla.org").then(function() {
+ waitForPref("bootstraptest.active_version", function() {
run_test_2(uri);
});
});
@@ -248,38 +258,8 @@ function run_test_7() {
let uri = b1.getResourceURI(".");
check_mapping(uri, b1.id);
- do_execute_soon(run_test_8);
- });
-}
-
-// Tests that temporary addon-on URIs are mappable after install and uninstall
-function run_test_8() {
- prepare_test({
- "bootstrap2@tests.mozilla.org": [
- ["onInstalling", false],
- "onInstalled"
- ]
- }, [
- "onExternalInstall",
- ], function(b2) {
- let uri = b2.getResourceURI(".");
- check_mapping(uri, b2.id);
-
- prepare_test({
- "bootstrap2@tests.mozilla.org": [
- ["onUninstalling", false],
- "onUninstalled"
- ]
- });
-
- b2.uninstall();
- ensure_test_completed();
-
- check_mapping(uri, b2.id);
-
do_execute_soon(run_test_invalidarg);
});
- AddonManager.installTemporaryAddon(do_get_addon("test_bootstrap2_1"));
}
// Tests that the AddonManager will bail when mapURIToAddonID is called with an
@@ -299,12 +279,11 @@ function run_test_invalidarg() {
AddonManager.mapURIToAddonID(test);
throw new Error("Shouldn't be able to map the URI in question");
}
+ catch (ex if ex.result) {
+ do_check_eq(ex.result, Components.results.NS_ERROR_INVALID_ARG);
+ }
catch (ex) {
- if (ex.result) {
- do_check_eq(ex.result, Components.results.NS_ERROR_INVALID_ARG);
- } else {
- do_throw(ex);
- }
+ do_throw(ex);
}
}