Bug 1139254 - Use MockRegistrar in toolkit/mozapps. r=Unfocused

This commit is contained in:
Hiroyuki Ikezoe 2015-03-30 02:14:00 -04:00
Родитель fa4702635a
Коммит 2cb5a25170
30 изменённых файлов: 172 добавлений и 515 удалений

Просмотреть файл

@ -27,6 +27,7 @@ Components.utils.import("resource://gre/modules/Promise.jsm");
Components.utils.import("resource://gre/modules/Task.jsm");
Components.utils.import("resource://gre/modules/osfile.jsm");
Components.utils.import("resource://gre/modules/AsyncShutdown.jsm");
Components.utils.import("resource://testing-common/MockRegistrar.jsm");
// We need some internal bits of AddonManager
let AMscope = Components.utils.import("resource://gre/modules/AddonManager.jsm");
@ -1405,20 +1406,7 @@ if ("nsIWindowsRegKey" in AM_Ci) {
}
};
var WinRegFactory = {
createInstance: function(aOuter, aIid) {
if (aOuter != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
var key = new MockWindowsRegKey();
return key.QueryInterface(aIid);
}
};
var registrar = Components.manager.QueryInterface(AM_Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{0478de5b-0f38-4edb-851d-4c99f1ed8eba}"),
"Mock Windows Registry Implementation",
"@mozilla.org/windows-registry-key;1", WinRegFactory);
MockRegistrar.register("@mozilla.org/windows-registry-key;1", MockWindowsRegKey);
}
// Get the profile directory for tests to use.

Просмотреть файл

