Bug 1756450 - Add test for updater's new internalError state r=bhearsum

Differential Revision: https://phabricator.services.mozilla.com/D157999
This commit is contained in:
Kirk Steuber 2022-09-23 19:47:34 +00:00
Родитель e2d241ebcf
Коммит 65e31d3d3d
4 изменённых файлов: 79 добавлений и 18 удалений

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

@ -53,24 +53,6 @@ class AppUpdater {
constructor() {
try {
this._listeners = new Set();
XPCOMUtils.defineLazyServiceGetter(
this,
"aus",
"@mozilla.org/updates/update-service;1",
"nsIApplicationUpdateService"
);
XPCOMUtils.defineLazyServiceGetter(
this,
"checker",
"@mozilla.org/updates/update-checker;1",
"nsIUpdateChecker"
);
XPCOMUtils.defineLazyServiceGetter(
this,
"um",
"@mozilla.org/updates/update-manager;1",
"nsIUpdateManager"
);
this.QueryInterface = ChromeUtils.generateQI([
"nsIObserver",
"nsIProgressEventSink",
@ -747,6 +729,25 @@ class AppUpdater {
}
}
XPCOMUtils.defineLazyServiceGetter(
AppUpdater.prototype,
"aus",
"@mozilla.org/updates/update-service;1",
"nsIApplicationUpdateService"
);
XPCOMUtils.defineLazyServiceGetter(
AppUpdater.prototype,
"checker",
"@mozilla.org/updates/update-checker;1",
"nsIUpdateChecker"
);
XPCOMUtils.defineLazyServiceGetter(
AppUpdater.prototype,
"um",
"@mozilla.org/updates/update-manager;1",
"nsIUpdateManager"
);
AppUpdater.STATUS = {
// Updates are allowed and there's no downloaded or staged update, but the
// AppUpdater hasn't checked for updates yet, so it doesn't know more than

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

@ -40,6 +40,7 @@ skip-if = os != 'win'
reason = Windows only feature.
[browser_aboutDialog_fc_check_unsupported.js]
[browser_aboutDialog_bc_multiUpdate.js]
[browser_aboutDialog_internalError.js]
# about:preferences Application Update Tests
[browser_aboutPrefs_fc_apply_blocked.js]
@ -69,6 +70,7 @@ reason = Windows only feature.
[browser_aboutPrefs_settings.js]
[browser_aboutPrefs_bc_multiUpdate.js]
[browser_aboutPrefs_backgroundUpdateSetting.js]
[browser_aboutPrefs_internalError.js]
# Doorhanger Application Update Tests
[browser_doorhanger_bc_check_cantApply.js]

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

@ -0,0 +1,29 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
XPCOMUtils.defineLazyModuleGetters(this, {
AppUpdater: "resource:///modules/AppUpdater.jsm",
sinon: "resource://testing-common/Sinon.jsm",
});
add_setup(function setup_internalErrorTest() {
const sandbox = sinon.createSandbox();
sandbox.stub(AppUpdater.prototype, "um").get(() => {
throw new Error("intentional test error");
});
registerCleanupFunction(() => {
sandbox.restore();
});
});
// Test for the About dialog's internal error handling.
add_task(async function aboutDialog_internalError() {
let params = {};
await runAboutDialogUpdateTest(params, [
{
panelId: "internalError",
},
]);
});

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

@ -0,0 +1,29 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
XPCOMUtils.defineLazyModuleGetters(this, {
AppUpdater: "resource:///modules/AppUpdater.jsm",
sinon: "resource://testing-common/Sinon.jsm",
});
add_setup(function setup_internalErrorTest() {
const sandbox = sinon.createSandbox();
sandbox.stub(AppUpdater.prototype, "um").get(() => {
throw new Error("intentional test error");
});
registerCleanupFunction(() => {
sandbox.restore();
});
});
// Test for about:preferences internal error handling.
add_task(async function aboutPrefs_internalError() {
let params = {};
await runAboutPrefsUpdateTest(params, [
{
panelId: "internalError",
},
]);
});