summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/update/tests/unit_aus_update/onlyDownloadUpdatesThisSession.js
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/mozapps/update/tests/unit_aus_update/onlyDownloadUpdatesThisSession.js')
-rw-r--r--toolkit/mozapps/update/tests/unit_aus_update/onlyDownloadUpdatesThisSession.js69
1 files changed, 69 insertions, 0 deletions
diff --git a/toolkit/mozapps/update/tests/unit_aus_update/onlyDownloadUpdatesThisSession.js b/toolkit/mozapps/update/tests/unit_aus_update/onlyDownloadUpdatesThisSession.js
new file mode 100644
index 0000000000..ab08ac854f
--- /dev/null
+++ b/toolkit/mozapps/update/tests/unit_aus_update/onlyDownloadUpdatesThisSession.js
@@ -0,0 +1,69 @@
+/* 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";
+
+function setup() {
+ setupTestCommon();
+ start_httpserver();
+ setUpdateURL(gURLData + gHTTPHandlerPath);
+ setUpdateChannel("test_channel");
+}
+setup();
+
+/**
+ * Checks for updates and makes sure that the update process does not proceed
+ * beyond the downloading stage.
+ */
+async function downloadUpdate() {
+ let patches = getRemotePatchString({});
+ let updateString = getRemoteUpdateString({}, patches);
+ gResponseBody = getRemoteUpdatesXMLString(updateString);
+
+ let { updates } = await waitForUpdateCheck(true);
+
+ initMockIncrementalDownload();
+ gIncrementalDownloadErrorType = 3;
+
+ let downloadRestrictionHitPromise = new Promise(resolve => {
+ let downloadRestrictionHitListener = (subject, topic) => {
+ Services.obs.removeObserver(downloadRestrictionHitListener, topic);
+ resolve();
+ };
+ Services.obs.addObserver(
+ downloadRestrictionHitListener,
+ "update-download-restriction-hit"
+ );
+ });
+
+ let bestUpdate = gAUS.selectUpdate(updates);
+ let success = await gAUS.downloadUpdate(bestUpdate, false);
+ Assert.ok(success, "Update download should have started");
+ return downloadRestrictionHitPromise;
+}
+
+add_task(async function onlyDownloadUpdatesThisSession() {
+ gAUS.onlyDownloadUpdatesThisSession = true;
+
+ await downloadUpdate();
+
+ Assert.ok(
+ !gUpdateManager.readyUpdate,
+ "There should not be a ready update. The update should still be downloading"
+ );
+ Assert.ok(
+ !!gUpdateManager.downloadingUpdate,
+ "A downloading update should exist"
+ );
+ Assert.equal(
+ gUpdateManager.downloadingUpdate.state,
+ STATE_DOWNLOADING,
+ "The downloading update should still be in the downloading state"
+ );
+});
+
+add_task(async function finish() {
+ stop_httpserver(doTestFinish);
+});