@ -10,6 +10,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/MockRegistrar.jsm");
var testserver = new HttpServer();
testserver.start(-1);
gPort = testserver.identity.primaryPort;
@ -48,20 +49,7 @@ var WindowWatcher = {
}
};
var WindowWatcherFactory = {
createInstance: function createInstance(outer, iid) {
if (outer != null)
throw Cr.NS_ERROR_NO_AGGREGATION;
return WindowWatcher.QueryInterface(iid);
}
};
var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1",
WindowWatcherFactory);
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
function load_blocklist(aFile, aCallback) {
Services.obs.addObserver(function() {

Просмотреть файл

@ -15,6 +15,7 @@ XPCOMUtils.defineLazyGetter(this, "gPref", function bls_gPref() {
});
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/MockRegistrar.jsm");
var testserver = new HttpServer();
testserver.start(-1);
gPort = testserver.identity.primaryPort;
@ -54,19 +55,7 @@ var WindowWatcher = {
}
};
var WindowWatcherFactory = {
createInstance: function createInstance(outer, iid) {
if (outer != null)
throw Cr.NS_ERROR_NO_AGGREGATION;
return WindowWatcher.QueryInterface(iid);
}
};
var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1",
WindowWatcherFactory);
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
function load_blocklist(aFile, aCallback) {
Services.obs.addObserver(function() {

Просмотреть файл

@ -11,6 +11,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/MockRegistrar.jsm");
var testserver = new HttpServer();
testserver.start(-1);
gPort = testserver.identity.primaryPort;
@ -49,19 +50,7 @@ var WindowWatcher = {
}
};
var WindowWatcherFactory = {
createInstance: function createInstance(outer, iid) {
if (outer != null)
throw Cr.NS_ERROR_NO_AGGREGATION;
return WindowWatcher.QueryInterface(iid);
}
};
var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1",
WindowWatcherFactory);
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
function load_blocklist(aFile, aCallback) {

Просмотреть файл

@ -35,6 +35,7 @@ const Cr = Components.results;
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://testing-common/MockRegistrar.jsm");
// Allow insecure updates
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false)
@ -360,13 +361,7 @@ var WindowWatcher = {
}
};
var WindowWatcherFactory = {
createInstance: function createInstance(outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return WindowWatcher.QueryInterface(iid);
}
};
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
var InstallConfirm = {
confirm: function(aWindow, aUrl, aInstalls, aInstallCount) {
@ -393,9 +388,6 @@ var InstallConfirmFactory = {
};
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);
registrar.registerFactory(Components.ID("{f0863905-4dde-42e2-991c-2dc8209bc9ca}"),
"Fake Install Prompt",
"@mozilla.org/addons/web-install-prompt;1", InstallConfirmFactory);

Просмотреть файл

@ -13,6 +13,7 @@ const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/MockRegistrar.jsm");
// This is the data we expect to see sent as part of the update url.
var EXPECTED = [
@ -105,16 +106,7 @@ var BlocklistService = {
}
};
var BlocklistServiceFactory = {
createInstance: function (outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return BlocklistService.QueryInterface(iid);
}
};
var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{61189e7a-6b1b-44b8-ac81-f180a6105085}"), "BlocklistService",
"@mozilla.org/extensions/blocklist;1", BlocklistServiceFactory);
MockRegistrar.register("@mozilla.org/extensions/blocklist;1", BlocklistService);
var server;

Просмотреть файл

@ -8,6 +8,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/MockRegistrar.jsm");
var testserver = new HttpServer();
testserver.start(-1);
gPort = testserver.identity.primaryPort;
@ -61,19 +62,7 @@ var WindowWatcher = {
}
};
var WindowWatcherFactory = {
createInstance: function createInstance(outer, iid) {
if (outer != null)
throw Cr.NS_ERROR_NO_AGGREGATION;
return WindowWatcher.QueryInterface(iid);
}
};
var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1",
WindowWatcherFactory);
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
function load_blocklist(aFile, aCallback) {

Просмотреть файл

@ -13,6 +13,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/MockRegistrar.jsm");
var testserver = new HttpServer();
testserver.start(-1);
gPort = testserver.identity.primaryPort;
@ -50,20 +51,7 @@ var WindowWatcher = {
}
};
var WindowWatcherFactory = {
createInstance: function createInstance(outer, iid) {
if (outer != null)
throw Cr.NS_ERROR_NO_AGGREGATION;
return WindowWatcher.QueryInterface(iid);
}
};
var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1",
WindowWatcherFactory);
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
function load_blocklist(aFile, aCallback) {
Services.obs.addObserver(function() {

Просмотреть файл

@ -14,6 +14,7 @@ const CATEGORY_UPDATE_TIMER = "update-timer";
// Get the HTTP server.
Components.utils.import("resource://testing-common/httpd.js");
Components.utils.import("resource://testing-common/MockRegistrar.jsm");
var testserver;
var gOSVersion;
var gBlocklist;
@ -49,16 +50,7 @@ var timerService = {
}
};
var TimerServiceFactory = {
createInstance: function (outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return timerService.QueryInterface(iid);
}
};
var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{61189e7a-6b1b-44b8-ac81-f180a6105085}"), "TimerService",
"@mozilla.org/updates/timer-manager;1", TimerServiceFactory);
MockRegistrar.register("@mozilla.org/updates/timer-manager;1", timerService);
function failHandler(metadata, response) {
do_throw("Should not have attempted to retrieve the blocklist when it is disabled");

Просмотреть файл

@ -8,6 +8,7 @@ const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/MockRegistrar.jsm");
var ADDONS = [{
id: "test_bug449027_1@tests.mozilla.org",
@ -249,14 +250,6 @@ var PluginHost = {
}
}
var PluginHostFactory = {
createInstance: function (outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return PluginHost.QueryInterface(iid);
}
};
// Don't need the full interface, attempts to call other methods will just
// throw which is just fine
var WindowWatcher = {
@ -285,20 +278,8 @@ var 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(Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{721c3e73-969e-474b-a6dc-059fd288c428}"),
"Fake Plugin Host",
"@mozilla.org/plugin/host;1", PluginHostFactory);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
MockRegistrar.register("@mozilla.org/plugin/host;1", PluginHost);
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
function create_addon(addon) {
var installrdf = "<?xml version=\"1.0\"?>\n" +

Просмотреть файл

@ -11,6 +11,7 @@ const Cr = Components.results;
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/MockRegistrar.jsm");
var gTestserver = new HttpServer();
gTestserver.start(-1);
gPort = gTestserver.identity.primaryPort;
@ -132,14 +133,6 @@ var PluginHost = {
}
}
var PluginHostFactory = {
createInstance: function (outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return PluginHost.QueryInterface(iid);
}
};
// Don't need the full interface, attempts to call other methods will just
// throw which is just fine
var WindowWatcher = {
@ -168,20 +161,8 @@ var 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("{721c3e73-969e-474b-a6dc-059fd288c428}"),
"Fake Plugin Host",
"@mozilla.org/plugin/host;1", PluginHostFactory);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
MockRegistrar.register("@mozilla.org/plugin/host;1", PluginHost);
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
function create_addon(addon) {
var installrdf = "<?xml version=\"1.0\"?>\n" +

Просмотреть файл

@ -8,6 +8,7 @@ const Cu = Components.utils;
const Cr = Components.results;
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/MockRegistrar.jsm");
const nsIBLS = Ci.nsIBlocklistService;
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
@ -56,14 +57,6 @@ var PluginHost = {
}
}
var PluginHostFactory = {
createInstance: function (outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return PluginHost.QueryInterface(iid);
}
};
// Don't need the full interface, attempts to call other methods will just
// throw which is just fine
var WindowWatcher = {
@ -90,21 +83,8 @@ var 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(Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{721c3e73-969e-474b-a6dc-059fd288c428}"),
"Fake Plugin Host",
"@mozilla.org/plugin/host;1", PluginHostFactory);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
MockRegistrar.register("@mozilla.org/plugin/host;1", PluginHost);
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
function do_update_blocklist(aDatafile, aNextPart) {

Просмотреть файл

@ -15,6 +15,7 @@ const Cu = Components.utils;
const Cr = Components.results;
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/MockRegistrar.jsm");
var testserver;
const profileDir = gProfD.clone();
@ -77,18 +78,7 @@ var 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);
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
function check_state_v1([a1, a2, a3, a4, a5, a6]) {
do_check_neq(a1, null);

Просмотреть файл

@ -10,6 +10,8 @@ Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
// Allow the mismatch UI to show
Services.prefs.setBoolPref("extensions.showMismatchUI", true);
Components.utils.import("resource://testing-common/MockRegistrar.jsm");
const Ci = Components.interfaces;
const extDir = gProfD.clone();
extDir.append("extensions");
@ -31,18 +33,7 @@ var 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(AM_Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
/**
* Start the test by installing extensions.

Просмотреть файл

@ -8,6 +8,8 @@ const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/upd
const PREF_EM_SHOW_MISMATCH_UI = "extensions.showMismatchUI";
const PREF_SHOWN_SELECTION_UI = "extensions.shownSelectionUI";
Components.utils.import("resource://testing-common/MockRegistrar.jsm");
const profileDir = gProfD.clone();
profileDir.append("extensions");
@ -29,18 +31,7 @@ var 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);
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
// Tests that the selection UI is displayed when upgrading an existing profile
function run_test() {

Просмотреть файл

@ -2,6 +2,8 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
Components.utils.import("resource://testing-common/MockRegistrar.jsm");
const Ci = Components.interfaces;
// This verifies that duplicate plugins are coalesced and maintain their ID
@ -84,18 +86,7 @@ var PluginHost = {
}
}
var PluginHostFactory = {
createInstance: function (outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return PluginHost.QueryInterface(iid);
}
};
var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{721c3e73-969e-474b-a6dc-059fd288c428}"),
"Fake Plugin Host",
"@mozilla.org/plugin/host;1", PluginHostFactory);
MockRegistrar.register("@mozilla.org/plugin/host;1", PluginHost);
var gPluginIDs = [null, null, null, null, null];

Просмотреть файл

@ -29,6 +29,7 @@ const Cu = Components.utils;
const Cr = Components.results;
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/MockRegistrar.jsm");
var testserver;
const profileDir = gProfD.clone();
@ -55,18 +56,7 @@ var 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);
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
// Return Date.now() in seconds, rounded
function now() {

Просмотреть файл

@ -6,6 +6,7 @@ const LIST_UPDATED_TOPIC = "plugins-list-updated";
// We need to use the same algorithm for generating IDs for plugins
var { getIDHashForString } = Components.utils.import("resource://gre/modules/addons/PluginProvider.jsm");
var { MockRegistrar } = Components.utils.import("resource://testing-common/MockRegistrar.jsm");
function PluginTag(name, description) {
this.name = name;
@ -49,17 +50,7 @@ gPluginHost = {
QueryInterface: XPCOMUtils.generateQI([AM_Ci.nsIPluginHost])
};
var PluginHostFactory = {
createInstance: function (outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return gPluginHost.QueryInterface(iid);
}
};
var registrar = Components.manager.QueryInterface(AM_Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{aa6f9fef-cbe2-4d55-a2fa-dcf5482068b9}"), "PluginHost",
"@mozilla.org/plugin/host;1", PluginHostFactory);
MockRegistrar.register("@mozilla.org/plugin/host;1", gPluginHost);
// This verifies that when the list of plugins changes the add-ons manager
// correctly updates

Просмотреть файл

@ -85,12 +85,6 @@ var gTestserver;
var gRegisteredServiceCleanup;
var gXHR;
var gXHRCallback;
var gUpdatePrompt;
var gUpdatePromptCallback;
var gCheckFunc;
var gResponseBody;
var gResponseStatusCode = 200;
@ -831,18 +825,6 @@ function cleanupTestCommon() {
// tests to fail.
gAUS.observe(null, "xpcom-shutdown", "");
if (gXHR) {
gXHRCallback = null;
gXHR.responseXML = null;
// null out the event handlers to prevent a mFreeCount leak of 1
gXHR.onerror = null;
gXHR.onload = null;
gXHR.onprogress = null;
gXHR = null;
}
gTestserver = null;
if (IS_UNIX) {
@ -2987,18 +2969,15 @@ function checkFilesInDirRecursive(aDir, aCallback) {
*
* Example of the callback function
*
* function callHandleEvent() {
* gXHR.status = gExpectedStatus;
* let e = { target: gXHR };
* gXHR.onload.handleEvent(e);
* function callHandleEvent(aXHR) {
* aXHR.status = gExpectedStatus;
* let e = { target: aXHR };
* aXHR.onload.handleEvent(e);
* }
*/
function overrideXHR(aCallback) {
gXHRCallback = aCallback;
gXHR = new xhr();
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(gXHR.classID, gXHR.classDescription,
gXHR.contractID, gXHR);
Cu.import("resource://testing-common/MockRegistrar.jsm");
MockRegistrar.register("@mozilla.org/xmlextras/xmlhttprequest;1", xhr, [aCallback]);
}
@ -3012,35 +2991,41 @@ function makeHandler(aVal) {
}
return aVal;
}
function xhr() {
function xhr(aCallback) {
this._callback = aCallback;
}
xhr.prototype = {
overrideMimeType: function(aMimetype) { },
setRequestHeader: function(aHeader, aValue) { },
status: null,
channel: { set notificationCallbacks(aVal) { } },
channel: {
set notificationCallbacks(aVal) { },
QueryInterface: XPCOMUtils.generateQI([Ci.nsIChannel])
},
_url: null,
_method: null,
open: function(aMethod, aUrl) {
gXHR.channel.originalURI = Services.io.newURI(aUrl, null, null);
gXHR._method = aMethod; gXHR._url = aUrl;
this.channel.originalURI = Services.io.newURI(aUrl, null, null);
this._method = aMethod; this._url = aUrl;
},
responseXML: null,
responseText: null,
send: function(aBody) {
do_execute_soon(gXHRCallback); // Use a timeout so the XHR completes
do_execute_soon(function() {
this._callback(this);
}.bind(this)); // Use a timeout so the XHR completes
},
_onprogress: null,
set onprogress(aValue) { gXHR._onprogress = makeHandler(aValue); },
get onprogress() { return gXHR._onprogress; },
set onprogress(aValue) { this._onprogress = makeHandler(aValue); },
get onprogress() { return this._onprogress; },
_onerror: null,
set onerror(aValue) { gXHR._onerror = makeHandler(aValue); },
get onerror() { return gXHR._onerror; },
set onerror(aValue) { this._onerror = makeHandler(aValue); },
get onerror() { return this._onerror; },
_onload: null,
set onload(aValue) { gXHR._onload = makeHandler(aValue); },
get onload() { return gXHR._onload; },
set onload(aValue) { this._onload = makeHandler(aValue); },
get onload() { return this._onload; },
addEventListener: function(aEvent, aValue, aCapturing) {
eval("gXHR._on" + aEvent + " = aValue");
eval("this._on" + aEvent + " = aValue");
},
flags: Ci.nsIClassInfo.SINGLETON,
implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
@ -3050,15 +3035,6 @@ xhr.prototype = {
aCount.value = interfaces.length;
return interfaces;
},
classDescription: "XMLHttpRequest",
contractID: "@mozilla.org/xmlextras/xmlhttprequest;1",
classID: Components.ID("{c9b37f43-4278-4304-a5e0-600991ab08cb}"),
createInstance: function(aOuter, aIID) {
if (aOuter == null) {
return gXHR.QueryInterface(aIID);
}
throw Cr.NS_ERROR_NO_AGGREGATION;
},
get wrappedJSObject() { return this; },
QueryInterface: XPCOMUtils.generateQI([Ci.nsIClassInfo])
};
@ -3071,29 +3047,28 @@ xhr.prototype = {
* The callback to call if the update prompt component is called.
*/
function overrideUpdatePrompt(aCallback) {
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
gUpdatePrompt = new UpdatePrompt();
gUpdatePromptCallback = aCallback;
registrar.registerFactory(gUpdatePrompt.classID, gUpdatePrompt.classDescription,
gUpdatePrompt.contractID, gUpdatePrompt);
Cu.import("resource://testing-common/MockRegistrar.jsm");
MockRegistrar.register("@mozilla.org/updates/update-prompt;1", UpdatePrompt, [aCallback]);
}
function UpdatePrompt() {
function UpdatePrompt(aCallback) {
this._callback = aCallback;
let fns = ["checkForUpdates", "showUpdateAvailable", "showUpdateDownloaded",
"showUpdateError", "showUpdateHistory", "showUpdateInstalled"];
fns.forEach(function(aPromptFn) {
UpdatePrompt.prototype[aPromptFn] = function() {
if (!gUpdatePromptCallback) {
if (!this._callback) {
return;
}
let callback = gUpdatePromptCallback[aPromptFn];
let callback = this._callback[aPromptFn];
if (!callback) {
return;
}
callback.apply(gUpdatePromptCallback,
callback.apply(this._callback,
Array.prototype.slice.call(arguments));
}
});
@ -3108,15 +3083,6 @@ UpdatePrompt.prototype = {
aCount.value = interfaces.length;
return interfaces;
},
classDescription: "UpdatePrompt",
contractID: "@mozilla.org/updates/update-prompt;1",
classID: Components.ID("{8c350a15-9b90-4622-93a1-4d320308664b}"),
createInstance: function(aOuter, aIID) {
if (aOuter == null) {
return gUpdatePrompt.QueryInterface(aIID);
}
throw Cr.NS_ERROR_NO_AGGREGATION;
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIClassInfo, Ci.nsIUpdatePrompt])
};
@ -3126,10 +3092,7 @@ const updateCheckListener = {
},
onCheckComplete: function UCL_onCheckComplete(aRequest, aUpdates, aUpdateCount) {
// The mock xmlhttprequest used by tests doesn't have a real nsIRequest so
// use _url to get the url to prevent the following error:
// ReferenceError: reference to undefined property "QueryInterface"
gRequestURL = gXHR._url;
gRequestURL = aRequest.channel.originalURI.spec;
gUpdateCount = aUpdateCount;
gUpdates = aUpdates;
debugDump("url = " + gRequestURL + ", " +
@ -3140,10 +3103,7 @@ const updateCheckListener = {
},
onError: function UCL_onError(aRequest, aUpdate) {
// The mock xmlhttprequest used by tests doesn't have a real nsIRequest so
// use _url to get the url to prevent the following error:
// ReferenceError: reference to undefined property "QueryInterface"
gRequestURL = gXHR._url;
gRequestURL = aRequest.channel.originalURI.spec;
gStatusCode = aRequest.status;
gStatusText = aUpdate.statusText ? aUpdate.statusText : null;
debugDump("url = " + gRequestURL + ", " +

Просмотреть файл

@ -33,17 +33,17 @@ function finish_test() {
// Callback function used by the custom XMLHttpRequest implementation to
// call the nsIDOMEventListener's handleEvent method for onload.
function callHandleEvent() {
gXHR.status = 400;
gXHR.responseText = gResponseBody;
function callHandleEvent(aXHR) {
aXHR.status = 400;
aXHR.responseText = gResponseBody;
try {
let parser = Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(Ci.nsIDOMParser);
gXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
aXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
} catch(e) {
}
let e = { target: gXHR };
gXHR.onload(e);
let e = { target: aXHR };
aXHR.onload(e);
}
// Helper function for testing mar downloads that have the correct size

Просмотреть файл

@ -2,6 +2,8 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
Components.utils.import("resource://testing-common/MockRegistrar.jsm");
function run_test() {
setupTestCommon();
@ -13,11 +15,12 @@ function run_test() {
Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, false);
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1",
WindowWatcherFactory);
let windowWatcherCID =
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1",
WindowWatcher);
do_register_cleanup(() => {
MockRegistrar.unregister(windowWatcherCID);
});
standardInit();
@ -39,12 +42,6 @@ function run_test() {
prompter.showUpdateError(update);
}
function end_test() {
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
WindowWatcherFactory);
}
const WindowWatcher = {
getNewPrompter: function(aParent) {
do_check_eq(aParent, null);
@ -64,12 +61,3 @@ const WindowWatcher = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowWatcher])
};
const WindowWatcherFactory = {
createInstance: function createInstance(aOuter, aIID) {
if (aOuter != null) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return WindowWatcher.QueryInterface(aIID);
}
};

Просмотреть файл

@ -43,18 +43,18 @@ function run_test() {
do_execute_soon(run_test_pt1);
}
function xhr_pt1() {
gXHR.status = 200;
gXHR.responseText = gResponseBody;
function xhr_pt1(aXHR) {
aXHR.status = 200;
aXHR.responseText = gResponseBody;
try {
let parser = Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(Ci.nsIDOMParser);
gXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
aXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
} catch (e) {
gXHR.responseXML = null;
aXHR.responseXML = null;
}
let e = { target: gXHR };
gXHR.onload(e);
let e = { target: aXHR };
aXHR.onload(e);
}
function run_test_pt1() {

Просмотреть файл

@ -16,7 +16,7 @@ function run_test() {
setUpdateURLOverride();
Services.prefs.setBoolPref(PREF_APP_UPDATE_AUTO, false);
overrideXHR(null);
overrideXHR(xhr_pt1);
overrideUpdatePrompt(updatePrompt);
standardInit();
@ -26,13 +26,12 @@ function run_test() {
function run_test_pt1() {
gResponseBody = null;
gCheckFunc = check_test_pt1;
gXHRCallback = xhr_pt1;
gUpdateChecker.checkForUpdates(updateCheckListener, true);
}
function xhr_pt1() {
gXHR.status = Cr.NS_ERROR_OFFLINE;
gXHR.onerror({ target: gXHR });
function xhr_pt1(aXHR) {
aXHR.status = Cr.NS_ERROR_OFFLINE;
aXHR.onerror({ target: aXHR });
}
function check_test_pt1(request, update) {
@ -43,7 +42,7 @@ function check_test_pt1(request, update) {
gAUS.onError(request, update);
// Trigger another check by notifying the offline status observer
gXHRCallback = xhr_pt2;
overrideXHR(xhr_pt2);
Services.obs.notifyObservers(gAUS, "network:offline-status-changed", "online");
}
@ -53,20 +52,20 @@ const updatePrompt = {
}
};
function xhr_pt2() {
function xhr_pt2(aXHR) {
let patches = getLocalPatchString();
let updates = getLocalUpdateString(patches);
let responseBody = getLocalUpdatesXMLString(updates);
gXHR.status = 200;
gXHR.responseText = responseBody;
aXHR.status = 200;
aXHR.responseText = responseBody;
try {
let parser = Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(Ci.nsIDOMParser);
gXHR.responseXML = parser.parseFromString(responseBody, "application/xml");
aXHR.responseXML = parser.parseFromString(responseBody, "application/xml");
} catch (e) {
}
gXHR.onload({ target: gXHR });
aXHR.onload({ target: aXHR });
}
function check_test_pt2(update) {

Просмотреть файл

@ -5,9 +5,9 @@
/* General MAR File Download Tests */
Components.utils.import("resource://testing-common/MockRegistrar.jsm");
const INC_CONTRACT_ID = "@mozilla.org/network/incremental-download;1";
var gIncrementalDownloadClassID, gIncOldFactory;
// gIncrementalDownloadErrorType is used to loop through each of the connection
// error types in the Mock incremental downloader.
var gIncrementalDownloadErrorType = 0;
@ -36,23 +36,19 @@ function finish_test() {
stop_httpserver(doTestFinish);
}
function end_test() {
cleanupMockIncrementalDownload();
}
// Callback function used by the custom XMLHttpRequest implementation to
// call the nsIDOMEventListener's handleEvent method for onload.
function callHandleEvent() {
gXHR.status = 400;
gXHR.responseText = gResponseBody;
function callHandleEvent(aXHR) {
aXHR.status = 400;
aXHR.responseText = gResponseBody;
try {
let parser = Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(Ci.nsIDOMParser);
gXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
aXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
} catch (e) {
}
let e = { target: gXHR };
gXHR.onload(e);
let e = { target: aXHR };
aXHR.onload(e);
}
// Helper function for testing mar downloads that have the correct size
@ -92,37 +88,12 @@ function setResponseBody(aHashFunction, aHashValue, aSize) {
gResponseBody = getRemoteUpdatesXMLString(updates);
}
const newFactory = {
createInstance: function(aOuter, aIID) {
if (aOuter) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return new IncrementalDownload().QueryInterface(aIID);
},
lockFactory: function(aLock) {
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory])
};
function initMockIncrementalDownload() {
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
gIncrementalDownloadClassID = registrar.contractIDToCID(INC_CONTRACT_ID);
gIncOldFactory = Cm.getClassObject(Cc[INC_CONTRACT_ID], Ci.nsIFactory);
registrar.unregisterFactory(gIncrementalDownloadClassID, gIncOldFactory);
let components = [IncrementalDownload];
registrar.registerFactory(gIncrementalDownloadClassID, "",
INC_CONTRACT_ID, newFactory);
}
function cleanupMockIncrementalDownload() {
if (gIncOldFactory) {
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(gIncrementalDownloadClassID, newFactory);
registrar.registerFactory(gIncrementalDownloadClassID, "",
INC_CONTRACT_ID, gIncOldFactory);
}
gIncOldFactory = null;
let incrementalDownloadCID =
MockRegistrar.register(INC_CONTRACT_ID, IncrementalDownload);
do_register_cleanup(() => {
MockRegistrar.unregister(incrementalDownloadCID);
});
}
/* This Mock incremental downloader is used to verify that connection

Просмотреть файл

@ -37,20 +37,20 @@ function check_test_helper_pt1() {
// Callback function used by the custom XMLHttpRequest implementation to
// call the nsIDOMEventListener's handleEvent method for onload.
function callHandleEvent() {
gXHR.status = 400;
gXHR.responseText = gResponseBody;
function callHandleEvent(aXHR) {
aXHR.status = 400;
aXHR.responseText = gResponseBody;
try {
if (gResponseBody) {
let parser = Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(Ci.nsIDOMParser);
gXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
aXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
}
} catch (e) {
gXHR.responseXML = null;
aXHR.responseXML = null;
}
let e = { target: gXHR };
gXHR.onload(e);
let e = { target: aXHR };
aXHR.onload(e);
}
// update xml not found

Просмотреть файл

@ -2,6 +2,8 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
Components.utils.import("resource://testing-common/MockRegistrar.jsm");
/**
* Test that nsIUpdatePrompt doesn't display UI for showUpdateInstalled and
* showUpdateAvailable when there is already an application update window open.
@ -15,15 +17,16 @@ function run_test() {
Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, false);
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1",
WindowWatcherFactory);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af56}"),
"Fake Window Mediator",
"@mozilla.org/appshell/window-mediator;1",
WindowMediatorFactory);
let windowWatcherCID =
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1",
WindowWatcher);
let windowMediatorCID =
MockRegistrar.register("@mozilla.org/appshell/window-mediator;1",
WindowMediator);
do_register_cleanup(() => {
MockRegistrar.unregister(windowWatcherCID);
MockRegistrar.unregister(windowMediatorCID);
});
standardInit();
@ -52,12 +55,6 @@ function run_test() {
// didn't throw and otherwise it would report no tests run.
do_check_true(true);
registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
WindowWatcherFactory);
registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af56}"),
WindowMediatorFactory);
doTestFinish();
}
@ -77,15 +74,6 @@ const WindowWatcher = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowWatcher])
};
const WindowWatcherFactory = {
createInstance: function createInstance(aOuter, aIID) {
if (aOuter != null) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return WindowWatcher.QueryInterface(aIID);
}
};
const WindowMediator = {
getMostRecentWindow: function(aWindowType) {
return { getInterface: XPCOMUtils.generateQI([Ci.nsIDOMWindow]) };
@ -93,12 +81,3 @@ const WindowMediator = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowMediator])
}
const WindowMediatorFactory = {
createInstance: function createInstance(aOuter, aIID) {
if (aOuter != null) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return WindowMediator.QueryInterface(aIID);
}
};

Просмотреть файл

@ -2,6 +2,8 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
Components.utils.import("resource://testing-common/MockRegistrar.jsm");
/**
* Test that nsIUpdatePrompt doesn't display UI for showUpdateInstalled,
* showUpdateAvailable, and showUpdateError when the app.update.silent
@ -16,11 +18,12 @@ function run_test() {
Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, true);
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1",
WindowWatcherFactory);
let windowWatcherCID =
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1",
WindowWatcher);
do_register_cleanup(() => {
MockRegistrar.unregister(windowWatcherCID);
});
standardInit();
@ -57,10 +60,6 @@ function run_test() {
// didn't throw and otherwise it would report no tests run.
do_check_true(true);
registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
WindowWatcherFactory);
doTestFinish();
}
@ -87,12 +86,3 @@ const WindowWatcher = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowWatcher])
};
const WindowWatcherFactory = {
createInstance: function createInstance(aOuter, aIID) {
if (aOuter != null) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return WindowWatcher.QueryInterface(aIID);
}
};

Просмотреть файл

@ -2,6 +2,8 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
Components.utils.import("resource://testing-common/MockRegistrar.jsm");
function run_test() {
setupTestCommon();
@ -15,15 +17,16 @@ function run_test() {
overrideXHR(callHandleEvent);
standardInit();
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1",
WindowWatcherFactory);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af56}"),
"Fake Window Mediator",
"@mozilla.org/appshell/window-mediator;1",
WindowMediatorFactory);
let windowWatcherCID =
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1",
WindowWatcher);
let windowMediatorCID =
MockRegistrar.register("@mozilla.org/appshell/window-mediator;1",
WindowMediator);
do_register_cleanup(() => {
MockRegistrar.unregister(windowWatcherCID);
MockRegistrar.unregister(windowMediatorCID);
});
Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, false);
Services.prefs.setBoolPref(PREF_APP_UPDATE_NOTIFIEDUNSUPPORTED, true);
@ -50,27 +53,19 @@ function check_test() {
doTestFinish();
}
function end_test() {
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
WindowWatcherFactory);
registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af56}"),
WindowMediatorFactory);
}
// Callback function used by the custom XMLHttpRequest implementation to
// call the nsIDOMEventListener's handleEvent method for onload.
function callHandleEvent() {
gXHR.status = 400;
gXHR.responseText = gResponseBody;
function callHandleEvent(aXHR) {
aXHR.status = 400;
aXHR.responseText = gResponseBody;
try {
let parser = Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(Ci.nsIDOMParser);
gXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
aXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
} catch (e) {
}
let e = { target: gXHR };
gXHR.onload(e);
let e = { target: aXHR };
aXHR.onload(e);
}
function check_showUpdateAvailable() {
@ -85,15 +80,6 @@ const WindowWatcher = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowWatcher])
};
const WindowWatcherFactory = {
createInstance: function createInstance(aOuter, aIID) {
if (aOuter != null) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return WindowWatcher.QueryInterface(aIID);
}
};
const WindowMediator = {
getMostRecentWindow: function(aWindowType) {
return null;
@ -101,12 +87,3 @@ const WindowMediator = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowMediator])
};
const WindowMediatorFactory = {
createInstance: function createInstance(aOuter, aIID) {
if (aOuter != null) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return WindowMediator.QueryInterface(aIID);
}
};

Просмотреть файл

@ -27,10 +27,10 @@ function run_test() {
// Callback function used by the custom XMLHttpRequest implementation to
// call the nsIDOMEventListener's handleEvent method for onload.
function callHandleEvent() {
gXHR.status = gExpectedStatusCode;
let e = { target: gXHR };
gXHR.onload(e);
function callHandleEvent(aXHR) {
aXHR.status = gExpectedStatusCode;
var e = { target: aXHR };
aXHR.onload(e);
}
// Helper functions for testing nsIUpdateCheckListener statusText

Просмотреть файл

@ -28,12 +28,12 @@ function run_test() {
// Callback function used by the custom XMLHttpRequest implementation to
// call the nsIDOMEventListener's handleEvent method for onload.
function callHandleEvent() {
function callHandleEvent(aXHR) {
// The mock xmlhttprequest needs a status code to return to the consumer and
// the value is not important for this test.
gXHR.status = 404;
let e = { target: gXHR };
gXHR.onload(e);
aXHR.status = 404;
var e = { target: aXHR };
aXHR.onload(e);
}
// Helper function for parsing the result from the contructed url