summaryrefslogtreecommitdiffstats
path: root/browser/components/urlbar/tests/browser-tips/browser_updateAsk.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/urlbar/tests/browser-tips/browser_updateAsk.js')
-rw-r--r--browser/components/urlbar/tests/browser-tips/browser_updateAsk.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/browser/components/urlbar/tests/browser-tips/browser_updateAsk.js b/browser/components/urlbar/tests/browser-tips/browser_updateAsk.js
new file mode 100644
index 0000000000..3f2014d8c0
--- /dev/null
+++ b/browser/components/urlbar/tests/browser-tips/browser_updateAsk.js
@@ -0,0 +1,74 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Checks the UPDATE_ASK tip.
+//
+// The update parts of this test are adapted from:
+// https://searchfox.org/mozilla-central/source/toolkit/mozapps/update/tests/browser/browser_aboutDialog_fc_downloadOptIn.js
+
+"use strict";
+
+let params = { queryString: "&invalidCompleteSize=1" };
+
+let downloadInfo = [];
+if (Services.prefs.getBoolPref(PREF_APP_UPDATE_BITS_ENABLED, false)) {
+ downloadInfo[0] = { patchType: "partial", bitsResult: "0" };
+} else {
+ downloadInfo[0] = { patchType: "partial", internalResult: "0" };
+}
+
+let preSteps = [
+ {
+ panelId: "checkingForUpdates",
+ checkActiveUpdate: null,
+ continueFile: CONTINUE_CHECK,
+ },
+ {
+ panelId: "downloadAndInstall",
+ checkActiveUpdate: null,
+ continueFile: null,
+ },
+];
+
+let postSteps = [
+ {
+ panelId: "downloading",
+ checkActiveUpdate: { state: STATE_DOWNLOADING },
+ continueFile: CONTINUE_DOWNLOAD,
+ downloadInfo,
+ },
+ {
+ panelId: "apply",
+ checkActiveUpdate: { state: STATE_PENDING },
+ continueFile: null,
+ },
+];
+
+add_task(async function test() {
+ await SpecialPowers.pushPrefEnv({
+ set: [["browser.urlbar.suggest.quickactions", false]],
+ });
+
+ // Disable the pref that automatically downloads and installs updates.
+ await UpdateUtils.setAppUpdateAutoEnabled(false);
+
+ // Set up the "download and install" update state.
+ await initUpdate(params);
+ UrlbarProviderInterventions.checkForBrowserUpdate(true);
+ await processUpdateSteps(preSteps);
+
+ // Pick the tip and continue with the mock update, which should attempt to
+ // restart the browser.
+ await doUpdateTest({
+ searchString: SEARCH_STRINGS.UPDATE,
+ tip: UrlbarProviderInterventions.TIP_TYPE.UPDATE_ASK,
+ title: /^A new version of .+ is available\.$/,
+ button: "Install and Restart to Update",
+ awaitCallback() {
+ return Promise.all([
+ processUpdateSteps(postSteps),
+ awaitAppRestartRequest(),
+ ]);
+ },
+ });
+});