summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/extensions/test/xpcshell/test_bug542391.js
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/mozapps/extensions/test/xpcshell/test_bug542391.js')
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug542391.js50
1 files changed, 36 insertions, 14 deletions
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug542391.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug542391.js
index aa1bbd53f..ceb472f98 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug542391.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug542391.js
@@ -9,12 +9,12 @@ const PREF_EM_SHOW_MISMATCH_UI = "extensions.showMismatchUI";
// The test extension uses an insecure update url.
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-var Cu = Components.utils;
-var Cr = Components.results;
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+const Cr = Components.results;
-Cu.import("resource://testing-common/MockRegistrar.jsm");
+Cu.import("resource://testing-common/httpd.js");
var testserver;
const profileDir = gProfD.clone();
@@ -26,14 +26,14 @@ var gCheckUpdates = false;
// This will be called to show the compatibility update dialog.
var WindowWatcher = {
expected: false,
- args: null,
+ arguments: null,
openWindow: function(parent, url, name, features, args) {
do_check_true(Services.startup.interrupted);
do_check_eq(url, URI_EXTENSION_UPDATE_DIALOG);
do_check_true(this.expected);
this.expected = false;
- this.args = args.QueryInterface(AM_Ci.nsIVariant);
+ this.arguments = args.QueryInterface(AM_Ci.nsIVariant);
var updated = !gCheckUpdates;
if (gCheckUpdates) {
@@ -77,7 +77,18 @@ var WindowWatcher = {
}
}
-MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
+var WindowWatcherFactory = {
+ createInstance: function createInstance(outer, iid) {
+ if (outer != null)
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ return WindowWatcher.QueryInterface(iid);
+ }
+};
+
+var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
+ "Fake Window Watcher",
+ "@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
function check_state_v1([a1, a2, a3, a4, a5, a6]) {
do_check_neq(a1, null);
@@ -295,9 +306,10 @@ add_task(function* init() {
}, profileDir);
// Create and configure the HTTP server.
- testserver = createHttpServer(4444);
+ testserver = new HttpServer();
testserver.registerDirectory("/data/", do_get_file("data"));
testserver.registerDirectory("/addons/", do_get_file("addons"));
+ testserver.start(4444);
startupManager();
@@ -385,9 +397,9 @@ add_task(function* run_test_1() {
"override1x2-1x3@tests.mozilla.org"]);
check_state_v3(addons);
- do_check_eq(WindowWatcher.args.length, 2);
- do_check_true(WindowWatcher.args.indexOf("upgradeable1x2-3@tests.mozilla.org") >= 0);
- do_check_true(WindowWatcher.args.indexOf("override1x2-1x3@tests.mozilla.org") >= 0);
+ do_check_eq(WindowWatcher.arguments.length, 2);
+ do_check_true(WindowWatcher.arguments.indexOf("upgradeable1x2-3@tests.mozilla.org") >= 0);
+ do_check_true(WindowWatcher.arguments.indexOf("override1x2-1x3@tests.mozilla.org") >= 0);
});
// Downgrade to version 2 which will remove appDisable from two add-ons
@@ -438,8 +450,8 @@ add_task(function* run_test_5() {
"override1x2-1x3@tests.mozilla.org"]);
check_state_v3_2(addons);
- do_check_eq(WindowWatcher.args.length, 1);
- do_check_true(WindowWatcher.args.indexOf("upgradeable1x2-3@tests.mozilla.org") >= 0);
+ do_check_eq(WindowWatcher.arguments.length, 1);
+ do_check_true(WindowWatcher.arguments.indexOf("upgradeable1x2-3@tests.mozilla.org") >= 0);
});
// Downgrade to version 1 which will appEnable all the add-ons
@@ -462,3 +474,13 @@ add_task(function* run_test_6() {
"override1x2-1x3@tests.mozilla.org"]);
check_state_v1_2(addons);
});
+
+add_task(function* cleanup() {
+ return new Promise((resolve, reject) => {
+ testserver.stop(resolve);
+ });
+});
+
+function run_test() {
+ run_next_test();
+}