Backed out 23 changesets (bug 1887980, bug 1875502) for causing xpc failures @ toolkit/components/extensions/test/xpcshell/test_ext_storage_idb_data_migration.js CLOSED TREE

Backed out changeset fb53b5f266e2 (bug 1875502)
Backed out changeset 9157c611617d (bug 1875502)
Backed out changeset 924b7230a45e (bug 1875502)
Backed out changeset d83fa2a0c858 (bug 1887980)
Backed out changeset c538de825468 (bug 1875502)
Backed out changeset a6c1ee51eadb (bug 1875502)
Backed out changeset 47bc52e77563 (bug 1875502)
Backed out changeset 54d53947927a (bug 1875502)
Backed out changeset 6bc2601a69bd (bug 1875502)
Backed out changeset 917a4aed3b4b (bug 1875502)
Backed out changeset afa0353ca6a2 (bug 1875502)
Backed out changeset 42ad3c8fe41e (bug 1875502)
Backed out changeset b5f4c67a548b (bug 1875502)
Backed out changeset d47c42d117e3 (bug 1875502)
Backed out changeset a33c98ac118c (bug 1875502)
Backed out changeset b57983b426ba (bug 1875502)
Backed out changeset a013811a156b (bug 1875502)
Backed out changeset 05b53ed47055 (bug 1875502)
Backed out changeset aa0eee306544 (bug 1875502)
Backed out changeset 5736dca8c05b (bug 1875502)
Backed out changeset 6e60ddb35c98 (bug 1875502)
Backed out changeset fcb327ff8717 (bug 1875502)
Backed out changeset 1950b330d253 (bug 1875502)
This commit is contained in:
Sandor Molnar
2024-05-16 00:21:12 +03:00
parent c7e4dfa4b3
commit 5aee31029c
159 changed files with 1204 additions and 1826 deletions

View File

