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. // We reach this phase right after showing the first browser window.
// This means that any I/O at this point delayed first paint. // This means that any I/O at this point delayed first paint.
"before 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", path: "XREAppFeat:formautofill@mozilla.org.xpi",
condition: !WIN, condition: !WIN,

View File

@@ -739,7 +739,7 @@ nsBrowserContentHandler.prototype = {
overridePage = Services.urlFormatter.formatURLPref( overridePage = Services.urlFormatter.formatURLPref(
"startup.homepage_override_url" "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 /** 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 * 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, { XPCOMUtils.defineLazyServiceGetters(lazy, {
BrowserHandler: ["@mozilla.org/browser/clh;1", "nsIBrowserHandler"], BrowserHandler: ["@mozilla.org/browser/clh;1", "nsIBrowserHandler"],
PushService: ["@mozilla.org/push/Service;1", "nsIPushService"], PushService: ["@mozilla.org/push/Service;1", "nsIPushService"],
UpdateServiceStub: [
"@mozilla.org/updates/update-service-stub;1",
"nsIApplicationUpdateServiceStub",
],
}); });
ChromeUtils.defineLazyGetter( ChromeUtils.defineLazyGetter(
@@ -1519,7 +1515,6 @@ BrowserGlue.prototype = {
millisecondsIn24Hours; millisecondsIn24Hours;
if (buildDate + acceptableAge < today) { if (buildDate + acceptableAge < today) {
// This is asynchronous, but just kick it off rather than waiting.
Cc["@mozilla.org/updates/update-service;1"] Cc["@mozilla.org/updates/update-service;1"]
.getService(Ci.nsIApplicationUpdateService) .getService(Ci.nsIApplicationUpdateService)
.checkForBackgroundUpdates(); .checkForBackgroundUpdates();
@@ -3032,8 +3027,16 @@ BrowserGlue.prototype = {
name: "BackgroundUpdate", name: "BackgroundUpdate",
condition: AppConstants.MOZ_UPDATE_AGENT, condition: AppConstants.MOZ_UPDATE_AGENT,
task: async () => { task: async () => {
// Never in automation! // Never in automation! This is close to
if (!lazy.UpdateServiceStub.updateDisabledForTesting) { // `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 { try {
await lazy.BackgroundUpdate.scheduleFirefoxMessagingSystemTargetingSnapshotting(); await lazy.BackgroundUpdate.scheduleFirefoxMessagingSystemTargetingSnapshotting();
} catch (e) { } catch (e) {

View File

@@ -39,8 +39,7 @@ add_task(async function test_override_postupdate_page() {
reloadUpdateManagerData(true); reloadUpdateManagerData(true);
}); });
writeFile(XML_UPDATE, getActiveUpdateFile()); writeUpdatesToXMLFile(XML_UPDATE);
writeSuccessUpdateStatusFile();
reloadUpdateManagerData(false); reloadUpdateManagerData(false);
is( is(
@@ -102,45 +101,32 @@ function getActiveUpdateFile() {
function reloadUpdateManagerData(skipFiles = false) { function reloadUpdateManagerData(skipFiles = false) {
Cc["@mozilla.org/updates/update-manager;1"] Cc["@mozilla.org/updates/update-manager;1"]
.getService(Ci.nsIUpdateManager) .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 * @param {string} aText
* The string to write to the file. * The updates represented as a string to write to the active-update.xml file.
* @param {nsIFile} aFile
* The file to write to.
*/ */
function writeFile(aText, aFile) { function writeUpdatesToXMLFile(aText) {
const PERMS_FILE = 0o644; const PERMS_FILE = 0o644;
const MODE_WRONLY = 0x02; const MODE_WRONLY = 0x02;
const MODE_CREATE = 0x08; const MODE_CREATE = 0x08;
const MODE_TRUNCATE = 0x20; const MODE_TRUNCATE = 0x20;
if (!aFile.exists()) { let activeUpdateFile = getActiveUpdateFile();
aFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE); if (!activeUpdateFile.exists()) {
activeUpdateFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
} }
let fos = Cc["@mozilla.org/network/file-output-stream;1"].createInstance( let fos = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(
Ci.nsIFileOutputStream Ci.nsIFileOutputStream
); );
let flags = MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE; 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.write(aText, aText.length);
fos.close(); 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() { async checkUpdateInProgress() {
const aus = Cc["@mozilla.org/updates/update-service;1"].getService(
Ci.nsIApplicationUpdateService
);
let um = Cc["@mozilla.org/updates/update-manager;1"].getService( let um = Cc["@mozilla.org/updates/update-manager;1"].getService(
Ci.nsIUpdateManager Ci.nsIUpdateManager
); );
// We don't want to see an idle state just because the updater hasn't if (!um.readyUpdate && !um.downloadingUpdate) {
// initialized yet.
await aus.init();
if (aus.currentState == Ci.nsIApplicationUpdateService.STATE_IDLE) {
return; return;
} }
@@ -2584,8 +2578,12 @@ var gMainPane = {
{} {}
); );
if (rv != 1) { if (rv != 1) {
let aus = Cc["@mozilla.org/updates/update-service;1"].getService(
Ci.nsIApplicationUpdateService
);
await aus.stopDownload(); await aus.stopDownload();
await um.cleanupActiveUpdates(); um.cleanupReadyUpdate();
um.cleanupDownloadingUpdate();
UpdateListener.clearPendingAndActiveNotifications(); UpdateListener.clearPendingAndActiveNotifications();
} }
}, },

View File

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

View File

@@ -120,11 +120,10 @@ add_task(async function test_bug538331() {
if (testCase.openURL) { if (testCase.openURL) {
actionsXML += ' openURL="' + testCase.openURL + '"'; actionsXML += ' openURL="' + testCase.openURL + '"';
} }
writeFile(XML_PREFIX + actionsXML + XML_SUFFIX, getActiveUpdateFile()); writeUpdatesToXMLFile(XML_PREFIX + actionsXML + XML_SUFFIX);
} else { } else {
writeFile(XML_EMPTY, getActiveUpdateFile()); writeUpdatesToXMLFile(XML_EMPTY);
} }
writeSuccessUpdateStatusFile();
reloadUpdateManagerData(false); reloadUpdateManagerData(false);
@@ -197,45 +196,33 @@ function getActiveUpdateFile() {
function reloadUpdateManagerData(skipFiles = false) { function reloadUpdateManagerData(skipFiles = false) {
Cc["@mozilla.org/updates/update-manager;1"] Cc["@mozilla.org/updates/update-manager;1"]
.getService(Ci.nsIUpdateManager) .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 * @param aText
* The string to write to the file. * The updates represented as a string to write to the active-update.xml
* @param {nsIFile} aFile * file.
* The file to write to.
*/ */
function writeFile(aText, aFile) { function writeUpdatesToXMLFile(aText) {
const PERMS_FILE = 0o644; const PERMS_FILE = 0o644;
const MODE_WRONLY = 0x02; const MODE_WRONLY = 0x02;
const MODE_CREATE = 0x08; const MODE_CREATE = 0x08;
const MODE_TRUNCATE = 0x20; const MODE_TRUNCATE = 0x20;
if (!aFile.exists()) { let activeUpdateFile = getActiveUpdateFile();
aFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE); if (!activeUpdateFile.exists()) {
activeUpdateFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
} }
let fos = Cc["@mozilla.org/network/file-output-stream;1"].createInstance( let fos = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(
Ci.nsIFileOutputStream Ci.nsIFileOutputStream
); );
let flags = MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE; 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.write(aText, aText.length);
fos.close(); 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 Ci.nsIUpdateManager
); );
await TestUtils.waitForCondition( await TestUtils.waitForCondition(
async () => !(await um.getReadyUpdate()), () => !um.readyUpdate,
"Waiting for the ready update to be removed" "Waiting for the ready update to be removed"
); );
ok(!(await um.getReadyUpdate()), "There should not be a ready update"); ok(!um.readyUpdate, "There should not be a ready update");
let history; await TestUtils.waitForCondition(
await TestUtils.waitForCondition(async () => { () => !!um.getUpdateAt(0),
history = await um.getHistory(); "Waiting for the ready update to be moved to the update history"
return !!history[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");
ok(!!history[0], "There should be an update in the update history");
// Leave no trace. Since this test modifies its support files put them back in // Leave no trace. Since this test modifies its support files put them back in
// their original state. // their original state.
@@ -104,5 +103,6 @@ add_task(async function whats_new_page() {
updatesFile.remove(false); updatesFile.remove(false);
Cc["@mozilla.org/updates/update-manager;1"] Cc["@mozilla.org/updates/update-manager;1"]
.getService(Ci.nsIUpdateManager) .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 Ci.nsIUpdateManager
); );
await TestUtils.waitForCondition( await TestUtils.waitForCondition(
async () => !(await um.getReadyUpdate()), () => !um.readyUpdate,
"Waiting for the ready update to be removed" "Waiting for the ready update to be removed"
); );
ok(!(await um.getReadyUpdate()), "There should not be a ready update"); ok(!um.readyUpdate, "There should not be a ready update");
let history; await TestUtils.waitForCondition(
await TestUtils.waitForCondition(async () => { () => !!um.getUpdateAt(0),
history = await um.getHistory(); "Waiting for the ready update to be moved to the update history"
return !!history[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");
ok(!!history[0], "There should be an update in the update history");
// Leave no trace. Since this test modifies its support files put them back in // Leave no trace. Since this test modifies its support files put them back in
// their original state. // their original state.
@@ -105,5 +104,6 @@ add_task(async function nimbus_whats_new_page() {
updatesFile.remove(false); updatesFile.remove(false);
Cc["@mozilla.org/updates/update-manager;1"] Cc["@mozilla.org/updates/update-manager;1"]
.getService(Ci.nsIUpdateManager) .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(); getVersionParams();
if (params.backgroundUpdate) { if (params.backgroundUpdate) {
setUpdateURL(updateURL); setUpdateURL(updateURL);
await gAUS.checkForBackgroundUpdates(); gAUS.checkForBackgroundUpdates();
if (params.continueFile) { if (params.continueFile) {
await continueFileHandler(params.continueFile); await continueFileHandler(params.continueFile);
} }
if (params.waitForUpdateState) { if (params.waitForUpdateState) {
let whichUpdateFn = let whichUpdate =
params.waitForUpdateState == STATE_DOWNLOADING params.waitForUpdateState == STATE_DOWNLOADING
? "getDownloadingUpdate" ? "downloadingUpdate"
: "getReadyUpdate"; : "readyUpdate";
let update;
await TestUtils.waitForCondition( await TestUtils.waitForCondition(
async () => { () =>
update = await gUpdateManager[whichUpdateFn](); gUpdateManager[whichUpdate] &&
return update && update.state == params.waitForUpdateState; gUpdateManager[whichUpdate].state == params.waitForUpdateState,
},
"Waiting for update state: " + params.waitForUpdateState, "Waiting for update state: " + params.waitForUpdateState,
undefined, undefined,
200 200
@@ -160,7 +158,7 @@ async function initUpdate(params) {
}); });
// Display the UI after the update state equals the expected value. // Display the UI after the update state equals the expected value.
Assert.equal( Assert.equal(
update.state, gUpdateManager[whichUpdate].state,
params.waitForUpdateState, params.waitForUpdateState,
"The update state value should equal " + params.waitForUpdateState "The update state value should equal " + params.waitForUpdateState
); );
@@ -211,28 +209,30 @@ async function processUpdateStep(step) {
} }
if (checkActiveUpdate) { if (checkActiveUpdate) {
let whichUpdateFn = let whichUpdate =
checkActiveUpdate.state == STATE_DOWNLOADING checkActiveUpdate.state == STATE_DOWNLOADING
? "getDownloadingUpdate" ? "downloadingUpdate"
: "getReadyUpdate"; : "readyUpdate";
let update; await TestUtils.waitForCondition(
await TestUtils.waitForCondition(async () => { () => gUpdateManager[whichUpdate],
update = await gUpdateManager[whichUpdateFn](); "Waiting for active update"
return update; );
}, "Waiting for active update"); Assert.ok(
Assert.ok(!!update, "There should be an active update"); !!gUpdateManager[whichUpdate],
"There should be an active update"
);
Assert.equal( Assert.equal(
update.state, gUpdateManager[whichUpdate].state,
checkActiveUpdate.state, checkActiveUpdate.state,
"The active update state should equal " + checkActiveUpdate.state "The active update state should equal " + checkActiveUpdate.state
); );
} else { } else {
Assert.ok( Assert.ok(
!(await gUpdateManager.getReadyUpdate()), !gUpdateManager.readyUpdate,
"There should not be a ready update" "There should not be a ready update"
); );
Assert.ok( Assert.ok(
!(await gUpdateManager.getDownloadingUpdate()), !gUpdateManager.downloadingUpdate,
"There should not be a downloadingUpdate update" "There should not be a downloadingUpdate update"
); );
} }
@@ -244,7 +244,7 @@ async function processUpdateStep(step) {
await continueFileHandler(continueFile); await continueFileHandler(continueFile);
let patch = getPatchOfType( let patch = getPatchOfType(
data.patchType, data.patchType,
await gUpdateManager.getDownloadingUpdate() gUpdateManager.downloadingUpdate
); );
// The update is removed early when the last download fails so check // The update is removed early when the last download fails so check
// that there is a patch before proceeding. // 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; return Services.dirsvc.get("UpdRootD", Ci.nsIFile).parent.parent.path;
""" """
) )
os.makedirs(path, exist_ok=True)
self.lock_dir = Path(path) self.lock_dir = Path(path)
def assertNoLocks(self): 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); user_pref("dom.input_events.security.minTimeElapsedInMS", 0);
// Set address autofill to true for tests // Set address autofill to true for tests
user_pref("extensions.formautofill.addresses.experiments.enabled", true); user_pref("extensions.formautofill.addresses.experiments.enabled", true);
// Turn off update
user_pref("app.update.disabledForTesting", true);

View File

@@ -5,6 +5,3 @@
// Base preferences file used by the mochitest // Base preferences file used by the mochitest
/* globals user_pref */ /* globals user_pref */
/* eslint quotes: 0 */ /* 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. // storage access API spec for secure contexts.
user_pref("dom.storage_access.dont_grant_insecure_contexts", false); 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 // 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. // 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 // 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); user_pref("browser.tabs.remote.systemTriggeredAboutBlankAnywhere", true);
// Make sure speech dispatcher notification error does not impact how we measure visual perception in raptor tests // 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); 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 // TODO: Bug 1795750 - Re-enable this pref when we have a new version of the
// Quitter XPI with a simpler version format. // Quitter XPI with a simpler version format.
user_pref("extensions.webextensions.warnings-as-errors", false); 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 // disable telemetry bug 1639148
user_pref("toolkit.telemetry.server", ""); user_pref("toolkit.telemetry.server", "");
user_pref("telemetry.fog.test.localhost_port", -1); 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.autoplay.blocking_policy', 1);
user_pref('media.allowed-to-play.enabled', false); user_pref('media.allowed-to-play.enabled', false);
user_pref('media.block-autoplay-until-in-foreground', true); 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); user_pref("layout.css.prefers-color-scheme.content-override", 1);
// Force OffscreenCanvas support // Force OffscreenCanvas support
user_pref("gfx.offscreencanvas.enabled", true); 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. // Enable form autofill feature testing.
user_pref("extensions.formautofill.addresses.available", "on"); user_pref("extensions.formautofill.addresses.available", "on");
user_pref("extensions.formautofill.creditCards.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. // We use data: to tell the Quitter extension to quit.
user_pref("security.data_uri.block_toplevel_data_uri_navigations", false); 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 // TODO: Bug 1795750 - Re-enable this pref when we have a new version of the
// Quitter XPI with a simpler version format. // Quitter XPI with a simpler version format.
user_pref("extensions.webextensions.warnings-as-errors", false); 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); user_pref("network.captive-portal-service.enabled", false);
// Enable http2 websockets support // Enable http2 websockets support
user_pref("network.http.http2.websockets", true); 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("browser.newtabpage.activity-stream.showSponsoredTopSites", false);
user_pref("security.turn_off_all_security_so_that_viruses_can_take_over_this_computer", true); 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); 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 { ObjectUtils } from "resource://gre/modules/ObjectUtils.sys.mjs";
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs"; import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
import { UpdateUtils } from "resource://gre/modules/UpdateUtils.sys.mjs"; import { UpdateUtils } from "resource://gre/modules/UpdateUtils.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const Utils = TelemetryUtils; const Utils = TelemetryUtils;
@@ -34,13 +33,6 @@ ChromeUtils.defineLazyGetter(lazy, "fxAccounts", () => {
).getFxAccountsSingleton(); ).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. // The maximum length of a string (e.g. description) in the addons section.
const MAX_ADDON_STRING_LENGTH = 100; const MAX_ADDON_STRING_LENGTH = 100;
// The maximum length of a string value in the settings.attribution object. // The maximum length of a string value in the settings.attribution object.
@@ -1626,7 +1618,7 @@ EnvironmentCache.prototype = {
intl: Policy._intlLoaded ? getIntlSettings() : {}, intl: Policy._intlLoaded ? getIntlSettings() : {},
update: { update: {
channel: updateChannel, channel: updateChannel,
enabled: !lazy.UpdateServiceStub.updateDisabled, enabled: !Services.policies || Services.policies.isAllowed("appUpdate"),
}, },
userPrefs: this._getPrefData(), userPrefs: this._getPrefData(),
sandbox: this._getSandboxData(), sandbox: this._getSandboxData(),

View File

@@ -46,6 +46,23 @@ export var UpdatePing = {
Services.obs.addObserver(this, UPDATE_STAGED_TOPIC); 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 * Generate an "update" ping with reason "success" and dispatch it
* to the Telemetry system. * to the Telemetry system.
@@ -67,10 +84,7 @@ export var UpdatePing = {
// update manager should still have information about the active update: given the // 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 // previous assumptions, we can simply get the channel from the update and assume
// it matches with the state previous to the update. // it matches with the state previous to the update.
let updateManager = Cc["@mozilla.org/updates/update-manager;1"].getService( let update = this._getActiveUpdate();
Ci.nsIUpdateManager
);
let update = updateManager ? updateManager.updateInstalledAtStartup : null;
const payload = { const payload = {
reason: "success", reason: "success",
@@ -101,7 +115,7 @@ export var UpdatePing = {
* @param {String} aUpdateState The state of the downloaded patch. See * @param {String} aUpdateState The state of the downloaded patch. See
* nsIUpdateService.idl for a list of possible values. * nsIUpdateService.idl for a list of possible values.
*/ */
async _handleUpdateReady(aUpdateState) { _handleUpdateReady(aUpdateState) {
const ALLOWED_STATES = [ const ALLOWED_STATES = [
"applied", "applied",
"applied-service", "applied-service",
@@ -116,10 +130,7 @@ export var UpdatePing = {
// Get the information about the update we're going to apply from the // Get the information about the update we're going to apply from the
// update manager. // update manager.
let updateManager = Cc["@mozilla.org/updates/update-manager;1"].getService( let update = this._getActiveUpdate();
Ci.nsIUpdateManager
);
let update = updateManager ? await updateManager.getReadyUpdate() : null;
if (!update) { if (!update) {
this._log.trace( this._log.trace(
"Cannot get the update manager or no update is currently active." "Cannot get the update manager or no update is currently active."
@@ -153,10 +164,10 @@ export var UpdatePing = {
/** /**
* The notifications handler. * The notifications handler.
*/ */
async observe(aSubject, aTopic, aData) { observe(aSubject, aTopic, aData) {
this._log.trace("observe - aTopic: " + aTopic); this._log.trace("observe - aTopic: " + aTopic);
if (aTopic == UPDATE_DOWNLOADED_TOPIC || aTopic == UPDATE_STAGED_TOPIC) { 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); activeUpdateFile.remove(false);
reloadUpdateManagerData(true); reloadUpdateManagerData(true);
}); });
writeFile(XML_UPDATE, getActiveUpdateFile()); writeUpdatesToXMLFile(XML_UPDATE);
writeSuccessUpdateStatusFile();
reloadUpdateManagerData(false); reloadUpdateManagerData(false);
// Start monitoring the ping archive. // Start monitoring the ping archive.
@@ -135,45 +134,33 @@ function getActiveUpdateFile() {
function reloadUpdateManagerData(skipFiles = false) { function reloadUpdateManagerData(skipFiles = false) {
Cc["@mozilla.org/updates/update-manager;1"] Cc["@mozilla.org/updates/update-manager;1"]
.getService(Ci.nsIUpdateManager) .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 * @param aText
* The string to write to the file. * The updates represented as a string to write to the active-update.xml
* @param {nsIFile} aFile * file.
* The file to write to.
*/ */
function writeFile(aText, aFile) { function writeUpdatesToXMLFile(aText) {
const PERMS_FILE = 0o644; const PERMS_FILE = 0o644;
const MODE_WRONLY = 0x02; const MODE_WRONLY = 0x02;
const MODE_CREATE = 0x08; const MODE_CREATE = 0x08;
const MODE_TRUNCATE = 0x20; const MODE_TRUNCATE = 0x20;
if (!aFile.exists()) { let activeUpdateFile = getActiveUpdateFile();
aFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE); if (!activeUpdateFile.exists()) {
activeUpdateFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
} }
let fos = Cc["@mozilla.org/network/file-output-stream;1"].createInstance( let fos = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(
Ci.nsIFileOutputStream Ci.nsIFileOutputStream
); );
let flags = MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE; 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.write(aText, aText.length);
fos.close(); 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) { if (updateState == Ci.nsIApplicationUpdateService.STATE_DOWNLOADING) {
LOG("AppUpdater:check - downloading"); LOG("AppUpdater:check - downloading");
this.#update = await this.um.getDownloadingUpdate(); this.#update = this.um.downloadingUpdate;
await this.#downloadUpdate(); await this.#downloadUpdate();
return; return;
} }
if (updateState == Ci.nsIApplicationUpdateService.STATE_STAGING) { if (updateState == Ci.nsIApplicationUpdateService.STATE_STAGING) {
LOG("AppUpdater:check - staging"); LOG("AppUpdater:check - staging");
this.#update = await this.um.getReadyUpdate(); this.#update = this.um.readyUpdate;
await this.#awaitStagingComplete(); await this.#awaitStagingComplete();
return; return;
} }
@@ -326,7 +326,7 @@ export class AppUpdater {
} }
LOG("AppUpdater:check - Update check succeeded"); LOG("AppUpdater:check - Update check succeeded");
this.#update = await this.aus.selectUpdate(result.updates); this.#update = this.aus.selectUpdate(result.updates);
if (!this.#update) { if (!this.#update) {
LOG("AppUpdater:check - result: NO_UPDATES_FOUND"); LOG("AppUpdater:check - result: NO_UPDATES_FOUND");
this.#setStatus(AppUpdater.STATUS.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"); LOG("AppUpdater:check - Got user approval. Proceeding with download");
// If we resolved because of `aus.stateTransition`, we may actually be // If we resolved because of `aus.stateTransition`, we may actually be
// downloading a different update now. // downloading a different update now.
const downloadingUpdate = await this.um.getDownloadingUpdate(); if (this.um.downloadingUpdate) {
if (downloadingUpdate) { this.#update = this.um.downloadingUpdate;
this.#update = downloadingUpdate;
} }
} else { } else {
LOG( LOG(
@@ -420,8 +419,8 @@ export class AppUpdater {
async #downloadUpdate() { async #downloadUpdate() {
this.#setStatus(AppUpdater.STATUS.DOWNLOADING); this.#setStatus(AppUpdater.STATUS.DOWNLOADING);
let result = await this.aus.downloadUpdate(this.#update, false); let success = await this.aus.downloadUpdate(this.#update, false);
if (result != Ci.nsIApplicationUpdateService.DOWNLOAD_SUCCESS) { if (!success) {
LOG("AppUpdater:#downloadUpdate - downloadUpdate failed."); LOG("AppUpdater:#downloadUpdate - downloadUpdate failed.");
this.#setStatus(AppUpdater.STATUS.DOWNLOAD_FAILED); this.#setStatus(AppUpdater.STATUS.DOWNLOAD_FAILED);
return; return;
@@ -436,21 +435,15 @@ export class AppUpdater {
* is reached. * is reached.
*/ */
async #awaitDownloadComplete() { async #awaitDownloadComplete() {
// These cases are unlikely, but we might have just completed really fast.
let updateState = this.aus.currentState; let updateState = this.aus.currentState;
switch (updateState) { if (
case Ci.nsIApplicationUpdateService.STATE_IDLE: updateState != Ci.nsIApplicationUpdateService.STATE_DOWNLOADING &&
LOG("AppUpdater:#awaitDownloadComplete - Quick failure."); updateState != Ci.nsIApplicationUpdateService.STATE_SWAP
this.#setStatus(AppUpdater.STATUS.DOWNLOAD_FAILED); ) {
return; throw new Error(
case Ci.nsIApplicationUpdateService.STATE_STAGING: "AppUpdater:#awaitDownloadComplete invoked in unexpected state: " +
LOG("AppUpdater:#awaitDownloadComplete - Quick staging."); this.aus.getStateName(updateState)
await this.#awaitStagingComplete(); );
return;
case Ci.nsIApplicationUpdateService.STATE_PENDING:
LOG("AppUpdater:#awaitDownloadComplete - Quick pending.");
this.#onReadyToRestart();
return;
} }
// We may already be in the `DOWNLOADING` state, depending on how we entered // We may already be in the `DOWNLOADING` state, depending on how we entered
@@ -560,25 +553,12 @@ export class AppUpdater {
* is reached. * is reached.
*/ */
async #awaitStagingComplete() { async #awaitStagingComplete() {
// These cases are unlikely, but we might have just completed really fast.
let updateState = this.aus.currentState; let updateState = this.aus.currentState;
switch (updateState) { if (updateState != Ci.nsIApplicationUpdateService.STATE_STAGING) {
case Ci.nsIApplicationUpdateService.STATE_IDLE: throw new Error(
LOG("AppUpdater:#awaitStagingComplete - Quick failure."); "AppUpdater:#awaitStagingComplete invoked in unexpected state: " +
this.#setStatus(AppUpdater.STATUS.DOWNLOAD_FAILED); this.aus.getStateName(updateState)
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;
} }
LOG("AppUpdater:#awaitStagingComplete - Setting status STAGING."); 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 // During an update swap, the new update will initially be stored in
// `downloadingUpdate`. Part way through, it will be moved into // `downloadingUpdate`. Part way through, it will be moved into
// `readyUpdate` and `downloadingUpdate` will be set to `null`. // `readyUpdate` and `downloadingUpdate` will be set to `null`.
this.#update = await this.um.getDownloadingUpdate(); this.#update = this.um.downloadingUpdate;
if (!this.#update) { if (!this.#update) {
this.#update = await this.um.getReadyUpdate(); this.#update = this.um.readyUpdate;
} }
await this.#awaitDownloadComplete(); await this.#awaitDownloadComplete();

View File

@@ -59,9 +59,17 @@ export const backgroundTaskTimeoutSec = Services.prefs.getIntPref(
async function _attemptBackgroundUpdate() { async function _attemptBackgroundUpdate() {
let SLUG = "_attemptBackgroundUpdate"; let SLUG = "_attemptBackgroundUpdate";
// Most likely we will implicitly initialize update at some point, but make // Here's where we do `post-update-processing`. Creating the stub invokes the
// sure post update processing gets run, just in case. // `UpdateServiceStub()` constructor, which handles various migrations (which should not be
await lazy.UpdateService.init(); // 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( lazy.log.debug(
`${SLUG}: checking for preconditions necessary to update this installation` `${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 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 // 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 // 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 // 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(10, 12),
buildId.slice(12, 14) buildId.slice(12, 14)
).getTime() ?? 0; ).getTime() ?? 0;
const updateHistory = await lazy.UpdateManager.getHistory(); let updateTime = lazy.UpdateManager.getUpdateAt(0)?.installDate ?? 0;
let updateTime = updateHistory[0]?.installDate ?? 0;
// Check that update/build times are at most 24 hours after now. // Check that update/build times are at most 24 hours after now.
if (buildTime - now > this.promptMaxFutureVariation) { if (buildTime - now > this.promptMaxFutureVariation) {
buildTime = 0; buildTime = 0;
@@ -329,7 +328,7 @@ export var UpdateListener = {
); );
}, },
async scheduleUpdateAvailableNotification(update) { scheduleUpdateAvailableNotification(update) {
// Show a badge/banner-only notification immediately. // Show a badge/banner-only notification immediately.
this.showUpdateAvailableNotification(update, true); this.showUpdateAvailableNotification(update, true);
// Track the latest update, since we will almost certainly have a new update // 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 // doorhanger would be scheduled at least once per day. If the user
// downloads the first update, we don't want to keep alerting them. // downloads the first update, we don't want to keep alerting them.
if (!this.availablePromptScheduled) { if (!this.availablePromptScheduled) {
const suppressedPromptDelay = await this.getSuppressedPromptDelay(); this.addTimeout(Math.max(0, this.suppressedPromptDelay), () => {
this.addTimeout(Math.max(0, suppressedPromptDelay), () => {
// If we downloaded or installed an update via the badge or banner // If we downloaded or installed an update via the badge or banner
// while the timer was running, bail out of showing the doorhanger. // while the timer was running, bail out of showing the doorhanger.
if ( if (
lazy.AppUpdateService.currentState != lazy.UpdateManager.downloadingUpdate ||
Ci.nsIApplicationUpdateService.STATE_IDLE lazy.UpdateManager.readyUpdate
) { ) {
return; return;
} }
@@ -445,13 +443,13 @@ export var UpdateListener = {
} }
}, },
async handleUpdateAvailable(update, status) { handleUpdateAvailable(update, status) {
switch (status) { switch (status) {
case "show-prompt": case "show-prompt":
// If an update is available, show an update available doorhanger unless // If an update is available, show an update available doorhanger unless
// PREF_APP_UPDATE_SUPPRESS_PROMPTS is true (only on Nightly). // PREF_APP_UPDATE_SUPPRESS_PROMPTS is true (only on Nightly).
if (AppConstants.NIGHTLY_BUILD && lazy.SUPPRESS_PROMPTS) { if (AppConstants.NIGHTLY_BUILD && lazy.SUPPRESS_PROMPTS) {
await this.scheduleUpdateAvailableNotification(update); this.scheduleUpdateAvailableNotification(update);
} else { } else {
this.showUpdateAvailableNotification(update, false); this.showUpdateAvailableNotification(update, false);
} }
@@ -493,7 +491,7 @@ export var UpdateListener = {
this.clearPendingAndActiveNotifications(); this.clearPendingAndActiveNotifications();
}, },
async observe(subject, topic, status) { observe(subject, topic, status) {
let update = subject && subject.QueryInterface(Ci.nsIUpdate); let update = subject && subject.QueryInterface(Ci.nsIUpdate);
switch (topic) { switch (topic) {
@@ -503,7 +501,7 @@ export var UpdateListener = {
// in case it is set. // in case it is set.
Services.prefs.clearUserPref(PREF_APP_UPDATE_UNSUPPORTED_URL); Services.prefs.clearUserPref(PREF_APP_UPDATE_UNSUPPORTED_URL);
} }
await this.handleUpdateAvailable(update, status); this.handleUpdateAvailable(update, status);
break; break;
case "update-downloading": case "update-downloading":
this.handleUpdateDownloading(status); 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 * 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/. */ * 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 { 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 = {}; const lazy = {};
@@ -13,25 +12,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
UpdateLog: "resource://gre/modules/UpdateLog.sys.mjs", 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 DIR_UPDATES = "updates";
const FILE_UPDATE_STATUS = "update.status"; const FILE_UPDATE_STATUS = "update.status";
@@ -43,7 +23,6 @@ const KEY_OLD_UPDROOT = "OldUpdRootD";
// happens for every install rather than once per profile) // happens for every install rather than once per profile)
const PREF_PREFIX_UPDATE_DIR_MIGRATED = "app.update.migrated.updateDir3."; const PREF_PREFIX_UPDATE_DIR_MIGRATED = "app.update.migrated.updateDir3.";
const PREF_APP_UPDATE_ALTUPDATEDIRPATH = "app.update.altUpdateDirPath"; const PREF_APP_UPDATE_ALTUPDATEDIRPATH = "app.update.altUpdateDirPath";
const PREF_APP_UPDATE_DISABLEDFORTESTING = "app.update.disabledForTesting";
function getUpdateBaseDirNoCreate() { function getUpdateBaseDirNoCreate() {
if (Cu.isInAutomation) { if (Cu.isInAutomation) {
@@ -77,163 +56,55 @@ function getUpdateBaseDirNoCreate() {
return FileUtils.getDir(KEY_UPDROOT, []); return FileUtils.getDir(KEY_UPDROOT, []);
} }
export class UpdateServiceStub { export function UpdateServiceStub() {
#initUpdatePromise; LOG("UpdateServiceStub - Begin.");
#initStubHasRun = false;
/** let updateDir = getUpdateBaseDirNoCreate();
* See nsIUpdateService.idl let prefUpdateDirMigrated =
*/ PREF_PREFIX_UPDATE_DIR_MIGRATED + updateDir.leafName;
async init() {
await this.#init(false);
}
async initUpdate() {
await this.#init(true);
}
#initOnlyStub(updateDir) { let statusFile = updateDir;
// We may need to migrate update data statusFile.append(DIR_UPDATES);
let prefUpdateDirMigrated = statusFile.append("0");
PREF_PREFIX_UPDATE_DIR_MIGRATED + updateDir.leafName; statusFile.append(FILE_UPDATE_STATUS);
if ( updateDir = null; // We don't need updateDir anymore, plus now its nsIFile
AppConstants.platform == "win" && // contains the status file's path
!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}`
);
}
}
}
async #initUpdate() { // We may need to migrate update data
// Ensure that the constructors for the update services have run. if (
const aus = Cc["@mozilla.org/updates/update-service;1"].getService( AppConstants.platform == "win" &&
Ci.nsIApplicationUpdateService !Services.prefs.getBoolPref(prefUpdateDirMigrated, false)
); ) {
Cc["@mozilla.org/updates/update-manager;1"].getService(Ci.nsIUpdateManager); Services.prefs.setBoolPref(prefUpdateDirMigrated, true);
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;
try { try {
const updateDir = getUpdateBaseDirNoCreate(); migrateUpdateDirectory();
if (!this.#initStubHasRun) { } catch (ex) {
this.#initStubHasRun = true; // For the most part, migrateUpdateDirectory() catches its own errors.
try { // But there are technically things that could happen that might not be
this.#initOnlyStub(updateDir); // caught, like nsIFile.parent or nsIFile.append could unexpectedly fail.
} catch (ex) { // So we will catch any errors here, just in case.
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) {
LOG( 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}`);
}
}
} }
/** // If the update.status file exists then initiate post update processing.
* See nsIUpdateService.idl if (statusFile.exists()) {
*/ let aus = Cc["@mozilla.org/updates/update-service;1"]
get updateDisabledForTesting() { .getService(Ci.nsIApplicationUpdateService)
return ( .QueryInterface(Ci.nsIObserver);
(Cu.isInAutomation || aus.observe(null, "post-update-processing", "");
lazy.Marionette.running ||
lazy.RemoteAgent.running) &&
Services.prefs.getBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING, false)
);
} }
/**
* 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 * 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. * directory that may need to be migrated to the new update directory.

View File

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

View File

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

View File

@@ -288,21 +288,6 @@ interface nsIUpdateCheck : nsISupports
readonly attribute Promise result; 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 * An interface describing an object that knows how to check for updates. It can
* perform multiple update checks simultaneously or consolidate multiple check * perform multiple update checks simultaneously or consolidate multiple check
@@ -378,45 +363,6 @@ interface nsIUpdateChecker : nsISupports
* Ends all pending update checks. * Ends all pending update checks.
*/ */
void stopAllChecks(); 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)] [scriptable, uuid(1107d207-a263-403a-b268-05772ec10757)]
interface nsIApplicationUpdateService : nsISupports 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 * Checks for available updates in the background using the listener provided
* by the application update service for background checks. * by the application update service for background checks.
* @returns A promise resolving to `true` if the update check was started, or * @returns true if the update check was started, false if not. Note that the
* one resolving to `false` if not. Note that the check starting does * check starting does not necessarily mean that the check will
* not necessarily mean that the check will succeed or that an * succeed or that an update will be downloaded.
* update will be downloaded.
*/ */
Promise checkForBackgroundUpdates(); boolean checkForBackgroundUpdates();
/** /**
* Selects the best update to install from a list of available updates. * Selects the best update to install from a list of available updates.
* @param updates * @param updates
* An array of updates that are available * 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 * Adds a listener that receives progress and state information about the
@@ -478,28 +410,14 @@ interface nsIApplicationUpdateService : nsISupports
*/ */
void removeDownloadListener(in nsIRequestObserver listener); 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 * Starts downloading the update passed. Once the update is downloaded, it
* will automatically be prepared for installation. * will automatically be prepared for installation.
* *
* @param update * @param update
* The update to download. * The update to download.
* @returns A promise that resolves with the integer value of one of the * @returns A promise that resolves to `true` if an update download was
* `DOWNLOAD_*` constants above indicating whether or not the * started, otherwise `false.
* download was started.
*/ */
Promise downloadUpdate(in nsIUpdate update); Promise downloadUpdate(in nsIUpdate update);
@@ -709,11 +627,6 @@ interface nsIApplicationUpdateService : nsISupports
* A Promise that resolves immediately after `currentState` changes. * A Promise that resolves immediately after `currentState` changes.
*/ */
readonly attribute Promise stateTransition; 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); 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 * An interface describing a global application service that maintains a list
* of updates previously performed as well as the current active update. * of updates previously performed as well as the current active update.
@@ -864,45 +744,39 @@ interface nsIUpdateManagerInternal : nsISupports
interface nsIUpdateManager : nsISupports interface nsIUpdateManager : nsISupports
{ {
/** /**
* @returns Promise<Array<nsIUpdate>> * Gets the update at the specified index
* Resolves with an array describing the update history. The first * @param index
* element in the array represents the most recent item in the * The index within the updates array
* history. * @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 * Gets the total number of updates in the history list.
* downloaded, or null if there isn't one.
*/ */
Promise getReadyUpdate(); long getUpdateCount();
/** /**
* Returns a Promise that resolves with the nsIUpdate that is currently * The update that has been downloaded, or null if there isn't one.
* downloading, 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 * An update is no longer considered to be downloading once onStopRequest is
* called. This means that both onStopRequest handlers for download listeners * called. This means that both onStopRequest handlers for download listeners
* and observers of the "update-downloaded" topic should expect the update * and observers of the "update-downloaded" topic should expect the update
* that was just downloaded to be stored in readyUpdate, not * that was just downloaded to be stored in readyUpdate, not
* downloadingUpdate. * downloadingUpdate.
*/ */
Promise getDownloadingUpdate(); attribute nsIUpdate downloadingUpdate;
/**
* 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;
/** /**
* Adds the specified update to the update history. The update history is * 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 * limited to 10 items, so this may also remove the last item from the
* history. * 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. * Saves all updates to disk.
@@ -923,15 +797,13 @@ interface nsIUpdateManager : nsISupports
void elevationOptedIn(); 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 * 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 * downloaded. The second function does this for the update that has already
* been downloaded. The third function does this for both updates. * been downloaded.
* @returns Promise<undefined>
*/ */
Promise cleanupDownloadingUpdate(); void cleanupDownloadingUpdate();
Promise cleanupReadyUpdate(); void cleanupReadyUpdate();
Promise cleanupActiveUpdates();
/** /**
* Runs cleanup that ought to happen on a Firefox paveover install to * 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. * conveys that the cleanup has completed.
*/ */
Promise doUninstallCleanup(); 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 }, checkActiveUpdate: { state: STATE_APPLIED },
continueFile: null, continueFile: null,
}, },
async () => { () => {
prepareToDownloadVersion(SECOND_UPDATE_VERSION); prepareToDownloadVersion(SECOND_UPDATE_VERSION);
await gAUS.checkForBackgroundUpdates(); gAUS.checkForBackgroundUpdates();
}, },
{ {
panelId: "applying", panelId: "applying",

View File

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

View File

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

View File

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

View File

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

View File

@@ -54,7 +54,7 @@ add_task(async function doorhanger_bc_multiUpdate() {
prepareToDownloadVersion(SECOND_UPDATE_VERSION); prepareToDownloadVersion(SECOND_UPDATE_VERSION);
let updateSwapped = waitForEvent("update-swap"); let updateSwapped = waitForEvent("update-swap");
await gAUS.checkForBackgroundUpdates(); gAUS.checkForBackgroundUpdates();
await updateSwapped; await updateSwapped;
// The badge should be hidden while we swap from one update to the other // 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 // 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); prepareToDownloadVersion(SECOND_UPDATE_VERSION, 0);
let updateSwapped = waitForEvent("update-swap"); let updateSwapped = waitForEvent("update-swap");
await gAUS.checkForBackgroundUpdates(); gAUS.checkForBackgroundUpdates();
await updateSwapped; await updateSwapped;
// The badge should be hidden while we swap from one update to the other // 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 // 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"), () => !Services.wm.getMostRecentWindow("Update:Elevation"),
"The Update Elevation dialog should have closed" "The Update Elevation dialog should have closed"
); );
let readyUpdate = await gUpdateManager.getReadyUpdate(); ok(!!gUpdateManager.readyUpdate, "There should be a ready update");
ok(!!readyUpdate, "There should be a ready update");
is( is(
readyUpdate.state, gUpdateManager.readyUpdate.state,
STATE_PENDING_ELEVATE, STATE_PENDING_ELEVATE,
"The ready update state should equal " + 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"), () => !Services.wm.getMostRecentWindow("Update:Elevation"),
"The Update Elevation dialog should have closed" "The Update Elevation dialog should have closed"
); );
readyUpdate = await gUpdateManager.getReadyUpdate(); ok(!gUpdateManager.readyUpdate, "There should not be a ready update");
ok(!readyUpdate, "There should not be a ready update");
is( is(
readStatusFile(), readStatusFile(),
STATE_NONE, STATE_NONE,
@@ -81,10 +79,9 @@ add_task(async function elevation_dialog() {
() => !Services.wm.getMostRecentWindow("Update:Elevation"), () => !Services.wm.getMostRecentWindow("Update:Elevation"),
"The Update Elevation dialog should have closed" "The Update Elevation dialog should have closed"
); );
readyUpdate = await gUpdateManager.getReadyUpdate(); ok(!!gUpdateManager.readyUpdate, "There should be a ready update");
ok(!!readyUpdate, "There should be a ready update");
is( is(
readyUpdate.state, gUpdateManager.readyUpdate.state,
STATE_PENDING_ELEVATE, STATE_PENDING_ELEVATE,
"The active update state should equal " + 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 * @return A promise that returns the domWindow for the Update Elevation Dialog
* and resolves when the Update Elevation Dialog loads. * and resolves when the Update Elevation Dialog loads.
*/ */
async function waitForElevationDialog() { function waitForElevationDialog() {
let elevationDialogLoadedPromise = new Promise(resolve => { return new Promise(resolve => {
var listener = { var listener = {
onOpenWindow: aXULWindow => { onOpenWindow: aXULWindow => {
debugDump("Update Elevation dialog shown..."); debugDump("Update Elevation dialog shown...");
@@ -127,18 +124,16 @@ async function waitForElevationDialog() {
}; };
Services.wm.addListener(listener); 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) { if (checkActiveUpdate) {
let activeUpdate = await (checkActiveUpdate.state == STATE_DOWNLOADING let activeUpdate =
? gUpdateManager.getDownloadingUpdate() checkActiveUpdate.state == STATE_DOWNLOADING
: gUpdateManager.getReadyUpdate()); ? gUpdateManager.downloadingUpdate
: gUpdateManager.readyUpdate;
ok(!!activeUpdate, "There should be an active update"); ok(!!activeUpdate, "There should be an active update");
is( is(
activeUpdate.state, activeUpdate.state,
@@ -587,13 +588,10 @@ function runDoorhangerUpdateTest(params, steps) {
); );
} else { } else {
ok( ok(
!(await gUpdateManager.getDownloadingUpdate()), !gUpdateManager.downloadingUpdate,
"There should not be a downloading update" "There should not be a downloading update"
); );
ok( ok(!gUpdateManager.readyUpdate, "There should not be a ready update");
!(await gUpdateManager.getReadyUpdate()),
"There should not be a ready update"
);
} }
let buttonEl = getNotificationButton(window, notificationId, button); let buttonEl = getNotificationButton(window, notificationId, button);
@@ -643,10 +641,6 @@ function runDoorhangerUpdateTest(params, steps) {
// Perform a background check doorhanger test. // Perform a background check doorhanger test.
executeSoon(() => { executeSoon(() => {
(async function () { (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(); gAUS.checkForBackgroundUpdates();
for (var i = 0; i < params.checkAttempts - 1; i++) { for (var i = 0; i < params.checkAttempts - 1; i++) {
await waitForEvent("update-error", "check-attempt-failed"); await waitForEvent("update-error", "check-attempt-failed");
@@ -659,7 +653,7 @@ function runDoorhangerUpdateTest(params, steps) {
writeStatusFile(STATE_FAILED_CRC_ERROR); writeStatusFile(STATE_FAILED_CRC_ERROR);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(params.updates), true); writeUpdatesToXMLFile(getLocalUpdatesXMLString(params.updates), true);
reloadUpdateManagerData(); reloadUpdateManagerData();
await testPostUpdateProcessing(); testPostUpdateProcessing();
} }
for (let step of steps) { for (let step of steps) {
@@ -755,9 +749,10 @@ function runAboutDialogUpdateTest(params, steps) {
); );
if (checkActiveUpdate) { if (checkActiveUpdate) {
let activeUpdate = await (checkActiveUpdate.state == STATE_DOWNLOADING let activeUpdate =
? gUpdateManager.getDownloadingUpdate() checkActiveUpdate.state == STATE_DOWNLOADING
: gUpdateManager.getReadyUpdate()); ? gUpdateManager.downloadingUpdate
: gUpdateManager.readyUpdate;
ok(!!activeUpdate, "There should be an active update"); ok(!!activeUpdate, "There should be an active update");
is( is(
activeUpdate.state, activeUpdate.state,
@@ -766,13 +761,10 @@ function runAboutDialogUpdateTest(params, steps) {
); );
} else { } else {
ok( ok(
!(await gUpdateManager.getDownloadingUpdate()), !gUpdateManager.downloadingUpdate,
"There should not be a downloading update" "There should not be a downloading update"
); );
ok( ok(!gUpdateManager.readyUpdate, "There should not be a ready update");
!(await gUpdateManager.getReadyUpdate()),
"There should not be a ready update"
);
} }
// Some tests just want to stop at the downloading state. These won't // Some tests just want to stop at the downloading state. These won't
@@ -783,7 +775,7 @@ function runAboutDialogUpdateTest(params, steps) {
await continueFileHandler(continueFile); await continueFileHandler(continueFile);
let patch = getPatchOfType( let patch = getPatchOfType(
data.patchType, data.patchType,
await gUpdateManager.getDownloadingUpdate() gUpdateManager.downloadingUpdate
); );
// The update is removed early when the last download fails so check // The update is removed early when the last download fails so check
// that there is a patch before proceeding. // that there is a patch before proceeding.
@@ -924,21 +916,19 @@ function runAboutDialogUpdateTest(params, steps) {
getVersionParams(params.version); getVersionParams(params.version);
if (params.backgroundUpdate) { if (params.backgroundUpdate) {
setUpdateURL(updateURL); setUpdateURL(updateURL);
await gAUS.checkForBackgroundUpdates(); gAUS.checkForBackgroundUpdates();
if (params.continueFile) { if (params.continueFile) {
await continueFileHandler(params.continueFile); await continueFileHandler(params.continueFile);
} }
if (params.waitForUpdateState) { if (params.waitForUpdateState) {
let whichUpdateFn = let whichUpdate =
params.waitForUpdateState == STATE_DOWNLOADING params.waitForUpdateState == STATE_DOWNLOADING
? "getDownloadingUpdate" ? "downloadingUpdate"
: "getReadyUpdate"; : "readyUpdate";
let update;
await TestUtils.waitForCondition( await TestUtils.waitForCondition(
async () => { () =>
update = await gUpdateManager[whichUpdateFn](); gUpdateManager[whichUpdate] &&
return update && update.state == params.waitForUpdateState; gUpdateManager[whichUpdate].state == params.waitForUpdateState,
},
"Waiting for update state: " + params.waitForUpdateState, "Waiting for update state: " + params.waitForUpdateState,
undefined, undefined,
200 200
@@ -949,7 +939,7 @@ function runAboutDialogUpdateTest(params, steps) {
}); });
// Display the UI after the update state equals the expected value. // Display the UI after the update state equals the expected value.
is( is(
update.state, gUpdateManager[whichUpdate].state,
params.waitForUpdateState, params.waitForUpdateState,
"The update state value should equal " + params.waitForUpdateState "The update state value should equal " + params.waitForUpdateState
); );
@@ -1066,9 +1056,10 @@ function runAboutPrefsUpdateTest(params, steps) {
); );
if (checkActiveUpdate) { if (checkActiveUpdate) {
let activeUpdate = await (checkActiveUpdate.state == STATE_DOWNLOADING let activeUpdate =
? gUpdateManager.getDownloadingUpdate() checkActiveUpdate.state == STATE_DOWNLOADING
: gUpdateManager.getReadyUpdate()); ? gUpdateManager.downloadingUpdate
: gUpdateManager.readyUpdate;
ok(!!activeUpdate, "There should be an active update"); ok(!!activeUpdate, "There should be an active update");
is( is(
activeUpdate.state, activeUpdate.state,
@@ -1077,13 +1068,10 @@ function runAboutPrefsUpdateTest(params, steps) {
); );
} else { } else {
ok( ok(
!(await gUpdateManager.getDownloadingUpdate()), !gUpdateManager.downloadingUpdate,
"There should not be a downloading update" "There should not be a downloading update"
); );
ok( ok(!gUpdateManager.readyUpdate, "There should not be a ready update");
!(await gUpdateManager.getReadyUpdate()),
"There should not be a ready update"
);
} }
if (panelId == "downloading") { if (panelId == "downloading") {
@@ -1096,7 +1084,7 @@ function runAboutPrefsUpdateTest(params, steps) {
await continueFileHandler(continueFile); await continueFileHandler(continueFile);
let patch = getPatchOfType( let patch = getPatchOfType(
data.patchType, data.patchType,
await gUpdateManager.getDownloadingUpdate() gUpdateManager.downloadingUpdate
); );
// The update is removed early when the last download fails so check // The update is removed early when the last download fails so check
// that there is a patch before proceeding. // that there is a patch before proceeding.
@@ -1260,23 +1248,21 @@ function runAboutPrefsUpdateTest(params, steps) {
getVersionParams(params.version); getVersionParams(params.version);
if (params.backgroundUpdate) { if (params.backgroundUpdate) {
setUpdateURL(updateURL); setUpdateURL(updateURL);
await gAUS.checkForBackgroundUpdates(); gAUS.checkForBackgroundUpdates();
if (params.continueFile) { if (params.continueFile) {
await continueFileHandler(params.continueFile); await continueFileHandler(params.continueFile);
} }
if (params.waitForUpdateState) { if (params.waitForUpdateState) {
// Wait until the update state equals the expected value before // Wait until the update state equals the expected value before
// displaying the UI. // displaying the UI.
let whichUpdateFn = let whichUpdate =
params.waitForUpdateState == STATE_DOWNLOADING params.waitForUpdateState == STATE_DOWNLOADING
? "getDownloadingUpdate" ? "downloadingUpdate"
: "getReadyUpdate"; : "readyUpdate";
let update;
await TestUtils.waitForCondition( await TestUtils.waitForCondition(
async () => { () =>
update = await gUpdateManager[whichUpdateFn](); gUpdateManager[whichUpdate] &&
return update && update.state == params.waitForUpdateState; gUpdateManager[whichUpdate].state == params.waitForUpdateState,
},
"Waiting for update state: " + params.waitForUpdateState, "Waiting for update state: " + params.waitForUpdateState,
undefined, undefined,
200 200
@@ -1286,7 +1272,7 @@ function runAboutPrefsUpdateTest(params, steps) {
logTestInfo(e); logTestInfo(e);
}); });
is( is(
update.state, gUpdateManager[whichUpdate].state,
params.waitForUpdateState, params.waitForUpdateState,
"The update state value should equal " + params.waitForUpdateState "The update state value should equal " + params.waitForUpdateState
); );
@@ -1367,10 +1353,6 @@ function runTelemetryUpdateTest(updateParams, event, stageFailure = false) {
updateParams + updateParams +
getVersionParams(); getVersionParams();
setUpdateURL(updateURL); 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(); gAUS.checkForBackgroundUpdates();
await waitForEvent(event); 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 // But the two entry points just immediately call the same function, so this
// should probably be alright. // should probably be alright.
is( is(
await gAUS.checkForBackgroundUpdates(), gAUS.checkForBackgroundUpdates(),
false, false,
"gAUS.checkForBackgroundUpdates() should not proceed with update check" "gAUS.checkForBackgroundUpdates() should not proceed with update check"
); );

View File

@@ -76,15 +76,6 @@ function handleRequest(aRequest, aResponse) {
return; 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; let retries = 0;
gSlowDownloadTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); gSlowDownloadTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
gSlowDownloadTimer.initWithCallback( gSlowDownloadTimer.initWithCallback(
@@ -101,7 +92,7 @@ function handleRequest(aRequest, aResponse) {
continueFile.remove(false); continueFile.remove(false);
} }
gSlowDownloadTimer.cancel(); gSlowDownloadTimer.cancel();
aResponse.write(marBytes); aResponse.write(readFileBytes(getTestDataFile(FILE_SIMPLE_MAR)));
aResponse.finish(); aResponse.finish();
} catch (e) {} } catch (e) {}
} }
@@ -151,9 +142,6 @@ function handleRequest(aRequest, aResponse) {
let url = ""; let url = "";
if (params.useSlowDownloadMar) { if (params.useSlowDownloadMar) {
url = URL_HTTP_UPDATE_SJS + "?slowDownloadMar=1"; url = URL_HTTP_UPDATE_SJS + "?slowDownloadMar=1";
if (params.useFirstByteEarly) {
url += "&amp;firstByteEarly=1";
}
} else { } else {
url = params.badURL ? BAD_SERVICE_URL : SERVICE_URL; url = params.badURL ? BAD_SERVICE_URL : SERVICE_URL;
} }

View File

@@ -176,16 +176,15 @@ function waitForEvent(topic, status = null) {
} }
/* Triggers post-update processing */ /* Triggers post-update processing */
async function testPostUpdateProcessing() { function testPostUpdateProcessing() {
await gAUS.internal.postUpdateProcessing(); gAUS.observe(null, "test-post-update-processing", "");
} }
/* Initializes the update service stub */ /* Initializes the update service stub */
async function initUpdateServiceStub() { function initUpdateServiceStub() {
const updateServiceStub = Cc[ Cc["@mozilla.org/updates/update-service-stub;1"].createInstance(
"@mozilla.org/updates/update-service-stub;1" Ci.nsISupports
].getService(Ci.nsIApplicationUpdateServiceStub); );
await updateServiceStub.init();
} }
/** /**
@@ -197,7 +196,10 @@ async function initUpdateServiceStub() {
* to populate the update metadata. * to populate the update metadata.
*/ */
function reloadUpdateManagerData(skipFiles = false) { 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 = { const observer = {

View File

@@ -1305,16 +1305,17 @@ function checkAppBundleModTime() {
* @param aUpdateCount * @param aUpdateCount
* The update history's update count. * The update history's update count.
*/ */
async function checkUpdateManager( function checkUpdateManager(
aStatusFileState, aStatusFileState,
aHasActiveUpdate, aHasActiveUpdate,
aUpdateStatusState, aUpdateStatusState,
aUpdateErrCode, aUpdateErrCode,
aUpdateCount aUpdateCount
) { ) {
let activeUpdate = await (aUpdateStatusState == STATE_DOWNLOADING let activeUpdate =
? gUpdateManager.getDownloadingUpdate() aUpdateStatusState == STATE_DOWNLOADING
: gUpdateManager.getReadyUpdate()); ? gUpdateManager.downloadingUpdate
: gUpdateManager.readyUpdate;
Assert.equal( Assert.equal(
readStatusState(), readStatusState(),
aStatusFileState, aStatusFileState,
@@ -1336,14 +1337,13 @@ async function checkUpdateManager(
msgTags[i] + "the active update should not be defined" msgTags[i] + "the active update should not be defined"
); );
} }
const history = await gUpdateManager.getHistory();
Assert.equal( Assert.equal(
history.length, gUpdateManager.getUpdateCount(),
aUpdateCount, aUpdateCount,
msgTags[i] + "the update manager updateCount attribute" + MSG_SHOULD_EQUAL msgTags[i] + "the update manager updateCount attribute" + MSG_SHOULD_EQUAL
); );
if (aUpdateCount > 0) { if (aUpdateCount > 0) {
let update = history[0]; let update = gUpdateManager.getUpdateAt(0);
Assert.equal( Assert.equal(
update.state, update.state,
aUpdateStatusState, aUpdateStatusState,
@@ -1445,9 +1445,9 @@ function checkPostUpdateRunningFile(aShouldExist) {
* Initializes the most commonly used settings and creates an instance of the * Initializes the most commonly used settings and creates an instance of the
* update service stub. * update service stub.
*/ */
async function standardInit() { function standardInit() {
// Initialize the update service stub component // 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. * Sets the active update and related information for updater tests.
*/ */
async function setupActiveUpdate() { 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();
let pendingState = gIsServiceTest ? STATE_PENDING_SVC : STATE_PENDING; let pendingState = gIsServiceTest ? STATE_PENDING_SVC : STATE_PENDING;
let patchProps = { state: pendingState }; let patchProps = { state: pendingState };
let patches = getLocalPatchString(patchProps); let patches = getLocalPatchString(patchProps);
@@ -2299,10 +2294,7 @@ async function setupActiveUpdate() {
writeVersionFile(DEFAULT_UPDATE_VERSION); writeVersionFile(DEFAULT_UPDATE_VERSION);
writeStatusFile(pendingState); writeStatusFile(pendingState);
reloadUpdateManagerData(); reloadUpdateManagerData();
Assert.ok( Assert.ok(!!gUpdateManager.readyUpdate, "the ready update should be defined");
!!(await gUpdateManager.getReadyUpdate()),
"the ready update should be defined"
);
} }
/** /**
@@ -2364,7 +2356,7 @@ async function stageUpdate(
); );
Assert.equal( Assert.equal(
(await gUpdateManager.getReadyUpdate()).state, gUpdateManager.readyUpdate.state,
aStateAfterStage, aStateAfterStage,
"the update state" + MSG_SHOULD_EQUAL "the update state" + MSG_SHOULD_EQUAL
); );
@@ -3169,11 +3161,6 @@ async function setupUpdaterTest(
{ requiresOmnijar = false } = {} { requiresOmnijar = false } = {}
) { ) {
debugDump("start - updater test setup"); 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); let updatesPatchDir = getUpdateDirFile(DIR_PATCH);
if (!updatesPatchDir.exists()) { if (!updatesPatchDir.exists()) {
updatesPatchDir.create(Ci.nsIFile.DIRECTORY_TYPE, PERMS_DIRECTORY); updatesPatchDir.create(Ci.nsIFile.DIRECTORY_TYPE, PERMS_DIRECTORY);
@@ -3311,7 +3298,7 @@ async function setupUpdaterTest(
}); });
if (aSetupActiveUpdate) { if (aSetupActiveUpdate) {
await setupActiveUpdate(); setupActiveUpdate();
} }
if (aPostUpdateAsync !== null) { if (aPostUpdateAsync !== null) {
@@ -4296,10 +4283,10 @@ async function waitForUpdateCheck(aSuccess, aExpectedValues = {}) {
* onStopRequest occurs and returns the arguments from onStopRequest. * onStopRequest occurs and returns the arguments from onStopRequest.
*/ */
async function waitForUpdateDownload(aUpdates, aExpectedStatus) { async function waitForUpdateDownload(aUpdates, aExpectedStatus) {
let bestUpdate = await gAUS.selectUpdate(aUpdates); let bestUpdate = gAUS.selectUpdate(aUpdates);
let result = await gAUS.downloadUpdate(bestUpdate, false); let success = await gAUS.downloadUpdate(bestUpdate, false);
if (result != Ci.nsIApplicationUpdateService.DOWNLOAD_SUCCESS) { if (!success) {
do_throw("nsIApplicationUpdateService:downloadUpdate returned " + result); do_throw("nsIApplicationUpdateService:downloadUpdate returned " + success);
} }
return new Promise(resolve => return new Promise(resolve =>
gAUS.addDownloadListener({ gAUS.addDownloadListener({

View File

@@ -137,58 +137,30 @@ class TestNoWindowUpdateRestart(MarionetteTestCase):
) )
self.assertTrue(quit_flags_correct) 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; let statusFile = FileUtils.getDir("UpdRootD", ["updates", "0"]);
(async () => { statusFile.append("update.status");
// Because post update processing happens during early startup and return statusFile.path;
// `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"),),
) )
with open(update_status_path, "r") as f:
# If Firefox was built with "--enable-unverified-updates" (or presumably if we tested # 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 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 # 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 # 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 # trying to test whether the update applied successfully, just whether the
# "No Window Update Restart" feature attempted to apply an update. # "No Window Update Restart" feature works.
# So both success and failure are fine. Any in-progress state is not. self.assertIn(f.read().strip(), ["succeeded", "failed: 19"])
self.assertIn(update_status, ["succeeded", "failed"])
def resetUpdate(self): def resetUpdate(self):
self.marionette.execute_script( self.marionette.execute_script(
""" """
let UM = Cc["@mozilla.org/updates/update-manager;1"].getService(Ci.nsIUpdateManager); 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( let { UpdateListener } = ChromeUtils.importESModule(
"resource://gre/modules/UpdateListener.sys.mjs" "resource://gre/modules/UpdateListener.sys.mjs"
@@ -267,7 +239,7 @@ class TestNoWindowUpdateRestart(MarionetteTestCase):
let aus = Cc["@mozilla.org/updates/update-service;1"] let aus = Cc["@mozilla.org/updates/update-service;1"]
.getService(Ci.nsIApplicationUpdateService); .getService(Ci.nsIApplicationUpdateService);
await aus.checkForBackgroundUpdates(); aus.checkForBackgroundUpdates();
await updateDownloadedPromise; await updateDownloadedPromise;

View File

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

View File

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

View File

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

View File

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

View File

@@ -17,23 +17,19 @@ async function run_test() {
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true); writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeStatusFile(STATE_NONE); writeStatusFile(STATE_NONE);
await standardInit(); standardInit();
Assert.ok( Assert.ok(
!(await gUpdateManager.getDownloadingUpdate()), !gUpdateManager.downloadingUpdate,
"there should not be a downloading update" "there should not be a downloading update"
); );
Assert.ok( Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update");
!(await gUpdateManager.getReadyUpdate()),
"there should not be a ready update"
);
const history = await gUpdateManager.getHistory();
Assert.equal( Assert.equal(
history.length, gUpdateManager.getUpdateCount(),
1, 1,
"the update manager update count" + MSG_SHOULD_EQUAL "the update manager update count" + MSG_SHOULD_EQUAL
); );
let update = history[0]; let update = gUpdateManager.getUpdateAt(0);
Assert.equal( Assert.equal(
update.state, update.state,
STATE_FAILED, 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 // Check that there are no active updates first so the updates directory is
// cleaned up by the UpdateManager before the remaining tests. // cleaned up by the UpdateManager before the remaining tests.
Assert.ok( Assert.ok(
!(await gUpdateManager.getDownloadingUpdate()), !gUpdateManager.downloadingUpdate,
"there should not be a downloading update" "there should not be a downloading update"
); );
Assert.ok( Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update");
!(await gUpdateManager.getReadyUpdate()),
"there should not be a ready update"
);
const history = await gUpdateManager.getHistory();
Assert.equal( Assert.equal(
history.length, gUpdateManager.getUpdateCount(),
1, 1,
"the update manager update count" + MSG_SHOULD_EQUAL "the update manager update count" + MSG_SHOULD_EQUAL
); );
let update = history[0]; let update = gUpdateManager.getUpdateAt(0);
Assert.equal( Assert.equal(
update.state, update.state,
STATE_FAILED, STATE_FAILED,

View File

@@ -21,27 +21,18 @@ async function run_test() {
log = getUpdateDirFile(FILE_UPDATE_ELEVATED_LOG); log = getUpdateDirFile(FILE_UPDATE_ELEVATED_LOG);
writeFile(log, "Last Update Elevated Log"); writeFile(log, "Last Update Elevated Log");
await standardInit(); standardInit();
Assert.ok( Assert.ok(
!(await gUpdateManager.getDownloadingUpdate()), !gUpdateManager.downloadingUpdate,
"there should not be a downloading update" "there should not be a downloading update"
); );
Assert.ok( Assert.ok(!gUpdateManager.readyUpdate, "there should not be a ready update");
!(await gUpdateManager.getReadyUpdate()),
"there should not be a ready update"
);
const history = await gUpdateManager.getHistory();
Assert.equal( Assert.equal(
history.length, gUpdateManager.getUpdateCount(),
1, 1,
"the update manager update count" + MSG_SHOULD_EQUAL "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(); await waitForUpdateXMLFiles();
let cancelations = Services.prefs.getIntPref(PREF_APP_UPDATE_CANCELATIONS, 0); let cancelations = Services.prefs.getIntPref(PREF_APP_UPDATE_CANCELATIONS, 0);
@@ -82,15 +73,5 @@ async function run_test() {
let dir = getUpdateDirFile(DIR_PATCH); let dir = getUpdateDirFile(DIR_PATCH);
Assert.ok(dir.exists(), MSG_SHOULD_EXIST); 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(); doTestFinish();
} }

View File

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

View File

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

View File

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

View File

@@ -55,7 +55,7 @@ async function testTransition(options) {
async function run_test() { async function run_test() {
setupTestCommon(null); setupTestCommon(null);
await standardInit(); standardInit();
// The setup functions we use for update testing typically allow for update. // 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 // 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 // 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); gAUS.addDownloadListener(listener);
let bestUpdate = await gAUS.selectUpdate(updates); let bestUpdate = gAUS.selectUpdate(updates);
await gAUS.downloadUpdate(bestUpdate, false); await gAUS.downloadUpdate(bestUpdate, false);
await waitForEvent("update-downloaded"); await waitForEvent("update-downloaded");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -24,6 +24,11 @@ const { sinon } = ChromeUtils.importESModule(
// We can't reasonably check NO_MOZ_BACKGROUNDTASKS, nor NO_OMNIJAR. // 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() { function setup_enterprise_policy_testing() {
// This initializes the policy engine for xpcshell tests // This initializes the policy engine for xpcshell tests
let policies = Cc["@mozilla.org/enterprisepolicies;1"].getService( let policies = Cc["@mozilla.org/enterprisepolicies;1"].getService(
@@ -44,12 +49,7 @@ async function setupPolicyEngineWithJson(json, customSchema) {
return EnterprisePolicyTesting.setupPolicyEngineWithJson(json, customSchema); return EnterprisePolicyTesting.setupPolicyEngineWithJson(json, customSchema);
} }
add_setup(async function test_setup() { add_setup(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();
// FOG needs a profile directory to put its data in. // FOG needs a profile directory to put its data in.
do_get_profile(); do_get_profile();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -24,6 +24,6 @@ async function run_test() {
checkUpdateLogContains(PERFORMING_STAGED_UPDATE); checkUpdateLogContains(PERFORMING_STAGED_UPDATE);
checkUpdateLogContains(ERR_UPDATE_IN_PROGRESS); checkUpdateLogContains(ERR_UPDATE_IN_PROGRESS);
await waitForUpdateXMLFiles(true, false); 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(); waitForFilesInUse();
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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