@@ -286,6 +286,18 @@ const startupPhases = {
// We reach this phase right after showing the first browser window.
// This means that any I/O at this point delayed first paint.
"before first paint": [
{
// bug 1545119
path: "OldUpdRootD:",
condition: WIN,
stat: 1,
},
{
// bug 1446012
path: "UpdRootD:updates/0/update.status",
condition: WIN,
stat: 1,
},
{
path: "XREAppFeat:formautofill@mozilla.org.xpi",
condition: !WIN,

View File

@@ -739,7 +739,7 @@ nsBrowserContentHandler.prototype = {
overridePage = Services.urlFormatter.formatURLPref(
"startup.homepage_override_url"
);
let update = lazy.UpdateManager.updateInstalledAtStartup;
let update = lazy.UpdateManager.readyUpdate;
/** If the override URL is provided by an experiment, is a valid
* Firefox What's New Page URL, and the update version is less than

View File

@@ -122,10 +122,6 @@ if (AppConstants.MOZ_UPDATE_AGENT) {
XPCOMUtils.defineLazyServiceGetters(lazy, {
BrowserHandler: ["@mozilla.org/browser/clh;1", "nsIBrowserHandler"],
PushService: ["@mozilla.org/push/Service;1", "nsIPushService"],
UpdateServiceStub: [
"@mozilla.org/updates/update-service-stub;1",
"nsIApplicationUpdateServiceStub",
],
});
ChromeUtils.defineLazyGetter(
@@ -1519,7 +1515,6 @@ BrowserGlue.prototype = {
millisecondsIn24Hours;
if (buildDate + acceptableAge < today) {
// This is asynchronous, but just kick it off rather than waiting.
Cc["@mozilla.org/updates/update-service;1"]
.getService(Ci.nsIApplicationUpdateService)
.checkForBackgroundUpdates();
@@ -3032,8 +3027,16 @@ BrowserGlue.prototype = {
name: "BackgroundUpdate",
condition: AppConstants.MOZ_UPDATE_AGENT,
task: async () => {
// Never in automation!
if (!lazy.UpdateServiceStub.updateDisabledForTesting) {
// Never in automation! This is close to
// `UpdateService.disabledForTesting`, but without creating the
// service, which can perform a good deal of I/O in order to log its
// state. Since this is in the startup path, we avoid all of that.
let disabledForTesting =
(Cu.isInAutomation ||
lazy.Marionette.running ||
lazy.RemoteAgent.running) &&
Services.prefs.getBoolPref("app.update.disabledForTesting", false);
if (!disabledForTesting) {
try {
await lazy.BackgroundUpdate.scheduleFirefoxMessagingSystemTargetingSnapshotting();
} catch (e) {

View File

@@ -39,8 +39,7 @@ add_task(async function test_override_postupdate_page() {
reloadUpdateManagerData(true);
});
writeFile(XML_UPDATE, getActiveUpdateFile());
writeSuccessUpdateStatusFile();
writeUpdatesToXMLFile(XML_UPDATE);
reloadUpdateManagerData(false);
is(
@@ -102,45 +101,32 @@ function getActiveUpdateFile() {
function reloadUpdateManagerData(skipFiles = false) {
Cc["@mozilla.org/updates/update-manager;1"]
.getService(Ci.nsIUpdateManager)
.internal.reload(skipFiles);
.QueryInterface(Ci.nsIObserver)
.observe(null, "um-reload-update-data", skipFiles ? "skip-files" : "");
}
/**
* Writes the specified text to the specified file.
* Writes the updates specified to the active-update.xml file.
*
* @param {string} aText
* The string to write to the file.
* @param {nsIFile} aFile
* The file to write to.
* The updates represented as a string to write to the active-update.xml file.
*/
function writeFile(aText, aFile) {
function writeUpdatesToXMLFile(aText) {
const PERMS_FILE = 0o644;
const MODE_WRONLY = 0x02;
const MODE_CREATE = 0x08;
const MODE_TRUNCATE = 0x20;
if (!aFile.exists()) {
aFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
let activeUpdateFile = getActiveUpdateFile();
if (!activeUpdateFile.exists()) {
activeUpdateFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
}
let fos = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(
Ci.nsIFileOutputStream
);
let flags = MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE;
fos.init(aFile, flags, PERMS_FILE, 0);
fos.init(activeUpdateFile, flags, PERMS_FILE, 0);
fos.write(aText, aText.length);
fos.close();
}
/**
* If we want the update system to treat the update we wrote out as one that it
* just installed, we need to make it think that the update state is
* "succeeded".
*/
function writeSuccessUpdateStatusFile() {
const statusFile = Services.dirsvc.get("UpdRootD", Ci.nsIFile);
statusFile.append("updates");
statusFile.append("0");
statusFile.append("update.status");
writeFile("succeeded", statusFile);
}

View File

@@ -2543,16 +2543,10 @@ var gMainPane = {
},
async checkUpdateInProgress() {
const aus = Cc["@mozilla.org/updates/update-service;1"].getService(
Ci.nsIApplicationUpdateService
);
let um = Cc["@mozilla.org/updates/update-manager;1"].getService(
Ci.nsIUpdateManager
);
// We don't want to see an idle state just because the updater hasn't
// initialized yet.
await aus.init();
if (aus.currentState == Ci.nsIApplicationUpdateService.STATE_IDLE) {
if (!um.readyUpdate && !um.downloadingUpdate) {
return;
}
@@ -2584,8 +2578,12 @@ var gMainPane = {
{}
);
if (rv != 1) {
let aus = Cc["@mozilla.org/updates/update-service;1"].getService(
Ci.nsIApplicationUpdateService
);
await aus.stopDownload();
await um.cleanupActiveUpdates();
um.cleanupReadyUpdate();
um.cleanupDownloadingUpdate();
UpdateListener.clearPendingAndActiveNotifications();
}
},

View File

@@ -39,8 +39,12 @@ const mockUpdateManager = {
registrar.registerFactory(this._originalClassId, "", this.contractId, null);
},
async getHistory() {
return [...this._updates];
getUpdateCount() {
return this._updates.length;
},
getUpdateAt(index) {
return this._updates[index];
},
_updates: [
@@ -110,17 +114,20 @@ add_task(async function () {
let dialogFrame = dialogOverlay.querySelector(".dialogFrame");
let frameDoc = dialogFrame.contentDocument;
let updates = frameDoc.querySelectorAll("richlistitem.update");
const history = await mockUpdateManager.getHistory();
// Test the update history numbers are correct
is(updates.length, history.length, "The update count is incorrect.");
is(
updates.length,
mockUpdateManager.getUpdateCount(),
"The update count is incorrect."
);
// Test the updates are displayed correctly
let update = null;
let updateData = null;
for (let i = 0; i < updates.length; ++i) {
update = updates[i];
updateData = history[i];
updateData = mockUpdateManager.getUpdateAt(i);
let testcases = [
{

View File

@@ -120,11 +120,10 @@ add_task(async function test_bug538331() {
if (testCase.openURL) {
actionsXML += ' openURL="' + testCase.openURL + '"';
}
writeFile(XML_PREFIX + actionsXML + XML_SUFFIX, getActiveUpdateFile());
writeUpdatesToXMLFile(XML_PREFIX + actionsXML + XML_SUFFIX);
} else {
writeFile(XML_EMPTY, getActiveUpdateFile());
writeUpdatesToXMLFile(XML_EMPTY);
}
writeSuccessUpdateStatusFile();
reloadUpdateManagerData(false);
@@ -197,45 +196,33 @@ function getActiveUpdateFile() {
function reloadUpdateManagerData(skipFiles = false) {
Cc["@mozilla.org/updates/update-manager;1"]
.getService(Ci.nsIUpdateManager)
.internal.reload(skipFiles);
.QueryInterface(Ci.nsIObserver)
.observe(null, "um-reload-update-data", skipFiles ? "skip-files" : "");
}
/**
* Writes the specified text to the specified file.
* Writes the updates specified to the active-update.xml file.
*
* @param {string} aText
* The string to write to the file.
* @param {nsIFile} aFile
* The file to write to.
* @param aText
* The updates represented as a string to write to the active-update.xml
* file.
*/
function writeFile(aText, aFile) {
function writeUpdatesToXMLFile(aText) {
const PERMS_FILE = 0o644;
const MODE_WRONLY = 0x02;
const MODE_CREATE = 0x08;
const MODE_TRUNCATE = 0x20;
if (!aFile.exists()) {
aFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
let activeUpdateFile = getActiveUpdateFile();
if (!activeUpdateFile.exists()) {
activeUpdateFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
}
let fos = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(
Ci.nsIFileOutputStream
);
let flags = MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE;
fos.init(aFile, flags, PERMS_FILE, 0);
fos.init(activeUpdateFile, flags, PERMS_FILE, 0);
fos.write(aText, aText.length);
fos.close();
}
/**
* If we want the update system to treat the update we wrote out as one that it
* just installed, we need to make it think that the update state is
* "succeeded".
*/
function writeSuccessUpdateStatusFile() {
const statusFile = Services.dirsvc.get("UpdRootD", Ci.nsIFile);
statusFile.append("updates");
statusFile.append("0");
statusFile.append("update.status");
writeFile("succeeded", statusFile);
}

View File

@@ -32,16 +32,15 @@ add_task(async function whats_new_page() {
Ci.nsIUpdateManager
);
await TestUtils.waitForCondition(
async () => !(await um.getReadyUpdate()),
() => !um.readyUpdate,
"Waiting for the ready update to be removed"
);
ok(!(await um.getReadyUpdate()), "There should not be a ready update");
let history;
await TestUtils.waitForCondition(async () => {
history = await um.getHistory();
return !!history[0];
}, "Waiting for the ready update to be moved to the update history");
ok(!!history[0], "There should be an update in the update history");
ok(!um.readyUpdate, "There should not be a ready update");
await TestUtils.waitForCondition(
() => !!um.getUpdateAt(0),
"Waiting for the ready update to be moved to the update history"
);
ok(!!um.getUpdateAt(0), "There should be an update in the update history");
// Leave no trace. Since this test modifies its support files put them back in
// their original state.
@@ -104,5 +103,6 @@ add_task(async function whats_new_page() {
updatesFile.remove(false);
Cc["@mozilla.org/updates/update-manager;1"]
.getService(Ci.nsIUpdateManager)
.internal.reload(false);
.QueryInterface(Ci.nsIObserver)
.observe(null, "um-reload-update-data", "");
});

View File

@@ -33,16 +33,15 @@ add_task(async function nimbus_whats_new_page() {
Ci.nsIUpdateManager
);
await TestUtils.waitForCondition(
async () => !(await um.getReadyUpdate()),
() => !um.readyUpdate,
"Waiting for the ready update to be removed"
);
ok(!(await um.getReadyUpdate()), "There should not be a ready update");
let history;
await TestUtils.waitForCondition(async () => {
history = await um.getHistory();
return !!history[0];
}, "Waiting for the ready update to be moved to the update history");
ok(!!history[0], "There should be an update in the update history");
ok(!um.readyUpdate, "There should not be a ready update");
await TestUtils.waitForCondition(
() => !!um.getUpdateAt(0),
"Waiting for the ready update to be moved to the update history"
);
ok(!!um.getUpdateAt(0), "There should be an update in the update history");
// Leave no trace. Since this test modifies its support files put them back in
// their original state.
@@ -105,5 +104,6 @@ add_task(async function nimbus_whats_new_page() {
updatesFile.remove(false);
Cc["@mozilla.org/updates/update-manager;1"]
.getService(Ci.nsIUpdateManager)
.internal.reload(false);
.QueryInterface(Ci.nsIObserver)
.observe(null, "um-reload-update-data", "");
});

View File

@@ -135,21 +135,19 @@ async function initUpdate(params) {
getVersionParams();
if (params.backgroundUpdate) {
setUpdateURL(updateURL);
await gAUS.checkForBackgroundUpdates();
gAUS.checkForBackgroundUpdates();
if (params.continueFile) {
await continueFileHandler(params.continueFile);
}
if (params.waitForUpdateState) {
let whichUpdateFn =
let whichUpdate =
params.waitForUpdateState == STATE_DOWNLOADING
? "getDownloadingUpdate"
: "getReadyUpdate";
let update;
? "downloadingUpdate"
: "readyUpdate";
await TestUtils.waitForCondition(
async () => {
update = await gUpdateManager[whichUpdateFn]();
return update && update.state == params.waitForUpdateState;
},
() =>
gUpdateManager[whichUpdate] &&
gUpdateManager[whichUpdate].state == params.waitForUpdateState,
"Waiting for update state: " + params.waitForUpdateState,
undefined,
200
@@ -160,7 +158,7 @@ async function initUpdate(params) {
});
// Display the UI after the update state equals the expected value.
Assert.equal(
update.state,
gUpdateManager[whichUpdate].state,
params.waitForUpdateState,
"The update state value should equal " + params.waitForUpdateState
);
@@ -211,28 +209,30 @@ async function processUpdateStep(step) {
}
if (checkActiveUpdate) {
let whichUpdateFn =
let whichUpdate =
checkActiveUpdate.state == STATE_DOWNLOADING
? "getDownloadingUpdate"
: "getReadyUpdate";
let update;
await TestUtils.waitForCondition(async () => {
update = await gUpdateManager[whichUpdateFn]();
return update;
}, "Waiting for active update");
Assert.ok(!!update, "There should be an active update");
? "downloadingUpdate"
: "readyUpdate";
await TestUtils.waitForCondition(
() => gUpdateManager[whichUpdate],
"Waiting for active update"
);
Assert.ok(
!!gUpdateManager[whichUpdate],
"There should be an active update"
);
Assert.equal(
update.state,
gUpdateManager[whichUpdate].state,
checkActiveUpdate.state,
"The active update state should equal " + checkActiveUpdate.state
);
} else {
Assert.ok(
!(await gUpdateManager.getReadyUpdate()),
!gUpdateManager.readyUpdate,
"There should not be a ready update"
);
Assert.ok(
!(await gUpdateManager.getDownloadingUpdate()),
!gUpdateManager.downloadingUpdate,
"There should not be a downloadingUpdate update"
);
}
@@ -244,7 +244,7 @@ async function processUpdateStep(step) {
await continueFileHandler(continueFile);
let patch = getPatchOfType(
data.patchType,
await gUpdateManager.getDownloadingUpdate()
gUpdateManager.downloadingUpdate
);
// The update is removed early when the last download fails so check
// that there is a patch before proceeding.

View File

@@ -43,7 +43,6 @@ class PurgeHTTPCacheAtShutdownTestCase(MarionetteTestCase):
return Services.dirsvc.get("UpdRootD", Ci.nsIFile).parent.parent.path;
"""
)
os.makedirs(path, exist_ok=True)
self.lock_dir = Path(path)
def assertNoLocks(self):

View File

@@ -10,7 +10,4 @@ user_pref("dom.input_events.security.minNumTicks", 0);
user_pref("dom.input_events.security.minTimeElapsedInMS", 0);
// Set address autofill to true for tests
user_pref("extensions.formautofill.addresses.experiments.enabled", true);
// Turn off update
user_pref("app.update.disabledForTesting", true);
user_pref("extensions.formautofill.addresses.experiments.enabled", true);

View File

@@ -5,6 +5,3 @@
// Base preferences file used by the mochitest
/* globals user_pref */
/* eslint quotes: 0 */
// Turn off update
user_pref("app.update.disabledForTesting", true);

View File

@@ -23,9 +23,6 @@ user_pref("general.smoothScroll", true);
// storage access API spec for secure contexts.
user_pref("dom.storage_access.dont_grant_insecure_contexts", false);
// Turn off update
user_pref("app.update.disabledForTesting", true);
// This feature restricts to add history when accessing to web page is too
// frequently, it assumes real human accesses them by clicking and key types.
// Therefore, in the mochitest, as the frequently in common browser tests can be

View File

@@ -97,5 +97,3 @@ user_pref("startup.homepage_welcome_url.additional", "");
user_pref("browser.tabs.remote.systemTriggeredAboutBlankAnywhere", true);
// Make sure speech dispatcher notification error does not impact how we measure visual perception in raptor tests
user_pref("media.webspeech.synth.dont_notify_on_error", true);
// Turn off update
user_pref("app.update.disabledForTesting", true);

View File

@@ -9,5 +9,3 @@ user_pref("dom.timeout.enable_budget_timer_throttling", false);
// TODO: Bug 1795750 - Re-enable this pref when we have a new version of the
// Quitter XPI with a simpler version format.
user_pref("extensions.webextensions.warnings-as-errors", false);
// Turn off update
user_pref("app.update.disabledForTesting", true);

View File

@@ -14,6 +14,3 @@ user_pref("extensions.webextensions.warnings-as-errors", false);
// disable telemetry bug 1639148
user_pref("toolkit.telemetry.server", "");
user_pref("telemetry.fog.test.localhost_port", -1);
// Turn off update
user_pref("app.update.disabledForTesting", true);

View File

@@ -51,6 +51,3 @@ user_pref('media.autoplay.ask-permission', true);
user_pref('media.autoplay.blocking_policy', 1);
user_pref('media.allowed-to-play.enabled', false);
user_pref('media.block-autoplay-until-in-foreground', true);
// Turn off update
user_pref("app.update.disabledForTesting", true);

View File

@@ -103,5 +103,3 @@ user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true);
user_pref("layout.css.prefers-color-scheme.content-override", 1);
// Force OffscreenCanvas support
user_pref("gfx.offscreencanvas.enabled", true);
// Turn off update
user_pref("app.update.disabledForTesting", true);

View File

@@ -26,5 +26,3 @@ user_pref("dom.gamepad.non_standard_events.enabled", true);
// Enable form autofill feature testing.
user_pref("extensions.formautofill.addresses.available", "on");
user_pref("extensions.formautofill.creditCards.available", "on");
// Turn off update
user_pref("app.update.disabledForTesting", true);

View File

@@ -228,6 +228,3 @@ user_pref("security.data_uri.block_toplevel_data_uri_navigations", false);
// We use data: to tell the Quitter extension to quit.
user_pref("security.data_uri.block_toplevel_data_uri_navigations", false);
// Turn off update
user_pref("app.update.disabledForTesting", true);

View File

@@ -7,5 +7,3 @@
// TODO: Bug 1795750 - Re-enable this pref when we have a new version of the
// Quitter XPI with a simpler version format.
user_pref("extensions.webextensions.warnings-as-errors", false);
// Turn off update
user_pref("app.update.disabledForTesting", true);

View File

@@ -94,5 +94,3 @@ user_pref("security.webauthn.enable_conditional_mediation", true);
user_pref("network.captive-portal-service.enabled", false);
// Enable http2 websockets support
user_pref("network.http.http2.websockets", true);
// Turn off update
user_pref("app.update.disabledForTesting", true);

View File

@@ -37,5 +37,3 @@ user_pref("browser.topsites.contile.enabled", false);
user_pref("browser.newtabpage.activity-stream.showSponsoredTopSites", false);
user_pref("security.turn_off_all_security_so_that_viruses_can_take_over_this_computer", true);
user_pref("preferences.force-disable.check.once.policy", true);
// Turn off update
user_pref("app.update.disabledForTesting", true);

View File

@@ -9,7 +9,6 @@ import { TelemetryUtils } from "resource://gre/modules/TelemetryUtils.sys.mjs";
import { ObjectUtils } from "resource://gre/modules/ObjectUtils.sys.mjs";
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
import { UpdateUtils } from "resource://gre/modules/UpdateUtils.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const Utils = TelemetryUtils;
@@ -34,13 +33,6 @@ ChromeUtils.defineLazyGetter(lazy, "fxAccounts", () => {
).getFxAccountsSingleton();
});
XPCOMUtils.defineLazyServiceGetter(
lazy,
"UpdateServiceStub",
"@mozilla.org/updates/update-service-stub;1",
"nsIApplicationUpdateServiceStub"
);
// The maximum length of a string (e.g. description) in the addons section.
const MAX_ADDON_STRING_LENGTH = 100;
// The maximum length of a string value in the settings.attribution object.
@@ -1626,7 +1618,7 @@ EnvironmentCache.prototype = {
intl: Policy._intlLoaded ? getIntlSettings() : {},
update: {
channel: updateChannel,
enabled: !lazy.UpdateServiceStub.updateDisabled,
enabled: !Services.policies || Services.policies.isAllowed("appUpdate"),
},
userPrefs: this._getPrefData(),
sandbox: this._getSandboxData(),

View File

@@ -46,6 +46,23 @@ export var UpdatePing = {
Services.obs.addObserver(this, UPDATE_STAGED_TOPIC);
},
/**
* Get the information about the update we're going to apply/was just applied
* from the update manager.
*
* @return {nsIUpdate} The information about the update, if available, or null.
*/
_getActiveUpdate() {
let updateManager = Cc["@mozilla.org/updates/update-manager;1"].getService(
Ci.nsIUpdateManager
);
if (!updateManager || !updateManager.readyUpdate) {
return null;
}
return updateManager.readyUpdate;
},
/**
* Generate an "update" ping with reason "success" and dispatch it
* to the Telemetry system.
@@ -67,10 +84,7 @@ export var UpdatePing = {
// update manager should still have information about the active update: given the
// previous assumptions, we can simply get the channel from the update and assume
// it matches with the state previous to the update.
let updateManager = Cc["@mozilla.org/updates/update-manager;1"].getService(
Ci.nsIUpdateManager
);
let update = updateManager ? updateManager.updateInstalledAtStartup : null;
let update = this._getActiveUpdate();
const payload = {
reason: "success",
@@ -101,7 +115,7 @@ export var UpdatePing = {
* @param {String} aUpdateState The state of the downloaded patch. See
* nsIUpdateService.idl for a list of possible values.
*/
async _handleUpdateReady(aUpdateState) {
_handleUpdateReady(aUpdateState) {
const ALLOWED_STATES = [
"applied",
"applied-service",
@@ -116,10 +130,7 @@ export var UpdatePing = {
// Get the information about the update we're going to apply from the
// update manager.
let updateManager = Cc["@mozilla.org/updates/update-manager;1"].getService(
Ci.nsIUpdateManager
);
let update = updateManager ? await updateManager.getReadyUpdate() : null;
let update = this._getActiveUpdate();
if (!update) {
this._log.trace(
"Cannot get the update manager or no update is currently active."
@@ -153,10 +164,10 @@ export var UpdatePing = {
/**
* The notifications handler.
*/
async observe(aSubject, aTopic, aData) {
observe(aSubject, aTopic, aData) {
this._log.trace("observe - aTopic: " + aTopic);
if (aTopic == UPDATE_DOWNLOADED_TOPIC || aTopic == UPDATE_STAGED_TOPIC) {
await this._handleUpdateReady(aData);
this._handleUpdateReady(aData);
}
},

View File

@@ -44,8 +44,7 @@ add_task(async function test_updatePing() {
activeUpdateFile.remove(false);
reloadUpdateManagerData(true);
});
writeFile(XML_UPDATE, getActiveUpdateFile());
writeSuccessUpdateStatusFile();
writeUpdatesToXMLFile(XML_UPDATE);
reloadUpdateManagerData(false);
// Start monitoring the ping archive.
@@ -135,45 +134,33 @@ function getActiveUpdateFile() {
function reloadUpdateManagerData(skipFiles = false) {
Cc["@mozilla.org/updates/update-manager;1"]
.getService(Ci.nsIUpdateManager)
.internal.reload(skipFiles);
.QueryInterface(Ci.nsIObserver)
.observe(null, "um-reload-update-data", skipFiles ? "skip-files" : "");
}
/**
* Writes the specified text to the specified file.
* Writes the updates specified to the active-update.xml file.
*
* @param {string} aText
* The string to write to the file.
* @param {nsIFile} aFile
* The file to write to.
* @param aText
* The updates represented as a string to write to the active-update.xml
* file.
*/
function writeFile(aText, aFile) {
function writeUpdatesToXMLFile(aText) {
const PERMS_FILE = 0o644;
const MODE_WRONLY = 0x02;
const MODE_CREATE = 0x08;
const MODE_TRUNCATE = 0x20;
if (!aFile.exists()) {
aFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
let activeUpdateFile = getActiveUpdateFile();
if (!activeUpdateFile.exists()) {
activeUpdateFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
}
let fos = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(
Ci.nsIFileOutputStream
);
let flags = MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE;
fos.init(aFile, flags, PERMS_FILE, 0);
fos.init(activeUpdateFile, flags, PERMS_FILE, 0);
fos.write(aText, aText.length);
fos.close();
}
/**
* If we want the update system to treat the update we wrote out as one that it
* just installed, we need to make it think that the update state is
* "succeeded".
*/
function writeSuccessUpdateStatusFile() {
const statusFile = Services.dirsvc.get("UpdRootD", Ci.nsIFile);
statusFile.append("updates");
statusFile.append("0");
statusFile.append("update.status");
writeFile("succeeded", statusFile);
}

View File

@@ -278,14 +278,14 @@ export class AppUpdater {
if (updateState == Ci.nsIApplicationUpdateService.STATE_DOWNLOADING) {
LOG("AppUpdater:check - downloading");
this.#update = await this.um.getDownloadingUpdate();
this.#update = this.um.downloadingUpdate;
await this.#downloadUpdate();
return;
}
if (updateState == Ci.nsIApplicationUpdateService.STATE_STAGING) {
LOG("AppUpdater:check - staging");
this.#update = await this.um.getReadyUpdate();
this.#update = this.um.readyUpdate;
await this.#awaitStagingComplete();
return;
}
@@ -326,7 +326,7 @@ export class AppUpdater {
}
LOG("AppUpdater:check - Update check succeeded");
this.#update = await this.aus.selectUpdate(result.updates);
this.#update = this.aus.selectUpdate(result.updates);
if (!this.#update) {
LOG("AppUpdater:check - result: NO_UPDATES_FOUND");
this.#setStatus(AppUpdater.STATUS.NO_UPDATES_FOUND);
@@ -371,9 +371,8 @@ export class AppUpdater {
LOG("AppUpdater:check - Got user approval. Proceeding with download");
// If we resolved because of `aus.stateTransition`, we may actually be
// downloading a different update now.
const downloadingUpdate = await this.um.getDownloadingUpdate();
if (downloadingUpdate) {
this.#update = downloadingUpdate;
if (this.um.downloadingUpdate) {
this.#update = this.um.downloadingUpdate;
}
} else {
LOG(
@@ -420,8 +419,8 @@ export class AppUpdater {
async #downloadUpdate() {
this.#setStatus(AppUpdater.STATUS.DOWNLOADING);
let result = await this.aus.downloadUpdate(this.#update, false);
if (result != Ci.nsIApplicationUpdateService.DOWNLOAD_SUCCESS) {
let success = await this.aus.downloadUpdate(this.#update, false);
if (!success) {
LOG("AppUpdater:#downloadUpdate - downloadUpdate failed.");
this.#setStatus(AppUpdater.STATUS.DOWNLOAD_FAILED);
return;
@@ -436,21 +435,15 @@ export class AppUpdater {
* is reached.
*/
async #awaitDownloadComplete() {
// These cases are unlikely, but we might have just completed really fast.
let updateState = this.aus.currentState;
switch (updateState) {
case Ci.nsIApplicationUpdateService.STATE_IDLE:
LOG("AppUpdater:#awaitDownloadComplete - Quick failure.");
this.#setStatus(AppUpdater.STATUS.DOWNLOAD_FAILED);
return;
case Ci.nsIApplicationUpdateService.STATE_STAGING:
LOG("AppUpdater:#awaitDownloadComplete - Quick staging.");
await this.#awaitStagingComplete();
return;
case Ci.nsIApplicationUpdateService.STATE_PENDING:
LOG("AppUpdater:#awaitDownloadComplete - Quick pending.");
this.#onReadyToRestart();
return;
if (
updateState != Ci.nsIApplicationUpdateService.STATE_DOWNLOADING &&
updateState != Ci.nsIApplicationUpdateService.STATE_SWAP
) {
throw new Error(
"AppUpdater:#awaitDownloadComplete invoked in unexpected state: " +
this.aus.getStateName(updateState)
);
}
// We may already be in the `DOWNLOADING` state, depending on how we entered
@@ -560,25 +553,12 @@ export class AppUpdater {
* is reached.
*/
async #awaitStagingComplete() {
// These cases are unlikely, but we might have just completed really fast.
let updateState = this.aus.currentState;
switch (updateState) {
case Ci.nsIApplicationUpdateService.STATE_IDLE:
LOG("AppUpdater:#awaitStagingComplete - Quick failure.");
this.#setStatus(AppUpdater.STATUS.DOWNLOAD_FAILED);
return;
case Ci.nsIApplicationUpdateService.STATE_DOWNLOADING:
LOG("AppUpdater:#awaitStagingComplete - Quick fallback.");
await this.#awaitDownloadComplete();
return;
case Ci.nsIApplicationUpdateService.STATE_PENDING:
LOG("AppUpdater:#awaitStagingComplete - Quick pending.");
this.#onReadyToRestart();
return;
case Ci.nsIApplicationUpdateService.STATE_SWAP:
LOG("AppUpdater:#awaitStagingComplete - Quick swap.");
await this.#awaitDownloadComplete();
return;
if (updateState != Ci.nsIApplicationUpdateService.STATE_STAGING) {
throw new Error(
"AppUpdater:#awaitStagingComplete invoked in unexpected state: " +
this.aus.getStateName(updateState)
);
}
LOG("AppUpdater:#awaitStagingComplete - Setting status STAGING.");
@@ -752,9 +732,9 @@ export class AppUpdater {
// During an update swap, the new update will initially be stored in
// `downloadingUpdate`. Part way through, it will be moved into
// `readyUpdate` and `downloadingUpdate` will be set to `null`.
this.#update = await this.um.getDownloadingUpdate();
this.#update = this.um.downloadingUpdate;
if (!this.#update) {
this.#update = await this.um.getReadyUpdate();
this.#update = this.um.readyUpdate;
}
await this.#awaitDownloadComplete();

View File

@@ -59,9 +59,17 @@ export const backgroundTaskTimeoutSec = Services.prefs.getIntPref(
async function _attemptBackgroundUpdate() {
let SLUG = "_attemptBackgroundUpdate";
// Most likely we will implicitly initialize update at some point, but make
// sure post update processing gets run, just in case.
await lazy.UpdateService.init();
// Here's where we do `post-update-processing`. Creating the stub invokes the
// `UpdateServiceStub()` constructor, which handles various migrations (which should not be
// necessary, but we want to run for consistency and any migrations added in the future) and then
// dispatches `post-update-processing` (if appropriate). We want to do this very early, so that
// the real update service is in its fully initialized state before any usage.
lazy.log.debug(
`${SLUG}: creating UpdateServiceStub() for "post-update-processing"`
);
Cc["@mozilla.org/updates/update-service-stub;1"].createInstance(
Ci.nsISupports
);
lazy.log.debug(
`${SLUG}: checking for preconditions necessary to update this installation`

View File

@@ -69,7 +69,7 @@ export var UpdateListener = {
return Services.prefs.getIntPref("app.update.badgeWaitTime", 4 * 24 * 3600); // 4 days
},
async getSuppressedPromptDelay() {
get suppressedPromptDelay() {
// Return the time (in milliseconds) after which a suppressed prompt should
// be shown. Either 14 days from the last build time, or 7 days from the
// last update time; whichever comes sooner. If build time is not available
@@ -91,8 +91,7 @@ export var UpdateListener = {
buildId.slice(10, 12),
buildId.slice(12, 14)
).getTime() ?? 0;
const updateHistory = await lazy.UpdateManager.getHistory();
let updateTime = updateHistory[0]?.installDate ?? 0;
let updateTime = lazy.UpdateManager.getUpdateAt(0)?.installDate ?? 0;
// Check that update/build times are at most 24 hours after now.
if (buildTime - now > this.promptMaxFutureVariation) {
buildTime = 0;
@@ -329,7 +328,7 @@ export var UpdateListener = {
);
},
async scheduleUpdateAvailableNotification(update) {
scheduleUpdateAvailableNotification(update) {
// Show a badge/banner-only notification immediately.
this.showUpdateAvailableNotification(update, true);
// Track the latest update, since we will almost certainly have a new update
@@ -343,13 +342,12 @@ export var UpdateListener = {
// doorhanger would be scheduled at least once per day. If the user
// downloads the first update, we don't want to keep alerting them.
if (!this.availablePromptScheduled) {
const suppressedPromptDelay = await this.getSuppressedPromptDelay();
this.addTimeout(Math.max(0, suppressedPromptDelay), () => {
this.addTimeout(Math.max(0, this.suppressedPromptDelay), () => {
// If we downloaded or installed an update via the badge or banner
// while the timer was running, bail out of showing the doorhanger.
if (
lazy.AppUpdateService.currentState !=
Ci.nsIApplicationUpdateService.STATE_IDLE
lazy.UpdateManager.downloadingUpdate ||
lazy.UpdateManager.readyUpdate
) {
return;
}
@@ -445,13 +443,13 @@ export var UpdateListener = {
}
},
async handleUpdateAvailable(update, status) {
handleUpdateAvailable(update, status) {
switch (status) {
case "show-prompt":
// If an update is available, show an update available doorhanger unless
// PREF_APP_UPDATE_SUPPRESS_PROMPTS is true (only on Nightly).
if (AppConstants.NIGHTLY_BUILD && lazy.SUPPRESS_PROMPTS) {
await this.scheduleUpdateAvailableNotification(update);
this.scheduleUpdateAvailableNotification(update);
} else {
this.showUpdateAvailableNotification(update, false);
}
@@ -493,7 +491,7 @@ export var UpdateListener = {
this.clearPendingAndActiveNotifications();
},
async observe(subject, topic, status) {
observe(subject, topic, status) {
let update = subject && subject.QueryInterface(Ci.nsIUpdate);
switch (topic) {
@@ -503,7 +501,7 @@ export var UpdateListener = {
// in case it is set.
Services.prefs.clearUserPref(PREF_APP_UPDATE_UNSUPPORTED_URL);
}
await this.handleUpdateAvailable(update, status);
this.handleUpdateAvailable(update, status);
break;
case "update-downloading":
this.handleUpdateDownloading(status);

File diff suppressed because it is too large Load Diff

View File

@@ -3,9 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
import { FileUtils } from "resource://gre/modules/FileUtils.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
const lazy = {};
@@ -13,25 +12,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
UpdateLog: "resource://gre/modules/UpdateLog.sys.mjs",
});
if (AppConstants.ENABLE_WEBDRIVER) {
XPCOMUtils.defineLazyServiceGetter(
lazy,
"Marionette",
"@mozilla.org/remote/marionette;1",
"nsIMarionette"
);
XPCOMUtils.defineLazyServiceGetter(
lazy,
"RemoteAgent",
"@mozilla.org/remote/agent;1",
"nsIRemoteAgent"
);
} else {
lazy.Marionette = { running: false };
lazy.RemoteAgent = { running: false };
}
const DIR_UPDATES = "updates";
const FILE_UPDATE_STATUS = "update.status";
@@ -43,7 +23,6 @@ const KEY_OLD_UPDROOT = "OldUpdRootD";
// happens for every install rather than once per profile)
const PREF_PREFIX_UPDATE_DIR_MIGRATED = "app.update.migrated.updateDir3.";
const PREF_APP_UPDATE_ALTUPDATEDIRPATH = "app.update.altUpdateDirPath";
const PREF_APP_UPDATE_DISABLEDFORTESTING = "app.update.disabledForTesting";
function getUpdateBaseDirNoCreate() {
if (Cu.isInAutomation) {
@@ -77,163 +56,55 @@ function getUpdateBaseDirNoCreate() {
return FileUtils.getDir(KEY_UPDROOT, []);
}
export class UpdateServiceStub {
#initUpdatePromise;
#initStubHasRun = false;
export function UpdateServiceStub() {
LOG("UpdateServiceStub - Begin.");
/**
* See nsIUpdateService.idl
*/
async init() {
await this.#init(false);
}
async initUpdate() {
await this.#init(true);
}
let updateDir = getUpdateBaseDirNoCreate();
let prefUpdateDirMigrated =
PREF_PREFIX_UPDATE_DIR_MIGRATED + updateDir.leafName;
#initOnlyStub(updateDir) {
// We may need to migrate update data
let prefUpdateDirMigrated =
PREF_PREFIX_UPDATE_DIR_MIGRATED + updateDir.leafName;
if (
AppConstants.platform == "win" &&
!Services.prefs.getBoolPref(prefUpdateDirMigrated, false)
) {
Services.prefs.setBoolPref(prefUpdateDirMigrated, true);
try {
migrateUpdateDirectory();
} catch (ex) {
// For the most part, migrateUpdateDirectory() catches its own
// errors. But there are technically things that could happen that
// might not be caught, like nsIFile.parent or nsIFile.append could
// unexpectedly fail.
// So we will catch any errors here, just in case.
LOG(
`UpdateServiceStub:UpdateServiceStub Failed to migrate update ` +
`directory. Exception: ${ex}`
);
}
}
}
let statusFile = updateDir;
statusFile.append(DIR_UPDATES);
statusFile.append("0");
statusFile.append(FILE_UPDATE_STATUS);
updateDir = null; // We don't need updateDir anymore, plus now its nsIFile
// contains the status file's path
async #initUpdate() {
// Ensure that the constructors for the update services have run.
const aus = Cc["@mozilla.org/updates/update-service;1"].getService(
Ci.nsIApplicationUpdateService
);
Cc["@mozilla.org/updates/update-manager;1"].getService(Ci.nsIUpdateManager);
Cc["@mozilla.org/updates/update-checker;1"].getService(Ci.nsIUpdateChecker);
// Run update service initialization
await aus.internal.init();
}
async #init(force_update_init) {
if (this.updateDisabled) {
return;
}
// We call into this from many places to ensure that initialization is done,
// so we want to optimize for the case where initialization is already
// finished.
if (this.#initUpdatePromise) {
try {
await this.#initUpdatePromise;
} catch (ex) {
// This will already have been logged when the error first happened, we
// don't need to log it again now.
}
return;
}
LOG(`UpdateServiceStub - Begin (force_update_init=${force_update_init})`);
let initUpdate = force_update_init;
// We may need to migrate update data
if (
AppConstants.platform == "win" &&
!Services.prefs.getBoolPref(prefUpdateDirMigrated, false)
) {
Services.prefs.setBoolPref(prefUpdateDirMigrated, true);
try {
const updateDir = getUpdateBaseDirNoCreate();
if (!this.#initStubHasRun) {
this.#initStubHasRun = true;
try {
this.#initOnlyStub(updateDir);
} catch (ex) {
LOG(
`UpdateServiceStub - Stub initialization failed: ${ex}: ${ex.stack}`
);
}
}
try {
if (!initUpdate) {
const statusFile = updateDir.clone();
statusFile.append(DIR_UPDATES);
statusFile.append("0");
statusFile.append(FILE_UPDATE_STATUS);
initUpdate = statusFile.exists();
}
} catch (ex) {
LOG(
`UpdateServiceStub - Failed to generate the status file: ${ex}: ${ex.stack}`
);
}
} catch (e) {
migrateUpdateDirectory();
} catch (ex) {
// For the most part, migrateUpdateDirectory() catches its own errors.
// But there are technically things that could happen that might not be
// caught, like nsIFile.parent or nsIFile.append could unexpectedly fail.
// So we will catch any errors here, just in case.
LOG(
`UpdateServiceStub - Failed to get update directory: ${e}: ${e.stack}`
`UpdateServiceStub:UpdateServiceStub Failed to migrate update ` +
`directory. Exception: ${ex}`
);
}
if (initUpdate) {
this.#initUpdatePromise = this.#initUpdate();
try {
await this.#initUpdatePromise;
} catch (ex) {
LOG(`UpdateServiceStub - Init failed: ${ex}: ${ex.stack}`);
}
}
}
/**
* See nsIUpdateService.idl
*/
get updateDisabledForTesting() {
return (
(Cu.isInAutomation ||
lazy.Marionette.running ||
lazy.RemoteAgent.running) &&
Services.prefs.getBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING, false)
);
// If the update.status file exists then initiate post update processing.
if (statusFile.exists()) {
let aus = Cc["@mozilla.org/updates/update-service;1"]
.getService(Ci.nsIApplicationUpdateService)
.QueryInterface(Ci.nsIObserver);
aus.observe(null, "post-update-processing", "");
}
/**
* See nsIUpdateService.idl
*/
get updateDisabled() {
return (
(Services.policies && !Services.policies.isAllowed("appUpdate")) ||
this.updateDisabledForTesting ||
Services.sysinfo.getProperty("isPackagedApp")
);
}
async observe(_subject, topic, _data) {
switch (topic) {
// This is sort of the "default" way of being initialized. The
// "@mozilla.org/updates/update-service-stub;1" contract definition in
// `components.conf` registers us for this notification, which we use to
// trigger initialization. Note, however, that this calls only `init` and
// not `initUpdate`.
case "profile-after-change":
await this.init();
break;
}
}
classID = Components.ID("{e43b0010-04ba-4da6-b523-1f92580bc150}");
QueryInterface = ChromeUtils.generateQI([
Ci.nsIApplicationUpdateServiceStub,
Ci.nsIObserver,
]);
}
UpdateServiceStub.prototype = {
observe() {},
classID: Components.ID("{e43b0010-04ba-4da6-b523-1f92580bc150}"),
QueryInterface: ChromeUtils.generateQI(["nsIObserver"]),
};
/**
* This function should be called when there are files in the old update
* directory that may need to be migrated to the new update directory.

View File

@@ -9,19 +9,21 @@ var gUpdateHistory = {
/**
* Initialize the User Interface
*/
async onLoad() {
onLoad() {
this._view = document.getElementById("historyItems");
var um = Cc["@mozilla.org/updates/update-manager;1"].getService(
Ci.nsIUpdateManager
);
const updateHistory = await um.getHistory();
if (updateHistory.length) {
var uc = um.getUpdateCount();
if (uc) {
while (this._view.hasChildNodes()) {
this._view.firstChild.remove();
}
for (const update of updateHistory) {
for (var i = 0; i < uc; ++i) {
var update = um.getUpdateAt(i);
if (!update || !update.name) {
continue;
}

View File

@@ -30,7 +30,7 @@ const gUpdateElevationDialog = {
button.label = label;
button.setAttribute("accesskey", this.getAUSString(string + ".accesskey"));
},
async onLoad() {
onLoad() {
this.strings = document.getElementById("updateStrings");
this.brandName = document
.getElementById("brandStrings")
@@ -39,7 +39,7 @@ const gUpdateElevationDialog = {
let um = Cc["@mozilla.org/updates/update-manager;1"].getService(
Ci.nsIUpdateManager
);
let update = await um.getReadyUpdate();
let update = um.readyUpdate;
let updateFinishedName = document.getElementById("updateFinishedName");
updateFinishedName.value = update.name;

View File

@@ -288,21 +288,6 @@ interface nsIUpdateCheck : nsISupports
readonly attribute Promise result;
};
/**
* An interface into the internals of the update checker. These should only be
* accessed from within update code and tests.
*/
[scriptable, uuid(e27f0336-ad86-4c31-bfee-1d96100521f5)]
interface nsIUpdateCheckerInternal : nsISupports
{
/**
* This is identical to the corresponding function in `nsIUpdateChecker`, but
* this version does not ensure the update system has been initialized before
* being called.
*/
nsIUpdateCheck checkForUpdates(in long checkType);
};
/**
* An interface describing an object that knows how to check for updates. It can
* perform multiple update checks simultaneously or consolidate multiple check
@@ -378,45 +363,6 @@ interface nsIUpdateChecker : nsISupports
* Ends all pending update checks.
*/
void stopAllChecks();
/**
* See nsIUpdateCheckerInternal for details.
*/
readonly attribute nsIUpdateCheckerInternal internal;
};
/**
* An interface into the internals of the update service. These should only be
* accessed from within update code and tests.
*/
[scriptable, uuid(7f39bc95-eaf8-4adc-990b-0fc0734f85fa)]
interface nsIApplicationUpdateServiceInternal : nsISupports
{
/**
* To initialize the update system, use the init method on
* `nsIApplicationUpdateService` or `nsIApplicationUpdateServiceStub`. This
* method is invoked as part of the update initialization process, but is not
* an entry point to it.
*
* @returns Promise<undefined>
*/
Promise init();
/**
* These are identical to the corresponding functions in
* `nsIApplicationUpdateService`, but these versions do not ensure the update
* system has been initialized before being called.
*/
Promise downloadUpdate(in nsIUpdate update);
Promise stopDownload();
/**
* Runs post update processing, even if it has already run. This should only
* be done in testing.
*
* @returns Promise<undefined>
*/
Promise postUpdateProcessing();
};
/**
@@ -427,35 +373,21 @@ interface nsIApplicationUpdateServiceInternal : nsISupports
[scriptable, uuid(1107d207-a263-403a-b268-05772ec10757)]
interface nsIApplicationUpdateService : nsISupports
{
/**
* Initializes the update system. It is typically not necessary to call this
* since the public methods that require initialization to be meaningful
* ensure that initialization has been performed. But this can be useful to
* spur the updater to resume or complete any in-progress updates from
* previous browser sessions.
*
* @returns Promise<undefined>
*/
Promise init();
/**
* Checks for available updates in the background using the listener provided
* by the application update service for background checks.
* @returns A promise resolving to `true` if the update check was started, or
* one resolving to `false` if not. Note that the check starting does
* not necessarily mean that the check will succeed or that an
* update will be downloaded.
* @returns true if the update check was started, false if not. Note that the
* check starting does not necessarily mean that the check will
* succeed or that an update will be downloaded.
*/
Promise checkForBackgroundUpdates();
boolean checkForBackgroundUpdates();
/**
* Selects the best update to install from a list of available updates.
* @param updates
* An array of updates that are available
* @returns Promise<nsIUpdate>
* Resolves with the best update to install.
*/
Promise selectUpdate(in Array<nsIUpdate> updates);
nsIUpdate selectUpdate(in Array<nsIUpdate> updates);
/**
* Adds a listener that receives progress and state information about the
@@ -478,28 +410,14 @@ interface nsIApplicationUpdateService : nsISupports
*/
void removeDownloadListener(in nsIRequestObserver listener);
/**
* The below are the possible return values for `downloadUpdate()`.
*/
// An update download was started.
const long DOWNLOAD_SUCCESS = 1;
// The update download is already in-progress but it is using a download
// method that we can't use in the background and Firefox is currently running
// as a background task.
const long DOWNLOAD_FAILURE_CANNOT_RESUME_IN_BACKGROUND = 2;
// The update download cannot be started for a reason that doesn't have a more
// specific failure code.
const long DOWNLOAD_FAILURE_GENERIC = 3;
/**
* Starts downloading the update passed. Once the update is downloaded, it
* will automatically be prepared for installation.
*
* @param update
* The update to download.
* @returns A promise that resolves with the integer value of one of the
* `DOWNLOAD_*` constants above indicating whether or not the
* download was started.
* @returns A promise that resolves to `true` if an update download was
* started, otherwise `false.
*/
Promise downloadUpdate(in nsIUpdate update);
@@ -709,11 +627,6 @@ interface nsIApplicationUpdateService : nsISupports
* A Promise that resolves immediately after `currentState` changes.
*/
readonly attribute Promise stateTransition;
/**
* See nsIApplicationUpdateServiceInternal for details.
*/
readonly attribute nsIApplicationUpdateServiceInternal internal;
};
/**
@@ -823,39 +736,6 @@ interface nsIUpdateSyncManager : nsISupports
void resetLock([optional] in nsIFile anAppFile);
};
/**
* An interface into the internals of the update manager. These should only be
* accessed from within update code and tests.
*/
[scriptable, uuid(a5739dda-b94f-47e1-a6f3-224d46d6cb8c)]
interface nsIUpdateManagerInternal : nsISupports
{
/**
* ** Test-only Method **
*
* Reloads the update manager's data. This will only work in testing.
* @param skipFiles
* If `true`, don't reload data from the XMLs, just clear out existing
* data.
*/
void reload(in boolean skipFiles);
/**
* These are identical to the functions with the same name in
* `nsIUpdateManager`, but these versions do not ensure the update system has
* been initialized before being called.
*/
Array<nsIUpdate> getHistory();
void addUpdateToHistory(in nsIUpdate update);
// Corresponds to `nsIUpdateManager.getReadyUpdate()`, but also provides
// write access.
attribute nsIUpdate readyUpdate;
// Corresponds to `nsIUpdateManager.getDownloadingUpdate()`, but also provides
// write access.
attribute nsIUpdate downloadingUpdate;
Promise refreshUpdateStatus();
};
/**
* An interface describing a global application service that maintains a list
* of updates previously performed as well as the current active update.
@@ -864,45 +744,39 @@ interface nsIUpdateManagerInternal : nsISupports
interface nsIUpdateManager : nsISupports
{
/**
* @returns Promise<Array<nsIUpdate>>
* Resolves with an array describing the update history. The first
* element in the array represents the most recent item in the
* history.
* Gets the update at the specified index
* @param index
* The index within the updates array
* @returns The nsIUpdate object at the specified index
*/
Promise getHistory();
nsIUpdate getUpdateAt(in long index);
/**
* Returns a Promise that resolves with the nsIUpdate that has been
* downloaded, or null if there isn't one.
* Gets the total number of updates in the history list.
*/
Promise getReadyUpdate();
long getUpdateCount();
/**
* Returns a Promise that resolves with the nsIUpdate that is currently
* downloading, or null if there isn't one.
* The update that has been downloaded, or null if there isn't one.
*/
attribute nsIUpdate readyUpdate;
/**
* The update that is currently downloading, or null if there isn't one.
* An update is no longer considered to be downloading once onStopRequest is
* called. This means that both onStopRequest handlers for download listeners
* and observers of the "update-downloaded" topic should expect the update
* that was just downloaded to be stored in readyUpdate, not
* downloadingUpdate.
*/
Promise getDownloadingUpdate();
/**
* If Firefox installed an update at the launch of the current session, this
* will contain that update. If not, this will be `null`.
*/
readonly attribute nsIUpdate updateInstalledAtStartup;
attribute nsIUpdate downloadingUpdate;
/**
* Adds the specified update to the update history. The update history is
* limited to 10 items, so this may also remove the last item from the
* history.
* @param update
* The update to add to the history.
* @returns Promise<undefined>
*/
Promise addUpdateToHistory(in nsIUpdate update);
void addUpdateToHistory(in nsIUpdate update);
/**
* Saves all updates to disk.
@@ -923,15 +797,13 @@ interface nsIUpdateManager : nsISupports
void elevationOptedIn();
/**
* These functions clean up and remove an active update without applying
* These functions both clean up and remove an active update without applying
* it. The first function does this for the update that is currently being
* downloaded. The second function does this for the update that has already
* been downloaded. The third function does this for both updates.
* @returns Promise<undefined>
* been downloaded.
*/
Promise cleanupDownloadingUpdate();
Promise cleanupReadyUpdate();
Promise cleanupActiveUpdates();
void cleanupDownloadingUpdate();
void cleanupReadyUpdate();
/**
* Runs cleanup that ought to happen on a Firefox paveover install to
@@ -953,48 +825,4 @@ interface nsIUpdateManager : nsISupports
* conveys that the cleanup has completed.
*/
Promise doUninstallCleanup();
/**
* See nsIUpdateManagerInternal for details.
*/
readonly attribute nsIUpdateManagerInternal internal;
};
/**
* A lightweight interface that we can load early in startup that gives us very
* limited access to the update system without the startup costs of loading
* nsIApplicationUpdateService.
*/
[scriptable, uuid(3ca17ada-8501-496f-bbe7-6a9f1c28eb2d)]
interface nsIApplicationUpdateServiceStub : nsISupports
{
/**
* This does the standard initialization of the update service stub. The
* primary effect of this is to initialize the update system (the same effect
* as `initUpdate`), but only if there are updates from a previous browser
* session. This allows us to avoid loading the update system so early if it
* would just be sitting idle until the update timer fires or the user visits
* the update UI.
*
* @returns Promise<undefined>
*/
Promise init();
/**
* This is identical to `nsIApplicationUpdateService.init()`.
*
* @returns Promise<undefined>
*/
Promise initUpdate();
/**
* This is identical to `nsIApplicationUpdateService.disabled`.
*/
readonly attribute boolean updateDisabled;
/**
* This will be `true` if update is disabled specifically because we are
* running a test that didn't opt-in to updating.
*/
readonly attribute boolean updateDisabledForTesting;
};

View File

@@ -34,9 +34,9 @@ add_task(async function aboutDialog_backgroundCheck_multiUpdate() {
checkActiveUpdate: { state: STATE_APPLIED },
continueFile: null,
},
async () => {
() => {
prepareToDownloadVersion(SECOND_UPDATE_VERSION);
await gAUS.checkForBackgroundUpdates();
gAUS.checkForBackgroundUpdates();
},
{
panelId: "applying",

View File

@@ -34,9 +34,9 @@ add_task(async function aboutDialog_backgroundCheck_multiUpdate() {
checkActiveUpdate: { state: STATE_APPLIED },
continueFile: null,
},
async () => {
() => {
prepareToDownloadVersion(SECOND_UPDATE_VERSION);
await gAUS.checkForBackgroundUpdates();
gAUS.checkForBackgroundUpdates();
},
{
panelId: "applying",

View File

@@ -34,9 +34,9 @@ add_task(async function aboutPrefs_backgroundCheck_multiUpdate() {
checkActiveUpdate: { state: STATE_APPLIED },
continueFile: null,
},
async () => {
() => {
prepareToDownloadVersion(SECOND_UPDATE_VERSION);
await gAUS.checkForBackgroundUpdates();
gAUS.checkForBackgroundUpdates();
},
{
panelId: "applying",

View File

@@ -69,7 +69,7 @@ async function changeAndVerifyUpdateWrites({
`We should ${expectPrompt ? "" : "not "}be prompted`
);
is(
!!(await gUpdateManager.getReadyUpdate()),
!!gUpdateManager.readyUpdate,
expectRemainingUpdate,
`There should ${expectRemainingUpdate ? "" : "not "}be a ready update`
);
@@ -89,24 +89,18 @@ add_task(async function testUpdateAutoPrefUI() {
info("Enable automatic updates and check that works.");
await changeAndVerifyPref(tab, true);
ok(
!(await gUpdateManager.getDownloadingUpdate()),
!gUpdateManager.downloadingUpdate,
"There should not be a downloading update"
);
ok(
!(await gUpdateManager.getReadyUpdate()),
"There should not be a ready update"
);
ok(!gUpdateManager.readyUpdate, "There should not be a ready update");
info("Disable automatic updates and check that works.");
await changeAndVerifyPref(tab, false);
ok(
!(await gUpdateManager.getDownloadingUpdate()),
!gUpdateManager.downloadingUpdate,
"There should not be a downloading update"
);
ok(
!(await gUpdateManager.getReadyUpdate()),
"There should not be a ready update"
);
ok(!gUpdateManager.readyUpdate, "There should not be a ready update");
let patchProps = { state: STATE_PENDING };
let patches = getLocalPatchString(patchProps);
@@ -115,10 +109,7 @@ add_task(async function testUpdateAutoPrefUI() {
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeStatusFile(STATE_PENDING);
reloadUpdateManagerData();
ok(
!!(await gUpdateManager.getReadyUpdate()),
"There should be a ready update"
);
ok(!!gUpdateManager.readyUpdate, "There should be a ready update");
let { prompt } = Services;
registerCleanupFunction(() => {

View File

@@ -22,7 +22,7 @@ add_task(async function doorhanger_bc_downloaded_disableBITS() {
let patch = getPatchOfType(
"partial",
await gUpdateManager.getReadyUpdate()
gUpdateManager.readyUpdate
).QueryInterface(Ci.nsIWritablePropertyBag);
ok(
!patch.getProperty("bitsId"),

View File

@@ -54,7 +54,7 @@ add_task(async function doorhanger_bc_multiUpdate() {
prepareToDownloadVersion(SECOND_UPDATE_VERSION);
let updateSwapped = waitForEvent("update-swap");
await gAUS.checkForBackgroundUpdates();
gAUS.checkForBackgroundUpdates();
await updateSwapped;
// The badge should be hidden while we swap from one update to the other
// to prevent restarting to update while staging is occurring. But since

View File

@@ -64,7 +64,7 @@ add_task(async function doorhanger_bc_multiUpdate() {
prepareToDownloadVersion(SECOND_UPDATE_VERSION, 0);
let updateSwapped = waitForEvent("update-swap");
await gAUS.checkForBackgroundUpdates();
gAUS.checkForBackgroundUpdates();
await updateSwapped;
// The badge should be hidden while we swap from one update to the other
// to prevent restarting to update while staging is occurring. But since

View File

@@ -44,10 +44,9 @@ add_task(async function elevation_dialog() {
() => !Services.wm.getMostRecentWindow("Update:Elevation"),
"The Update Elevation dialog should have closed"
);
let readyUpdate = await gUpdateManager.getReadyUpdate();
ok(!!readyUpdate, "There should be a ready update");
ok(!!gUpdateManager.readyUpdate, "There should be a ready update");
is(
readyUpdate.state,
gUpdateManager.readyUpdate.state,
STATE_PENDING_ELEVATE,
"The ready update state should equal " + STATE_PENDING_ELEVATE
);
@@ -65,8 +64,7 @@ add_task(async function elevation_dialog() {
() => !Services.wm.getMostRecentWindow("Update:Elevation"),
"The Update Elevation dialog should have closed"
);
readyUpdate = await gUpdateManager.getReadyUpdate();
ok(!readyUpdate, "There should not be a ready update");
ok(!gUpdateManager.readyUpdate, "There should not be a ready update");
is(
readStatusFile(),
STATE_NONE,
@@ -81,10 +79,9 @@ add_task(async function elevation_dialog() {
() => !Services.wm.getMostRecentWindow("Update:Elevation"),
"The Update Elevation dialog should have closed"
);
readyUpdate = await gUpdateManager.getReadyUpdate();
ok(!!readyUpdate, "There should be a ready update");
ok(!!gUpdateManager.readyUpdate, "There should be a ready update");
is(
readyUpdate.state,
gUpdateManager.readyUpdate.state,
STATE_PENDING_ELEVATE,
"The active update state should equal " + STATE_PENDING_ELEVATE
);
@@ -101,8 +98,8 @@ add_task(async function elevation_dialog() {
* @return A promise that returns the domWindow for the Update Elevation Dialog
* and resolves when the Update Elevation Dialog loads.
*/
async function waitForElevationDialog() {
let elevationDialogLoadedPromise = new Promise(resolve => {
function waitForElevationDialog() {
return new Promise(resolve => {
var listener = {
onOpenWindow: aXULWindow => {
debugDump("Update Elevation dialog shown...");
@@ -127,18 +124,16 @@ async function waitForElevationDialog() {
};
Services.wm.addListener(listener);
// Add the active-update.xml and update.status files used for these tests,
// reload the update manager, and then simulate startup so the Update
// Elevation Dialog is opened.
let patchProps = { state: STATE_PENDING_ELEVATE };
let patches = getLocalPatchString(patchProps);
let updateProps = { checkInterval: "1" };
let updates = getLocalUpdateString(updateProps, patches);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeStatusFile(STATE_PENDING_ELEVATE);
reloadUpdateManagerData();
testPostUpdateProcessing();
});
// Add the active-update.xml and update.status files used for these tests,
// reload the update manager, and then simulate startup so the Update
// Elevation Dialog is opened.
let patchProps = { state: STATE_PENDING_ELEVATE };
let patches = getLocalPatchString(patchProps);
let updateProps = { checkInterval: "1" };
let updates = getLocalUpdateString(updateProps, patches);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeStatusFile(STATE_PENDING_ELEVATE);
reloadUpdateManagerData();
await testPostUpdateProcessing();
return elevationDialogLoadedPromise;
}

View File

@@ -576,9 +576,10 @@ function runDoorhangerUpdateTest(params, steps) {
);
if (checkActiveUpdate) {
let activeUpdate = await (checkActiveUpdate.state == STATE_DOWNLOADING
? gUpdateManager.getDownloadingUpdate()
: gUpdateManager.getReadyUpdate());
let activeUpdate =
checkActiveUpdate.state == STATE_DOWNLOADING
? gUpdateManager.downloadingUpdate
: gUpdateManager.readyUpdate;
ok(!!activeUpdate, "There should be an active update");
is(
activeUpdate.state,
@@ -587,13 +588,10 @@ function runDoorhangerUpdateTest(params, steps) {
);
} else {
ok(
!(await gUpdateManager.getDownloadingUpdate()),
!gUpdateManager.downloadingUpdate,
"There should not be a downloading update"
);
ok(
!(await gUpdateManager.getReadyUpdate()),
"There should not be a ready update"
);
ok(!gUpdateManager.readyUpdate, "There should not be a ready update");
}
let buttonEl = getNotificationButton(window, notificationId, button);
@@ -643,10 +641,6 @@ function runDoorhangerUpdateTest(params, steps) {
// Perform a background check doorhanger test.
executeSoon(() => {
(async function () {
// `checkForBackgroundUpdates` is asynchronous, but it's not important
// for us to `await` on it since we will `await` on the results. And
// `await`ing on it could cause us to miss the events that we want to
// see.
gAUS.checkForBackgroundUpdates();
for (var i = 0; i < params.checkAttempts - 1; i++) {
await waitForEvent("update-error", "check-attempt-failed");
@@ -659,7 +653,7 @@ function runDoorhangerUpdateTest(params, steps) {
writeStatusFile(STATE_FAILED_CRC_ERROR);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(params.updates), true);
reloadUpdateManagerData();
await testPostUpdateProcessing();
testPostUpdateProcessing();
}
for (let step of steps) {
@@ -755,9 +749,10 @@ function runAboutDialogUpdateTest(params, steps) {
);
if (checkActiveUpdate) {
let activeUpdate = await (checkActiveUpdate.state == STATE_DOWNLOADING
? gUpdateManager.getDownloadingUpdate()
: gUpdateManager.getReadyUpdate());
let activeUpdate =
checkActiveUpdate.state == STATE_DOWNLOADING
? gUpdateManager.downloadingUpdate
: gUpdateManager.readyUpdate;
ok(!!activeUpdate, "There should be an active update");
is(
activeUpdate.state,
@@ -766,13 +761,10 @@ function runAboutDialogUpdateTest(params, steps) {
);
} else {
ok(
!(await gUpdateManager.getDownloadingUpdate()),
!gUpdateManager.downloadingUpdate,
"There should not be a downloading update"
);
ok(
!(await gUpdateManager.getReadyUpdate()),
"There should not be a ready update"
);
ok(!gUpdateManager.readyUpdate, "There should not be a ready update");
}
// Some tests just want to stop at the downloading state. These won't
@@ -783,7 +775,7 @@ function runAboutDialogUpdateTest(params, steps) {
await continueFileHandler(continueFile);
let patch = getPatchOfType(
data.patchType,
await gUpdateManager.getDownloadingUpdate()
gUpdateManager.downloadingUpdate
);
// The update is removed early when the last download fails so check
// that there is a patch before proceeding.
@@ -924,21 +916,19 @@ function runAboutDialogUpdateTest(params, steps) {
getVersionParams(params.version);
if (params.backgroundUpdate) {
setUpdateURL(updateURL);
await gAUS.checkForBackgroundUpdates();
gAUS.checkForBackgroundUpdates();
if (params.continueFile) {
await continueFileHandler(params.continueFile);
}
if (params.waitForUpdateState) {
let whichUpdateFn =
let whichUpdate =
params.waitForUpdateState == STATE_DOWNLOADING
? "getDownloadingUpdate"
: "getReadyUpdate";
let update;
? "downloadingUpdate"
: "readyUpdate";
await TestUtils.waitForCondition(
async () => {
update = await gUpdateManager[whichUpdateFn]();
return update && update.state == params.waitForUpdateState;
},
() =>
gUpdateManager[whichUpdate] &&
gUpdateManager[whichUpdate].state == params.waitForUpdateState,
"Waiting for update state: " + params.waitForUpdateState,
undefined,
200
@@ -949,7 +939,7 @@ function runAboutDialogUpdateTest(params, steps) {
});
// Display the UI after the update state equals the expected value.
is(
update.state,
gUpdateManager[whichUpdate].state,
params.waitForUpdateState,
"The update state value should equal " + params.waitForUpdateState
);
@@ -1066,9 +1056,10 @@ function runAboutPrefsUpdateTest(params, steps) {
);
if (checkActiveUpdate) {
let activeUpdate = await (checkActiveUpdate.state == STATE_DOWNLOADING
? gUpdateManager.getDownloadingUpdate()
: gUpdateManager.getReadyUpdate());
let activeUpdate =
checkActiveUpdate.state == STATE_DOWNLOADING
? gUpdateManager.downloadingUpdate
: gUpdateManager.readyUpdate;
ok(!!activeUpdate, "There should be an active update");
is(
activeUpdate.state,
@@ -1077,13 +1068,10 @@ function runAboutPrefsUpdateTest(params, steps) {
);
} else {
ok(
!(await gUpdateManager.getDownloadingUpdate()),
!gUpdateManager.downloadingUpdate,
"There should not be a downloading update"
);
ok(
!(await gUpdateManager.getReadyUpdate()),
"There should not be a ready update"
);
ok(!gUpdateManager.readyUpdate, "There should not be a ready update");
}
if (panelId == "downloading") {
@@ -1096,7 +1084,7 @@ function runAboutPrefsUpdateTest(params, steps) {
await continueFileHandler(continueFile);
let patch = getPatchOfType(
data.patchType,
await gUpdateManager.getDownloadingUpdate()
gUpdateManager.downloadingUpdate
);
// The update is removed early when the last download fails so check
// that there is a patch before proceeding.
@@ -1260,23 +1248,21 @@ function runAboutPrefsUpdateTest(params, steps) {
getVersionParams(params.version);
if (params.backgroundUpdate) {
setUpdateURL(updateURL);
await gAUS.checkForBackgroundUpdates();
gAUS.checkForBackgroundUpdates();
if (params.continueFile) {
await continueFileHandler(params.continueFile);
}
if (params.waitForUpdateState) {
// Wait until the update state equals the expected value before
// displaying the UI.
let whichUpdateFn =
let whichUpdate =
params.waitForUpdateState == STATE_DOWNLOADING
? "getDownloadingUpdate"
: "getReadyUpdate";
let update;
? "downloadingUpdate"
: "readyUpdate";
await TestUtils.waitForCondition(
async () => {
update = await gUpdateManager[whichUpdateFn]();
return update && update.state == params.waitForUpdateState;
},
() =>
gUpdateManager[whichUpdate] &&
gUpdateManager[whichUpdate].state == params.waitForUpdateState,
"Waiting for update state: " + params.waitForUpdateState,
undefined,
200
@@ -1286,7 +1272,7 @@ function runAboutPrefsUpdateTest(params, steps) {
logTestInfo(e);
});
is(
update.state,
gUpdateManager[whichUpdate].state,
params.waitForUpdateState,
"The update state value should equal " + params.waitForUpdateState
);
@@ -1367,10 +1353,6 @@ function runTelemetryUpdateTest(updateParams, event, stageFailure = false) {
updateParams +
getVersionParams();
setUpdateURL(updateURL);
// `checkForBackgroundUpdates` is asynchronous, but it's not important
// for us to `await` on it since we will `await` on the results. And
// `await`ing on it could cause us to miss the event that we want to
// see.
gAUS.checkForBackgroundUpdates();
await waitForEvent(event);
})();

View File

@@ -10,7 +10,7 @@ add_task(async function test_manual_app_update_policy() {
// But the two entry points just immediately call the same function, so this
// should probably be alright.
is(
await gAUS.checkForBackgroundUpdates(),
gAUS.checkForBackgroundUpdates(),
false,
"gAUS.checkForBackgroundUpdates() should not proceed with update check"
);

View File

@@ -76,15 +76,6 @@ function handleRequest(aRequest, aResponse) {
return;
}
let marBytes = readFileBytes(getTestDataFile(FILE_SIMPLE_MAR));
if (params.firstByteEarly) {
// Sending the first byte early causes the request's `onStartRequest`
// to be fired before the continue file is written.
const firstByte = marBytes[0];
marBytes = marBytes.substring(1);
aResponse.write(firstByte);
}
let retries = 0;
gSlowDownloadTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
gSlowDownloadTimer.initWithCallback(
@@ -101,7 +92,7 @@ function handleRequest(aRequest, aResponse) {
continueFile.remove(false);
}
gSlowDownloadTimer.cancel();
aResponse.write(marBytes);
aResponse.write(readFileBytes(getTestDataFile(FILE_SIMPLE_MAR)));
aResponse.finish();
} catch (e) {}
}
@@ -151,9 +142,6 @@ function handleRequest(aRequest, aResponse) {
let url = "";
if (params.useSlowDownloadMar) {
url = URL_HTTP_UPDATE_SJS + "?slowDownloadMar=1";
if (params.useFirstByteEarly) {
url += "&amp;firstByteEarly=1";
}
} else {
url = params.badURL ? BAD_SERVICE_URL : SERVICE_URL;
}

View File

@@ -176,16 +176,15 @@ function waitForEvent(topic, status = null) {
}
/* Triggers post-update processing */
async function testPostUpdateProcessing() {
await gAUS.internal.postUpdateProcessing();
function testPostUpdateProcessing() {
gAUS.observe(null, "test-post-update-processing", "");
}
/* Initializes the update service stub */
async function initUpdateServiceStub() {
const updateServiceStub = Cc[
"@mozilla.org/updates/update-service-stub;1"
].getService(Ci.nsIApplicationUpdateServiceStub);
await updateServiceStub.init();
function initUpdateServiceStub() {
Cc["@mozilla.org/updates/update-service-stub;1"].createInstance(
Ci.nsISupports
);
}
/**
@@ -197,7 +196,10 @@ async function initUpdateServiceStub() {
* to populate the update metadata.
*/
function reloadUpdateManagerData(skipFiles = false) {
gUpdateManager.internal.reload(skipFiles);
let observeData = skipFiles ? "skip-files" : "";
gUpdateManager
.QueryInterface(Ci.nsIObserver)
.observe(null, "um-reload-update-data", observeData);
}
const observer = {

View File

@@ -1305,16 +1305,17 @@ function checkAppBundleModTime() {
* @param aUpdateCount
* The update history's update count.
*/
async function checkUpdateManager(
function checkUpdateManager(
aStatusFileState,
aHasActiveUpdate,
aUpdateStatusState,
aUpdateErrCode,
aUpdateCount
) {
let activeUpdate = await (aUpdateStatusState == STATE_DOWNLOADING
? gUpdateManager.getDownloadingUpdate()
: gUpdateManager.getReadyUpdate());
let activeUpdate =
aUpdateStatusState == STATE_DOWNLOADING
? gUpdateManager.downloadingUpdate
: gUpdateManager.readyUpdate;
Assert.equal(
readStatusState(),
aStatusFileState,
@@ -1336,14 +1337,13 @@ async function checkUpdateManager(
msgTags[i] + "the active update should not be defined"
);
}
const history = await gUpdateManager.getHistory();
Assert.equal(
history.length,
gUpdateManager.getUpdateCount(),
aUpdateCount,
msgTags[i] + "the update manager updateCount attribute" + MSG_SHOULD_EQUAL
);
if (aUpdateCount > 0) {
let update = history[0];
let update = gUpdateManager.getUpdateAt(0);
Assert.equal(
update.state,
aUpdateStatusState,
@@ -1445,9 +1445,9 @@ function checkPostUpdateRunningFile(aShouldExist) {
* Initializes the most commonly used settings and creates an instance of the
* update service stub.
*/
async function standardInit() {
function standardInit() {
// Initialize the update service stub component
await initUpdateServiceStub();
initUpdateServiceStub();
}
/**
@@ -2285,12 +2285,7 @@ function checkSymlink() {
/**
* Sets the active update and related information for updater tests.
*/
async function setupActiveUpdate() {
// The update system being initialized at an unexpected time could cause
// unexpected effects in the reload process. Make sure that initialization
// has already run first.
await gAUS.init();
function setupActiveUpdate() {
let pendingState = gIsServiceTest ? STATE_PENDING_SVC : STATE_PENDING;
let patchProps = { state: pendingState };
let patches = getLocalPatchString(patchProps);
@@ -2299,10 +2294,7 @@ async function setupActiveUpdate() {
writeVersionFile(DEFAULT_UPDATE_VERSION);
writeStatusFile(pendingState);
reloadUpdateManagerData();
Assert.ok(
!!(await gUpdateManager.getReadyUpdate()),
"the ready update should be defined"
);
Assert.ok(!!gUpdateManager.readyUpdate, "the ready update should be defined");
}
/**
@@ -2364,7 +2356,7 @@ async function stageUpdate(
);
Assert.equal(
(await gUpdateManager.getReadyUpdate()).state,
gUpdateManager.readyUpdate.state,
aStateAfterStage,
"the update state" + MSG_SHOULD_EQUAL
);
@@ -3169,11 +3161,6 @@ async function setupUpdaterTest(
{ requiresOmnijar = false } = {}
) {
debugDump("start - updater test setup");
// Make sure that update has already been initialized. If post update
// processing unexpectedly runs between this setup and when we use these
// files, it may clean them up before we get the chance to use them.
await gAUS.init();
let updatesPatchDir = getUpdateDirFile(DIR_PATCH);
if (!updatesPatchDir.exists()) {
updatesPatchDir.create(Ci.nsIFile.DIRECTORY_TYPE, PERMS_DIRECTORY);
@@ -3311,7 +3298,7 @@ async function setupUpdaterTest(
});
if (aSetupActiveUpdate) {
await setupActiveUpdate();
setupActiveUpdate();
}
if (aPostUpdateAsync !== null) {
@@ -4296,10 +4283,10 @@ async function waitForUpdateCheck(aSuccess, aExpectedValues = {}) {
* onStopRequest occurs and returns the arguments from onStopRequest.
*/
async function waitForUpdateDownload(aUpdates, aExpectedStatus) {
let bestUpdate = await gAUS.selectUpdate(aUpdates);
let result = await gAUS.downloadUpdate(bestUpdate, false);
if (result != Ci.nsIApplicationUpdateService.DOWNLOAD_SUCCESS) {
do_throw("nsIApplicationUpdateService:downloadUpdate returned " + result);
let bestUpdate = gAUS.selectUpdate(aUpdates);
let success = await gAUS.downloadUpdate(bestUpdate, false);
if (!success) {
do_throw("nsIApplicationUpdateService:downloadUpdate returned " + success);
}
return new Promise(resolve =>
gAUS.addDownloadListener({

View File

@@ -137,58 +137,30 @@ class TestNoWindowUpdateRestart(MarionetteTestCase):
)
self.assertTrue(quit_flags_correct)
update_status = self.marionette.execute_async_script(
# Normally, the update status file would have been removed at this point by Post Update
# Processing. But restarting resets app.update.disabledForTesting, which causes that to be
# skipped, allowing us to look at the update status file directly.
update_status_path = self.marionette.execute_script(
"""
let [updateURLString, resolve] = arguments;
(async () => {
// Because post update processing happens during early startup and
// `app.update.disabledForTesting` is also set in early startup, it isn't
// especially well defined whether or not post update processing will have run at
// this point. Resolve this by forcing post update processing to run. This is as
// simple as turning off `app.update.disabledForTesting` and calling into
// UpdateManager, since the relevant methods ensure that initialization has run
// as long as update isn't disabled.
// Set the update URL to a local one first to ensure we don't hit the update server
// when we turn off `app.update.disabledForTesting`.
const mockAppInfo = Object.create(Services.appinfo, {
updateURL: {
configurable: true,
enumerable: true,
writable: false,
value: updateURLString,
},
});
Services.appinfo = mockAppInfo;
Services.prefs.setBoolPref("app.update.disabledForTesting", false);
const UM =
Cc["@mozilla.org/updates/update-manager;1"].getService(Ci.nsIUpdateManager);
const history = await UM.getHistory();
if (!history.length) {
return null;
}
return history[0].state;
})().then(resolve);
""",
script_args=(self.marionette.absolute_url("update.xml"),),
let statusFile = FileUtils.getDir("UpdRootD", ["updates", "0"]);
statusFile.append("update.status");
return statusFile.path;
"""
)
# If Firefox was built with "--enable-unverified-updates" (or presumably if we tested
# with an actual, signed update), the update should succeed. Otherwise, it will fail
# with CERT_VERIFY_ERROR (error code 19). Unfortunately, there is no good way to tell
# which of those situations we are in. Luckily, it doesn't matter, because we aren't
# trying to test whether the update applied successfully, just whether the
# "No Window Update Restart" feature attempted to apply an update.
# So both success and failure are fine. Any in-progress state is not.
self.assertIn(update_status, ["succeeded", "failed"])
with open(update_status_path, "r") as f:
# If Firefox was built with "--enable-unverified-updates" (or presumably if we tested
# with an actual, signed update), the update should succeed. Otherwise, it will fail
# with CERT_VERIFY_ERROR (error code 19). Unfortunately, there is no good way to tell
# which of those situations we are in. Luckily, it doesn't matter, because we aren't
# trying to test whether the update applied successfully, just whether the
# "No Window Update Restart" feature works.
self.assertIn(f.read().strip(), ["succeeded", "failed: 19"])
def resetUpdate(self):
self.marionette.execute_script(
"""
let UM = Cc["@mozilla.org/updates/update-manager;1"].getService(Ci.nsIUpdateManager);
UM.internal.reload(true);
UM.QueryInterface(Ci.nsIObserver).observe(null, "um-reload-update-data", "skip-files");
let { UpdateListener } = ChromeUtils.importESModule(
"resource://gre/modules/UpdateListener.sys.mjs"
@@ -267,7 +239,7 @@ class TestNoWindowUpdateRestart(MarionetteTestCase):
let aus = Cc["@mozilla.org/updates/update-service;1"]
.getService(Ci.nsIApplicationUpdateService);
await aus.checkForBackgroundUpdates();
aus.checkForBackgroundUpdates();
await updateDownloadedPromise;

View File

@@ -54,11 +54,11 @@ add_task(async function backgroundUpdate() {
gResponseBody = getRemoteUpdatesXMLString(updateString);
let { updates } = await waitForUpdateCheck(true);
let bestUpdate = await gAUS.selectUpdate(updates);
let result = await gAUS.downloadUpdate(bestUpdate, false);
let bestUpdate = gAUS.selectUpdate(updates);
let success = await gAUS.downloadUpdate(bestUpdate, false);
Assert.equal(
result,
Ci.nsIApplicationUpdateService.DOWNLOAD_FAILURE_CANNOT_RESUME_IN_BACKGROUND,
success,
false,
"We should not attempt to download an update in the background when an " +
"internal update download is already in progress."
);

View File

@@ -20,23 +20,19 @@ async function run_test() {
setUpdateChannel("original_channel");
await standardInit();
standardInit();
Assert.ok(
!(await gUpdateManager.getDownloadingUpdate()),
!gUpdateManager.downloadingUpdate,
"there should not be a downloading update"
);
Assert.ok(
!(await gUpdateManager.getReadyUpdate()),
"there should not be a ready update"
);
const history = await gUpdateManager.getHistory();
Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update");
Assert.equal(
history.length,
gUpdateManager.getUpdateCount(),
1,
"the update manager update count" + MSG_SHOULD_EQUAL
);
let update = history[0];
let update = gUpdateManager.getUpdateAt(0);
Assert.equal(
update.state,
STATE_FAILED,

View File

@@ -18,23 +18,19 @@ async function run_test() {
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeStatusFile(STATE_DOWNLOADING);
await standardInit();
standardInit();
Assert.ok(
!(await gUpdateManager.getDownloadingUpdate()),
!gUpdateManager.downloadingUpdate,
"there should not be a downloading update"
);
Assert.ok(
!(await gUpdateManager.getReadyUpdate()),
"there should not be a ready update"
);
const history = await gUpdateManager.getHistory();
Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update");
Assert.equal(
history.length,
gUpdateManager.getUpdateCount(),
1,
"the update manager update count" + MSG_SHOULD_EQUAL
);
let update = history[0];
let update = gUpdateManager.getUpdateAt(0);
Assert.equal(
update.state,
STATE_FAILED,

View File

@@ -19,23 +19,19 @@ async function run_test() {
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeStatusFile(STATE_DOWNLOADING);
await standardInit();
standardInit();
Assert.ok(
!(await gUpdateManager.getDownloadingUpdate()),
!gUpdateManager.downloadingUpdate,
"there should not be a downloading update"
);
Assert.ok(
!(await gUpdateManager.getReadyUpdate()),
"there should not be a ready update"
);
const history = await gUpdateManager.getHistory();
Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update");
Assert.equal(
history.length,
gUpdateManager.getUpdateCount(),
1,
"the update manager update count" + MSG_SHOULD_EQUAL
);
let update = history[0];
let update = gUpdateManager.getUpdateAt(0);
Assert.equal(
update.state,
STATE_FAILED,

View File

@@ -17,23 +17,19 @@ async function run_test() {
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeStatusFile(STATE_NONE);
await standardInit();
standardInit();
Assert.ok(
!(await gUpdateManager.getDownloadingUpdate()),
!gUpdateManager.downloadingUpdate,
"there should not be a downloading update"
);
Assert.ok(
!(await gUpdateManager.getReadyUpdate()),
"there should not be a ready update"
);
const history = await gUpdateManager.getHistory();
Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update");
Assert.equal(
history.length,
gUpdateManager.getUpdateCount(),
1,
"the update manager update count" + MSG_SHOULD_EQUAL
);
let update = history[0];
let update = gUpdateManager.getUpdateAt(0);
Assert.equal(
update.state,
STATE_FAILED,

View File

@@ -20,20 +20,16 @@ async function run_test() {
// Check that there are no active updates first so the updates directory is
// cleaned up by the UpdateManager before the remaining tests.
Assert.ok(
!(await gUpdateManager.getDownloadingUpdate()),
!gUpdateManager.downloadingUpdate,
"there should not be a downloading update"
);
Assert.ok(
!(await gUpdateManager.getReadyUpdate()),
"there should not be a ready update"
);
const history = await gUpdateManager.getHistory();
Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update");
Assert.equal(
history.length,
gUpdateManager.getUpdateCount(),
1,
"the update manager update count" + MSG_SHOULD_EQUAL
);
let update = history[0];
let update = gUpdateManager.getUpdateAt(0);
Assert.equal(
update.state,
STATE_FAILED,

View File

@@ -21,27 +21,18 @@ async function run_test() {
log = getUpdateDirFile(FILE_UPDATE_ELEVATED_LOG);
writeFile(log, "Last Update Elevated Log");
await standardInit();
standardInit();
Assert.ok(
!(await gUpdateManager.getDownloadingUpdate()),
!gUpdateManager.downloadingUpdate,
"there should not be a downloading update"
);
Assert.ok(
!(await gUpdateManager.getReadyUpdate()),
"there should not be a ready update"
);
const history = await gUpdateManager.getHistory();
Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update");
Assert.equal(
history.length,
gUpdateManager.getUpdateCount(),
1,
"the update manager update count" + MSG_SHOULD_EQUAL
);
Assert.equal(
gUpdateManager.updateInstalledAtStartup,
history[0],
"the update installed at startup should be the update from the history"
);
await waitForUpdateXMLFiles();
let cancelations = Services.prefs.getIntPref(PREF_APP_UPDATE_CANCELATIONS, 0);
@@ -82,15 +73,5 @@ async function run_test() {
let dir = getUpdateDirFile(DIR_PATCH);
Assert.ok(dir.exists(), MSG_SHOULD_EXIST);
// Simulate the browser restarting by rerunning update initialization.
reloadUpdateManagerData();
await testPostUpdateProcessing();
Assert.equal(
gUpdateManager.updateInstalledAtStartup,
null,
"updateInstalledAtStartup should be cleared on next browser start"
);
doTestFinish();
}

View File

@@ -99,19 +99,15 @@ async function testCleanupSuccessLogsFIFO(
"Last Update Elevated Log"
);
await testPostUpdateProcessing();
standardInit();
Assert.ok(
!(await gUpdateManager.getDownloadingUpdate()),
!gUpdateManager.downloadingUpdate,
"there should not be a downloading update"
);
Assert.ok(
!(await gUpdateManager.getReadyUpdate()),
"there should not be a ready update"
);
const history = await gUpdateManager.getHistory();
Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update");
Assert.equal(
history.length,
gUpdateManager.getUpdateCount(),
1,
"the update manager update count" + MSG_SHOULD_EQUAL
);

View File

@@ -33,11 +33,11 @@ add_task(async function disableBackgroundUpdatesBackgroundTask() {
gResponseBody = getRemoteUpdatesXMLString(updateString);
let { updates } = await waitForUpdateCheck(true);
let bestUpdate = await gAUS.selectUpdate(updates);
let result = await gAUS.downloadUpdate(bestUpdate, false);
let bestUpdate = gAUS.selectUpdate(updates);
let success = await gAUS.downloadUpdate(bestUpdate, false);
Assert.equal(
result,
Ci.nsIApplicationUpdateService.DOWNLOAD_FAILURE_GENERIC,
success,
false,
"Update should not download when disableBackgroundUpdates is specified " +
"and we are in background task mode."
);

View File

@@ -18,16 +18,15 @@ async function run_test() {
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeStatusFile(STATE_DOWNLOADING);
await standardInit();
standardInit();
const history = await gUpdateManager.getHistory();
Assert.equal(
history.length,
gUpdateManager.getUpdateCount(),
0,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
(await gUpdateManager.getDownloadingUpdate()).state,
gUpdateManager.downloadingUpdate.state,
STATE_DOWNLOADING,
"the update manager activeUpdate state attribute" + MSG_SHOULD_EQUAL
);

View File

@@ -55,7 +55,7 @@ async function testTransition(options) {
async function run_test() {
setupTestCommon(null);
await standardInit();
standardInit();
// The setup functions we use for update testing typically allow for update.
// But we are just testing preferences here. We don't want anything to
// actually attempt to update. Also, because we are messing with the pref

View File

@@ -267,7 +267,7 @@ add_task(async function testRedownload() {
};
gAUS.addDownloadListener(listener);
let bestUpdate = await gAUS.selectUpdate(updates);
let bestUpdate = gAUS.selectUpdate(updates);
await gAUS.downloadUpdate(bestUpdate, false);
await waitForEvent("update-downloaded");

View File

@@ -73,9 +73,9 @@ async function downloadUpdate(appUpdateAuto, onDownloadStartCallback) {
}
let waitToStartPromise = new Promise(resolve => {
let listener = {
onStartRequest: async _aRequest => {
onStartRequest: _aRequest => {
gAUS.removeDownloadListener(listener);
await onDownloadStartCallback();
onDownloadStartCallback();
resolve();
},
onProgress: (_aRequest, _aContext, _aProgress, _aMaxProgress) => {},
@@ -89,7 +89,7 @@ async function downloadUpdate(appUpdateAuto, onDownloadStartCallback) {
gAUS.addDownloadListener(listener);
});
let updateCheckStarted = await gAUS.checkForBackgroundUpdates();
let updateCheckStarted = gAUS.checkForBackgroundUpdates();
Assert.ok(updateCheckStarted, "Update check should have started");
if (!appUpdateAuto) {
@@ -103,8 +103,8 @@ async function downloadUpdate(appUpdateAuto, onDownloadStartCallback) {
await gAUS.downloadUpdate(update, true);
}
await waitToStartPromise;
await continueFileHandler(CONTINUE_DOWNLOAD);
await waitToStartPromise;
await downloadFinishedPromise;
// Wait an extra tick after the download has finished. If we try to check for
// another update exactly when "update-downloaded" fires,
@@ -141,10 +141,10 @@ async function testUpdateDoesNotDownload() {
);
let update = result.updates[0];
let downloadResult = await gAUS.downloadUpdate(update, true);
let downloadStarted = await gAUS.downloadUpdate(update, true);
Assert.equal(
downloadResult,
Ci.nsIApplicationUpdateService.DOWNLOAD_FAILURE_GENERIC,
downloadStarted,
false,
"Expected that we would not start downloading an update"
);
@@ -163,8 +163,8 @@ async function testUpdateDoesNotDownload() {
);
}
async function testUpdateCheckDoesNotStart() {
let updateCheckStarted = await gAUS.checkForBackgroundUpdates();
function testUpdateCheckDoesNotStart() {
let updateCheckStarted = gAUS.checkForBackgroundUpdates();
Assert.equal(
updateCheckStarted,
false,
@@ -173,7 +173,7 @@ async function testUpdateCheckDoesNotStart() {
}
function prepareToDownloadVersion(version, onlyCompleteMar = false) {
let updateUrl = `${APP_UPDATE_SJS_URL}?useSlowDownloadMar=1&useFirstByteEarly=1&appVersion=${version}`;
let updateUrl = `${APP_UPDATE_SJS_URL}?useSlowDownloadMar=1&appVersion=${version}`;
if (onlyCompleteMar) {
updateUrl += "&completePatchOnly=1";
}
@@ -197,16 +197,17 @@ async function multi_update_test(appUpdateAuto) {
prepareToDownloadVersion(FIRST_UPDATE_VERSION);
await downloadUpdate(appUpdateAuto, async () => {
const readyUpdate = await gUpdateManager.getReadyUpdate();
const downloadingUpdate = await gUpdateManager.getDownloadingUpdate();
Assert.ok(!readyUpdate, "There should not be a ready update yet");
await downloadUpdate(appUpdateAuto, () => {
Assert.ok(
!!downloadingUpdate,
!gUpdateManager.readyUpdate,
"There should not be a ready update yet"
);
Assert.ok(
!!gUpdateManager.downloadingUpdate,
"First update download should be in downloadingUpdate"
);
Assert.equal(
downloadingUpdate.state,
gUpdateManager.downloadingUpdate.state,
STATE_DOWNLOADING,
"downloadingUpdate should be downloading"
);
@@ -217,20 +218,21 @@ async function multi_update_test(appUpdateAuto) {
);
});
let readyUpdate = await gUpdateManager.getReadyUpdate();
let downloadingUpdate = await gUpdateManager.getDownloadingUpdate();
Assert.ok(
!downloadingUpdate,
!gUpdateManager.downloadingUpdate,
"First update download should no longer be in downloadingUpdate"
);
Assert.ok(!!readyUpdate, "First update download should be in readyUpdate");
Assert.ok(
!!gUpdateManager.readyUpdate,
"First update download should be in readyUpdate"
);
Assert.equal(
readyUpdate.state,
gUpdateManager.readyUpdate.state,
STATE_PENDING,
"readyUpdate should be pending"
);
Assert.equal(
readyUpdate.appVersion,
gUpdateManager.readyUpdate.appVersion,
FIRST_UPDATE_VERSION,
"readyUpdate version should be match the version of the first update"
);
@@ -240,22 +242,21 @@ async function multi_update_test(appUpdateAuto) {
"Updater state should be pending"
);
let existingUpdate = readyUpdate;
let existingUpdate = gUpdateManager.readyUpdate;
await testUpdateDoesNotDownload();
readyUpdate = await gUpdateManager.getReadyUpdate();
Assert.equal(
readyUpdate,
gUpdateManager.readyUpdate,
existingUpdate,
"readyUpdate should not have changed when no newer update is available"
);
Assert.equal(
readyUpdate.state,
gUpdateManager.readyUpdate.state,
STATE_PENDING,
"readyUpdate should still be pending"
);
Assert.equal(
readyUpdate.appVersion,
gUpdateManager.readyUpdate.appVersion,
FIRST_UPDATE_VERSION,
"readyUpdate version should be match the version of the first update"
);
@@ -270,19 +271,18 @@ async function multi_update_test(appUpdateAuto) {
prepareToDownloadVersion(SECOND_UPDATE_VERSION, true);
await testUpdateDoesNotDownload();
readyUpdate = await gUpdateManager.getReadyUpdate();
Assert.equal(
readyUpdate,
gUpdateManager.readyUpdate,
existingUpdate,
"readyUpdate should not have changed when no newer partial update is available"
);
Assert.equal(
readyUpdate.state,
gUpdateManager.readyUpdate.state,
STATE_PENDING,
"readyUpdate should still be pending"
);
Assert.equal(
readyUpdate.appVersion,
gUpdateManager.readyUpdate.appVersion,
FIRST_UPDATE_VERSION,
"readyUpdate version should be match the version of the first update"
);
@@ -294,29 +294,27 @@ async function multi_update_test(appUpdateAuto) {
prepareToDownloadVersion(SECOND_UPDATE_VERSION);
await downloadUpdate(appUpdateAuto, async () => {
readyUpdate = await gUpdateManager.getReadyUpdate();
downloadingUpdate = await gUpdateManager.getDownloadingUpdate();
await downloadUpdate(appUpdateAuto, () => {
Assert.ok(
!!downloadingUpdate,
!!gUpdateManager.downloadingUpdate,
"Second update download should be in downloadingUpdate"
);
Assert.equal(
downloadingUpdate.state,
gUpdateManager.downloadingUpdate.state,
STATE_DOWNLOADING,
"downloadingUpdate should be downloading"
);
Assert.ok(
!!readyUpdate,
!!gUpdateManager.readyUpdate,
"First update download should still be in readyUpdate"
);
Assert.equal(
readyUpdate.state,
gUpdateManager.readyUpdate.state,
STATE_PENDING,
"readyUpdate should still be pending"
);
Assert.equal(
readyUpdate.appVersion,
gUpdateManager.readyUpdate.appVersion,
FIRST_UPDATE_VERSION,
"readyUpdate version should be match the version of the first update"
);
@@ -327,20 +325,21 @@ async function multi_update_test(appUpdateAuto) {
);
});
readyUpdate = await gUpdateManager.getReadyUpdate();
downloadingUpdate = await gUpdateManager.getDownloadingUpdate();
Assert.ok(
!downloadingUpdate,
!gUpdateManager.downloadingUpdate,
"Second update download should no longer be in downloadingUpdate"
);
Assert.ok(!!readyUpdate, "Second update download should be in readyUpdate");
Assert.ok(
!!gUpdateManager.readyUpdate,
"Second update download should be in readyUpdate"
);
Assert.equal(
readyUpdate.state,
gUpdateManager.readyUpdate.state,
STATE_PENDING,
"readyUpdate should be pending"
);
Assert.equal(
readyUpdate.appVersion,
gUpdateManager.readyUpdate.appVersion,
SECOND_UPDATE_VERSION,
"readyUpdate version should be match the version of the second update"
);
@@ -357,25 +356,23 @@ async function multi_update_test(appUpdateAuto) {
// Second parameter forces a complete MAR download.
prepareToDownloadVersion(FIRST_UPDATE_VERSION, true);
await downloadUpdate(appUpdateAuto, async () => {
downloadingUpdate = await gUpdateManager.getDownloadingUpdate();
await downloadUpdate(appUpdateAuto, () => {
Assert.equal(
downloadingUpdate.selectedPatch.type,
gUpdateManager.downloadingUpdate.selectedPatch.type,
"complete",
"First update download should be a complete patch"
);
});
readyUpdate = await gUpdateManager.getReadyUpdate();
Assert.equal(
readyUpdate.selectedPatch.type,
gUpdateManager.readyUpdate.selectedPatch.type,
"complete",
"First update download should be a complete patch"
);
// Even a newer partial update should not be downloaded at this point.
prepareToDownloadVersion(SECOND_UPDATE_VERSION);
await testUpdateCheckDoesNotStart();
testUpdateCheckDoesNotStart();
}
add_task(async function all_multi_update_tests() {

View File

@@ -38,13 +38,9 @@ async function downloadUpdate() {
);
});
let bestUpdate = await gAUS.selectUpdate(updates);
let result = await gAUS.downloadUpdate(bestUpdate, false);
Assert.equal(
result,
Ci.nsIApplicationUpdateService.DOWNLOAD_SUCCESS,
"Update download should have started"
);
let bestUpdate = gAUS.selectUpdate(updates);
let success = await gAUS.downloadUpdate(bestUpdate, false);
Assert.ok(success, "Update download should have started");
return downloadRestrictionHitPromise;
}
@@ -54,13 +50,15 @@ add_task(async function onlyDownloadUpdatesThisSession() {
await downloadUpdate();
Assert.ok(
!(await gUpdateManager.getReadyUpdate()),
!gUpdateManager.readyUpdate,
"There should not be a ready update. The update should still be downloading"
);
const downloadingUpdate = await gUpdateManager.getDownloadingUpdate();
Assert.ok(!!downloadingUpdate, "A downloading update should exist");
Assert.ok(
!!gUpdateManager.downloadingUpdate,
"A downloading update should exist"
);
Assert.equal(
downloadingUpdate.state,
gUpdateManager.downloadingUpdate.state,
STATE_DOWNLOADING,
"The downloading update should still be in the downloading state"
);

View File

@@ -161,7 +161,7 @@ async function changeAndVerifyPref(
async function run_test() {
setupTestCommon(null);
await standardInit();
standardInit();
await testSetup();
logTestInfo("Testing boolean pref and its observer");

View File

@@ -11,12 +11,13 @@ async function run_test() {
setUpdateChannel("test_channel");
debugDump("testing update xml not available");
let checkResult = await waitForUpdateCheck(false);
Assert.equal(
checkResult.updates[0].errorCode,
1500,
"the update errorCode" + MSG_SHOULD_EQUAL
);
await waitForUpdateCheck(false).then(aArgs => {
Assert.equal(
aArgs.updates[0].errorCode,
1500,
"the update errorCode" + MSG_SHOULD_EQUAL
);
});
debugDump(
"testing one update available, the update's property values and " +
@@ -43,180 +44,183 @@ async function run_test() {
};
let updates = getRemoteUpdateString(updateProps, patches);
gResponseBody = getRemoteUpdatesXMLString(updates);
checkResult = await waitForUpdateCheck(true, { updateCount: 1 });
// XXXrstrong - not specifying a detailsURL will cause a leak due to
// bug 470244 and until this is fixed this will not test the value for
// detailsURL when it isn't specified in the update xml.
await waitForUpdateCheck(true, { updateCount: 1 }).then(aArgs => {
// XXXrstrong - not specifying a detailsURL will cause a leak due to
// bug 470244 and until this is fixed this will not test the value for
// detailsURL when it isn't specified in the update xml.
let bestUpdate = await gAUS.selectUpdate(checkResult.updates);
bestUpdate.QueryInterface(Ci.nsIWritablePropertyBag);
Assert.equal(
bestUpdate.type,
"minor",
"the update type attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.name,
"Minor Test",
"the update name attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.displayVersion,
"version 2.1a1pre",
"the update displayVersion attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.appVersion,
"2.1a1pre",
"the update appVersion attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.buildID,
"20080811053724",
"the update buildID attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.detailsURL,
"http://details/",
"the update detailsURL attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.promptWaitTime,
"345600",
"the update promptWaitTime attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.serviceURL,
gURLData + gHTTPHandlerPath + "?force=1",
"the update serviceURL attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.channel,
"test_channel",
"the update channel attribute" + MSG_SHOULD_EQUAL
);
Assert.ok(
!bestUpdate.isCompleteUpdate,
"the update isCompleteUpdate attribute" + MSG_SHOULD_EQUAL
);
Assert.ok(
!bestUpdate.isSecurityUpdate,
"the update isSecurityUpdate attribute" + MSG_SHOULD_EQUAL
);
// Check that installDate is within 10 seconds of the current date.
Assert.ok(
Date.now() - bestUpdate.installDate < 10000,
"the update installDate attribute should be within 10 seconds " +
"of the current time"
);
Assert.ok(
!bestUpdate.statusText,
"the update statusText attribute" + MSG_SHOULD_EQUAL
);
// nsIUpdate:state returns an empty string when no action has been performed
// on an available update
Assert.equal(
bestUpdate.state,
"",
"the update state attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.errorCode,
0,
"the update errorCode attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.patchCount,
2,
"the update patchCount attribute" + MSG_SHOULD_EQUAL
);
// XXX TODO - test nsIUpdate:serialize
let bestUpdate = gAUS
.selectUpdate(aArgs.updates)
.QueryInterface(Ci.nsIWritablePropertyBag);
Assert.equal(
bestUpdate.type,
"minor",
"the update type attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.name,
"Minor Test",
"the update name attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.displayVersion,
"version 2.1a1pre",
"the update displayVersion attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.appVersion,
"2.1a1pre",
"the update appVersion attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.buildID,
"20080811053724",
"the update buildID attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.detailsURL,
"http://details/",
"the update detailsURL attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.promptWaitTime,
"345600",
"the update promptWaitTime attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.serviceURL,
gURLData + gHTTPHandlerPath + "?force=1",
"the update serviceURL attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.channel,
"test_channel",
"the update channel attribute" + MSG_SHOULD_EQUAL
);
Assert.ok(
!bestUpdate.isCompleteUpdate,
"the update isCompleteUpdate attribute" + MSG_SHOULD_EQUAL
);
Assert.ok(
!bestUpdate.isSecurityUpdate,
"the update isSecurityUpdate attribute" + MSG_SHOULD_EQUAL
);
// Check that installDate is within 10 seconds of the current date.
Assert.ok(
Date.now() - bestUpdate.installDate < 10000,
"the update installDate attribute should be within 10 seconds " +
"of the current time"
);
Assert.ok(
!bestUpdate.statusText,
"the update statusText attribute" + MSG_SHOULD_EQUAL
);
// nsIUpdate:state returns an empty string when no action has been performed
// on an available update
Assert.equal(
bestUpdate.state,
"",
"the update state attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.errorCode,
0,
"the update errorCode attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.patchCount,
2,
"the update patchCount attribute" + MSG_SHOULD_EQUAL
);
// XXX TODO - test nsIUpdate:serialize
Assert.equal(
bestUpdate.getProperty("custom1_attr"),
"custom1 value",
"the update custom1_attr property" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.getProperty("custom2_attr"),
"custom2 value",
"the update custom2_attr property" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.getProperty("custom1_attr"),
"custom1 value",
"the update custom1_attr property" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.getProperty("custom2_attr"),
"custom2 value",
"the update custom2_attr property" + MSG_SHOULD_EQUAL
);
let patch = bestUpdate.getPatchAt(0);
Assert.equal(
patch.type,
"complete",
"the update patch type attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
patch.URL,
"http://complete/",
"the update patch URL attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
patch.size,
9856459,
"the update patch size attribute" + MSG_SHOULD_EQUAL
);
// The value for patch.state can be the string 'null' as a valid value. This
// is confusing if it returns null which is an invalid value since the test
// failure output will show a failure for null == null. To lessen the
// confusion first check that the typeof for patch.state is string.
Assert.equal(
typeof patch.state,
"string",
"the update patch state typeof value should equal |string|"
);
Assert.equal(
patch.state,
STATE_NONE,
"the update patch state attribute" + MSG_SHOULD_EQUAL
);
Assert.ok(
!patch.selected,
"the update patch selected attribute" + MSG_SHOULD_EQUAL
);
// XXX TODO - test nsIUpdatePatch:serialize
let patch = bestUpdate.getPatchAt(0);
Assert.equal(
patch.type,
"complete",
"the update patch type attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
patch.URL,
"http://complete/",
"the update patch URL attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
patch.size,
9856459,
"the update patch size attribute" + MSG_SHOULD_EQUAL
);
// The value for patch.state can be the string 'null' as a valid value. This
// is confusing if it returns null which is an invalid value since the test
// failure output will show a failure for null == null. To lessen the
// confusion first check that the typeof for patch.state is string.
Assert.equal(
typeof patch.state,
"string",
"the update patch state typeof value should equal |string|"
);
Assert.equal(
patch.state,
STATE_NONE,
"the update patch state attribute" + MSG_SHOULD_EQUAL
);
Assert.ok(
!patch.selected,
"the update patch selected attribute" + MSG_SHOULD_EQUAL
);
// XXX TODO - test nsIUpdatePatch:serialize
patch = bestUpdate.getPatchAt(1);
Assert.equal(
patch.type,
"partial",
"the update patch type attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
patch.URL,
"http://partial/",
"the update patch URL attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
patch.size,
1316138,
"the update patch size attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
patch.state,
STATE_NONE,
"the update patch state attribute" + MSG_SHOULD_EQUAL
);
Assert.ok(
!patch.selected,
"the update patch selected attribute" + MSG_SHOULD_EQUAL
);
// XXX TODO - test nsIUpdatePatch:serialize
patch = bestUpdate.getPatchAt(1);
Assert.equal(
patch.type,
"partial",
"the update patch type attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
patch.URL,
"http://partial/",
"the update patch URL attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
patch.size,
1316138,
"the update patch size attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
patch.state,
STATE_NONE,
"the update patch state attribute" + MSG_SHOULD_EQUAL
);
Assert.ok(
!patch.selected,
"the update patch selected attribute" + MSG_SHOULD_EQUAL
);
// XXX TODO - test nsIUpdatePatch:serialize
});
debugDump(
"testing an empty update xml that returns a root node name of " +
"parsererror"
);
gResponseBody = "<parsererror/>";
checkResult = await waitForUpdateCheck(false);
Assert.equal(
checkResult.updates[0].errorCode,
1200,
"the update errorCode" + MSG_SHOULD_EQUAL
);
await waitForUpdateCheck(false).then(aArgs => {
Assert.equal(
aArgs.updates[0].errorCode,
1200,
"the update errorCode" + MSG_SHOULD_EQUAL
);
});
debugDump("testing no updates available");
gResponseBody = getRemoteUpdatesXMLString("");
@@ -249,12 +253,13 @@ async function run_test() {
patches += getRemotePatchString(patchProps);
updates = getRemoteUpdateString({}, patches);
gResponseBody = getRemoteUpdatesXMLString(updates);
checkResult = await waitForUpdateCheck(true);
Assert.equal(
checkResult.updates.length,
0,
"the update count" + MSG_SHOULD_EQUAL
);
await waitForUpdateCheck(true).then(aArgs => {
Assert.equal(
aArgs.updates.length,
0,
"the update count" + MSG_SHOULD_EQUAL
);
});
debugDump(
"testing one update with complete patch with size 0 specified in " +
@@ -288,9 +293,10 @@ async function run_test() {
updateProps = { appVersion: "1.0a" };
updates += getRemoteUpdateString(updateProps, patches);
gResponseBody = getRemoteUpdatesXMLString(updates);
checkResult = await waitForUpdateCheck(true, { updateCount: 2 });
bestUpdate = await gAUS.selectUpdate(checkResult.updates);
Assert.ok(!bestUpdate, "there shouldn't be an update available");
await waitForUpdateCheck(true, { updateCount: 2 }).then(aArgs => {
let bestUpdate = gAUS.selectUpdate(aArgs.updates);
Assert.ok(!bestUpdate, "there shouldn't be an update available");
});
debugDump(
"testing that updates for the current version of the application " +
@@ -302,19 +308,20 @@ async function run_test() {
updateProps = { appVersion: "1.0" };
updates = getRemoteUpdateString(updateProps, patches);
gResponseBody = getRemoteUpdatesXMLString(updates);
checkResult = await waitForUpdateCheck(true, { updateCount: 1 });
bestUpdate = await gAUS.selectUpdate(checkResult.updates);
Assert.ok(!!bestUpdate, "there should be one update available");
Assert.equal(
bestUpdate.appVersion,
"1.0",
"the update appVersion attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.displayVersion,
"1.0",
"the update displayVersion attribute" + MSG_SHOULD_EQUAL
);
await waitForUpdateCheck(true, { updateCount: 1 }).then(aArgs => {
let bestUpdate = gAUS.selectUpdate(aArgs.updates);
Assert.ok(!!bestUpdate, "there should be one update available");
Assert.equal(
bestUpdate.appVersion,
"1.0",
"the update appVersion attribute" + MSG_SHOULD_EQUAL
);
Assert.equal(
bestUpdate.displayVersion,
"1.0",
"the update displayVersion attribute" + MSG_SHOULD_EQUAL
);
});
stop_httpserver(doTestFinish);
}

View File

@@ -15,7 +15,7 @@ async function verifyPref(expectedValue) {
async function run_test() {
setupTestCommon(null);
await standardInit();
standardInit();
let configFile = getUpdateDirFile(FILE_UPDATE_CONFIG_JSON);

View File

@@ -153,19 +153,15 @@ async function run_test() {
const pendingPingContents = "arbitrary pending ping file contents";
writeFile(oldPendingPingFile, pendingPingContents);
await standardInit();
standardInit();
Assert.ok(
!(await gUpdateManager.getDownloadingUpdate()),
!gUpdateManager.downloadingUpdate,
"there should not be a downloading update"
);
Assert.ok(
!(await gUpdateManager.getReadyUpdate()),
"there should not be a ready update"
);
const history = await gUpdateManager.getHistory();
Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update");
Assert.equal(
history.length,
gUpdateManager.getUpdateCount(),
1,
"the update manager update count" + MSG_SHOULD_EQUAL
);

View File

@@ -1,43 +0,0 @@
/* 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
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
const { TelemetryEnvironment } = ChromeUtils.importESModule(
"resource://gre/modules/TelemetryEnvironment.sys.mjs"
);
/**
* This test ensures that packaged installations don't send an `update.enabled`
* value of `true` in the telemetry environment.
*/
add_task(async function telemetryEnvironmentUpdateEnabled() {
const origSysinfo = Services.sysinfo;
registerCleanupFunction(() => {
Services.sysinfo = origSysinfo;
});
const mockSysinfo = Object.create(origSysinfo, {
getProperty: {
configurable: true,
enumerable: true,
writable: false,
value: prop => {
if (prop == "isPackagedApp") {
return true;
}
return origSysinfo.getProperty(prop);
},
},
});
Services.sysinfo = mockSysinfo;
const environmentData = await TelemetryEnvironment.onInitialized();
Assert.equal(
environmentData.settings.update.enabled,
false,
"Update should not be reported as enabled in a packaged app"
);
});

View File

@@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
async function run_test() {
function run_test() {
setupTestCommon();
debugDump(
@@ -74,25 +74,23 @@ async function run_test() {
updates = getLocalUpdateString(updateProps, patches);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), false);
await standardInit();
standardInit();
Assert.ok(
!(await gUpdateManager.getDownloadingUpdate()),
!gUpdateManager.downloadingUpdate,
"there should not be a downloading update"
);
Assert.ok(
!(await gUpdateManager.getReadyUpdate()),
"there should not be a ready update"
);
const history = await gUpdateManager.getHistory();
Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update");
Assert.equal(
history.length,
gUpdateManager.getUpdateCount(),
2,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL
);
debugDump("checking the first update properties");
let update = history[0].QueryInterface(Ci.nsIWritablePropertyBag);
let update = gUpdateManager
.getUpdateAt(0)
.QueryInterface(Ci.nsIWritablePropertyBag);
Assert.equal(
update.state,
STATE_SUCCEEDED,
@@ -299,7 +297,9 @@ async function run_test() {
);
debugDump("checking the second update properties");
update = history[1].QueryInterface(Ci.nsIWritablePropertyBag);
update = gUpdateManager
.getUpdateAt(1)
.QueryInterface(Ci.nsIWritablePropertyBag);
Assert.equal(
update.state,
STATE_FAILED,

View File

@@ -77,8 +77,6 @@ reason = "Update pref migration is currently Windows only"
run-if = ["os == 'win'"]
reason = "Update directory migration is currently Windows only"
["updateEnabledTelemetry.js"]
["updateManagerXML.js"]
["updateSyncManager.js"]

View File

@@ -10,12 +10,12 @@ const { BackgroundUpdate } = ChromeUtils.importESModule(
"resource://gre/modules/BackgroundUpdate.sys.mjs"
);
add_setup(async function test_setup() {
// These tests use per-installation prefs, and those are a shared resource, so
// they require some non-trivial setup.
setupTestCommon(null);
await standardInit();
// These tests use per-installation prefs, and those are a shared resource, so
// they require some non-trivial setup.
setupTestCommon(null);
standardInit();
add_setup(function test_setup() {
// FOG needs a profile directory to put its data in.
do_get_profile();

View File

@@ -24,6 +24,11 @@ const { sinon } = ChromeUtils.importESModule(
// We can't reasonably check NO_MOZ_BACKGROUNDTASKS, nor NO_OMNIJAR.
// These tests use per-installation prefs, and those are a shared resource, so
// they require some non-trivial setup.
setupTestCommon(null);
standardInit();
function setup_enterprise_policy_testing() {
// This initializes the policy engine for xpcshell tests
let policies = Cc["@mozilla.org/enterprisepolicies;1"].getService(
@@ -44,12 +49,7 @@ async function setupPolicyEngineWithJson(json, customSchema) {
return EnterprisePolicyTesting.setupPolicyEngineWithJson(json, customSchema);
}
add_setup(async function test_setup() {
// These tests use per-installation prefs, and those are a shared resource, so
// they require some non-trivial setup.
setupTestCommon(null);
await standardInit();
add_setup(function test_setup() {
// FOG needs a profile directory to put its data in.
do_get_profile();

View File

@@ -17,11 +17,11 @@ async function run_test() {
await setupUpdaterTest(FILE_COMPLETE_MAR, false);
let path = getTestDirFile(FILE_HELPER_BIN).path;
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, null, path);
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
await waitForUpdateXMLFiles();
await checkUpdateManager(
checkUpdateManager(
STATE_NONE,
false,
STATE_FAILED,

View File

@@ -24,11 +24,11 @@ async function run_test() {
path = path.repeat(1000); // 10000 characters
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, null, path);
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
await waitForUpdateXMLFiles();
await checkUpdateManager(
checkUpdateManager(
STATE_NONE,
false,
STATE_FAILED,

View File

@@ -26,7 +26,7 @@ async function run_test() {
path = path.repeat(1000); // 10000 characters
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, path, null, null);
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
await waitForUpdateXMLFiles();
@@ -38,9 +38,9 @@ async function run_test() {
// launch the maintenance service the update.status file isn't copied from
// the secure log directory to the patch directory and the update manager
// won't read the failure from the update.status file.
await checkUpdateManager(STATE_NONE, false, STATE_PENDING_SVC, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_PENDING_SVC, 0, 1);
} else {
await checkUpdateManager(
checkUpdateManager(
STATE_NONE,
false,
STATE_FAILED,

View File

@@ -23,7 +23,7 @@ async function run_test() {
path = "/" + path + "/../" + path;
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, path, null, null);
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
await waitForUpdateXMLFiles();
@@ -35,9 +35,9 @@ async function run_test() {
// launch the maintenance service the update.status file isn't copied from
// the secure log directory to the patch directory and the update manager
// won't read the failure from the update.status file.
await checkUpdateManager(STATE_NONE, false, STATE_PENDING_SVC, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_PENDING_SVC, 0, 1);
} else {
await checkUpdateManager(
checkUpdateManager(
STATE_NONE,
false,
STATE_FAILED,

View File

@@ -18,7 +18,7 @@ async function run_test() {
await setupUpdaterTest(FILE_COMPLETE_MAR, false);
let path = getApplyDirFile("..", false).path;
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, path, null);
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
await waitForUpdateXMLFiles();
@@ -30,9 +30,9 @@ async function run_test() {
// launch the maintenance service the update.status file isn't copied from
// the secure log directory to the patch directory and the update manager
// won't read the failure from the update.status file.
await checkUpdateManager(STATE_NONE, false, STATE_PENDING_SVC, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_PENDING_SVC, 0, 1);
} else {
await checkUpdateManager(
checkUpdateManager(
STATE_NONE,
false,
STATE_FAILED,

View File

@@ -23,10 +23,10 @@ async function run_test() {
path = path + "/../";
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, path, null, null, null);
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
await waitForUpdateXMLFiles();
await checkUpdateManager(STATE_NONE, false, STATE_AFTER_RUNUPDATE, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_AFTER_RUNUPDATE, 0, 1);
waitForFilesInUse();
}

View File

@@ -18,7 +18,7 @@ async function run_test() {
await setupUpdaterTest(FILE_COMPLETE_MAR, false);
let path = getApplyDirFile("..", false).path;
runUpdate(STATE_AFTER_RUNUPDATE, true, 1, true, null, null, path, null);
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
await waitForUpdateXMLFiles();
@@ -30,9 +30,9 @@ async function run_test() {
// launch the maintenance service the update.status file isn't copied from
// the secure log directory to the patch directory and the update manager
// won't read the failure from the update.status file.
await checkUpdateManager(STATE_NONE, false, STATE_PENDING_SVC, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_PENDING_SVC, 0, 1);
} else {
await checkUpdateManager(
checkUpdateManager(
STATE_NONE,
false,
STATE_FAILED,

View File

@@ -18,7 +18,7 @@ async function run_test() {
await setupUpdaterTest(FILE_COMPLETE_MAR, false);
let path = "\\\\.\\" + getApplyDirFile(null, false).path;
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, path, null);
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
await waitForUpdateXMLFiles();
@@ -30,9 +30,9 @@ async function run_test() {
// launch the maintenance service the update.status file isn't copied from
// the secure log directory to the patch directory and the update manager
// won't read the failure from the update.status file.
await checkUpdateManager(STATE_NONE, false, STATE_PENDING_SVC, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_PENDING_SVC, 0, 1);
} else {
await checkUpdateManager(
checkUpdateManager(
STATE_NONE,
false,
STATE_FAILED,

View File

@@ -17,7 +17,7 @@ async function run_test() {
setTestFilesAndDirsForFailure();
await setupUpdaterTest(FILE_COMPLETE_MAR, false);
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, "test", null);
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
await waitForUpdateXMLFiles();
@@ -29,9 +29,9 @@ async function run_test() {
// launch the maintenance service the update.status file isn't copied from
// the secure log directory to the patch directory and the update manager
// won't read the failure from the update.status file.
await checkUpdateManager(STATE_NONE, false, STATE_PENDING_SVC, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_PENDING_SVC, 0, 1);
} else {
await checkUpdateManager(
checkUpdateManager(
STATE_NONE,
false,
STATE_FAILED,

View File

@@ -24,6 +24,6 @@ async function run_test() {
checkUpdateLogContains(PERFORMING_STAGED_UPDATE);
checkUpdateLogContains(ERR_UPDATE_IN_PROGRESS);
await waitForUpdateXMLFiles(true, false);
await checkUpdateManager(STATE_AFTER_STAGE, true, STATE_AFTER_STAGE, 0, 0);
checkUpdateManager(STATE_AFTER_STAGE, true, STATE_AFTER_STAGE, 0, 0);
waitForFilesInUse();
}

View File

@@ -24,12 +24,12 @@ async function run_test() {
await runUpdateUsingApp(STATE_SUCCEEDED);
await checkPostUpdateAppLog();
checkAppBundleModTime();
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
await waitForUpdateXMLFiles();
await checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
let updatesDir = getUpdateDirFile(DIR_PATCH);
Assert.ok(

View File

@@ -50,10 +50,10 @@ async function run_test() {
// Reload the update manager now that the update directory files are locked.
reloadUpdateManagerData();
await runUpdateUsingApp(STATE_PENDING);
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
await checkUpdateManager(STATE_PENDING, false, STATE_NONE, 0, 0);
checkUpdateManager(STATE_PENDING, false, STATE_NONE, 0, 0);
let dir = getUpdateDirFile(DIR_PATCH);
Assert.ok(dir.exists(), MSG_SHOULD_EXIST + getMsgPath(dir.path));

View File

@@ -32,13 +32,12 @@ async function run_test() {
writeVersionFile("0.9");
// Try to switch the application to the fake staged application.
await runUpdateUsingApp(STATE_AFTER_STAGE);
reloadUpdateManagerData();
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(false);
setTestFilesAndDirsForFailure();
checkFilesAfterUpdateFailure(getApplyDirFile);
await waitForUpdateXMLFiles();
await checkUpdateManager(
checkUpdateManager(
STATE_NONE,
false,
STATE_FAILED,

View File

@@ -23,12 +23,12 @@ async function run_test() {
await runUpdateUsingApp(STATE_SUCCEEDED);
await checkPostUpdateAppLog();
checkAppBundleModTime();
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile, false, true);
checkUpdateLogContents(LOG_REPLACE_SUCCESS, false, true);
await waitForUpdateXMLFiles();
await checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
let updatesDir = getUpdateDirFile(DIR_PATCH);
Assert.ok(

View File

@@ -21,12 +21,12 @@ async function run_test() {
);
await runUpdateUsingApp(STATE_SUCCEEDED);
checkAppBundleModTime();
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getApplyDirFile);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
await waitForUpdateXMLFiles();
await checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
let updatesDir = getUpdateDirFile(DIR_PATCH);
Assert.ok(

View File

@@ -29,7 +29,7 @@ async function run_test() {
);
await waitForHelperExit();
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
@@ -40,7 +40,7 @@ async function run_test() {
true, // aActiveUpdateExists
false // aUpdatesExists
);
await checkUpdateManager(
checkUpdateManager(
STATE_PENDING, // aStatusFileState
true, // aHasActiveUpdate
STATE_PENDING, // aUpdateStatusState

View File

@@ -23,7 +23,7 @@ async function run_test() {
// Switch the application to the staged application that was updated.
runUpdate(STATE_AFTER_RUNUPDATE, true, 1, true);
await waitForHelperExit();
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(false);
setTestFilesAndDirsForFailure();
checkFilesAfterUpdateFailure(getApplyDirFile);
@@ -32,6 +32,6 @@ async function run_test() {
ERR_MOVE_DESTDIR_7 + "\n" + STATE_FAILED_WRITE_ERROR + "\n" + CALL_QUIT
);
await waitForUpdateXMLFiles();
await checkUpdateManager(STATE_NONE, false, STATE_AFTER_RUNUPDATE, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_AFTER_RUNUPDATE, 0, 1);
checkCallbackLog();
}

View File

@@ -30,12 +30,12 @@ async function run_test() {
await checkPostUpdateAppLog();
checkAppBundleModTime();
checkSymLinks();
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile);
checkUpdateLogContents(LOG_REPLACE_SUCCESS, false, true);
await waitForUpdateXMLFiles();
await checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
checkCallbackLog();
}

View File

@@ -16,11 +16,11 @@ async function run_test() {
await waitForHelperExit();
await checkPostUpdateAppLog();
checkAppBundleModTime();
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
await waitForUpdateXMLFiles();
await checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
checkCallbackLog();
}

View File

@@ -20,11 +20,11 @@ async function run_test() {
// Switch the application to the staged application that was updated.
runUpdate(STATE_SUCCEEDED, true, 0, true);
await checkPostUpdateAppLog();
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile, false, true);
checkUpdateLogContents(LOG_REPLACE_SUCCESS, false, true);
await waitForUpdateXMLFiles();
await checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
checkCallbackLog();
}

View File

@@ -20,11 +20,11 @@ async function run_test() {
// Switch the application to the staged application that was updated.
runUpdate(STATE_SUCCEEDED, true, 0, true);
await checkPostUpdateAppLog();
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile, false, true);
checkUpdateLogContents(LOG_REPLACE_SUCCESS, false, true);
await waitForUpdateXMLFiles();
await checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
checkCallbackLog();
}

View File

@@ -14,11 +14,11 @@ async function run_test() {
await setupUpdaterTest(FILE_COMPLETE_MAR, false);
runUpdate(STATE_SUCCEEDED, false, 0, true);
await checkPostUpdateAppLog();
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
await waitForUpdateXMLFiles();
await checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
checkCallbackLog();
}

View File

@@ -14,11 +14,11 @@ async function run_test() {
await setupUpdaterTest(FILE_PARTIAL_MAR, false);
runUpdate(STATE_SUCCEEDED, false, 0, true);
await checkPostUpdateAppLog();
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile);
checkUpdateLogContents(LOG_PARTIAL_SUCCESS);
await waitForUpdateXMLFiles();
await checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
checkCallbackLog();
}

View File

@@ -28,12 +28,12 @@ async function run_test() {
runUpdate(STATE_SUCCEEDED, false, 0, true);
await checkPostUpdateAppLog();
checkAppBundleModTime();
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS, false, false, true);
await waitForUpdateXMLFiles();
await checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
// This compares the callback arguments given, including the umask before
// updating, to the umask set when the app callback is launched. They should

View File

@@ -23,12 +23,12 @@ async function run_test() {
true
);
checkAppBundleModTime();
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
checkUpdateLogContents(LOG_PARTIAL_FAILURE);
await waitForUpdateXMLFiles();
await checkUpdateManager(
checkUpdateManager(
STATE_NONE,
false,
STATE_FAILED,

View File

@@ -24,7 +24,7 @@ async function run_test() {
// Switch the application to the staged application that was updated.
runUpdate(STATE_AFTER_RUNUPDATE, true, 1, true);
await waitForHelperExit();
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(false);
setTestFilesAndDirsForFailure();
checkFilesAfterUpdateFailure(getApplyDirFile);
@@ -33,6 +33,6 @@ async function run_test() {
ERR_MOVE_DESTDIR_7 + "\n" + STATE_FAILED_WRITE_ERROR + "\n" + CALL_QUIT
);
await waitForUpdateXMLFiles();
await checkUpdateManager(STATE_NONE, false, STATE_AFTER_RUNUPDATE, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_AFTER_RUNUPDATE, 0, 1);
checkCallbackLog();
}

View File

@@ -24,7 +24,7 @@ async function run_test() {
// Switch the application to the staged application that was updated.
runUpdate(STATE_AFTER_RUNUPDATE, true, 1, true);
await waitForHelperExit();
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(false);
setTestFilesAndDirsForFailure();
checkFilesAfterUpdateFailure(getApplyDirFile);
@@ -33,6 +33,6 @@ async function run_test() {
ERR_MOVE_DESTDIR_7 + "\n" + STATE_FAILED_WRITE_ERROR + "\n" + CALL_QUIT
);
await waitForUpdateXMLFiles();
await checkUpdateManager(STATE_NONE, false, STATE_AFTER_RUNUPDATE, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_AFTER_RUNUPDATE, 0, 1);
checkCallbackLog();
}

View File

@@ -16,12 +16,12 @@ async function run_test() {
runUpdate(STATE_SUCCEEDED, false, 0, true);
await waitForHelperExit();
await checkPostUpdateAppLog();
await testPostUpdateProcessing();
standardInit();
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile, false, true);
checkUpdateLogContains(ERR_BACKUP_DISCARD);
checkUpdateLogContains(STATE_SUCCEEDED + "\n" + CALL_QUIT);
await waitForUpdateXMLFiles();
await checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
checkCallbackLog();
}

Some files were not shown because too many files have changed in this diff Show More