tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_updateAsk.js (2033B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 // Checks the UPDATE_ASK tip.
      5 //
      6 // The update parts of this test are adapted from:
      7 // https://searchfox.org/mozilla-central/source/toolkit/mozapps/update/tests/browser/browser_aboutDialog_fc_downloadOptIn.js
      8 
      9 "use strict";
     10 
     11 let params = { queryString: "&invalidCompleteSize=1" };
     12 
     13 let downloadInfo = [];
     14 if (Services.prefs.getBoolPref(PREF_APP_UPDATE_BITS_ENABLED, false)) {
     15  downloadInfo[0] = { patchType: "partial", bitsResult: "0" };
     16 } else {
     17  downloadInfo[0] = { patchType: "partial", internalResult: "0" };
     18 }
     19 
     20 let preSteps = [
     21  {
     22    panelId: "checkingForUpdates",
     23    checkActiveUpdate: null,
     24    continueFile: CONTINUE_CHECK,
     25  },
     26  {
     27    panelId: "downloadAndInstall",
     28    checkActiveUpdate: null,
     29    continueFile: null,
     30  },
     31 ];
     32 
     33 let postSteps = [
     34  {
     35    panelId: "downloading",
     36    checkActiveUpdate: { state: STATE_DOWNLOADING },
     37    continueFile: CONTINUE_DOWNLOAD,
     38    downloadInfo,
     39  },
     40  {
     41    panelId: "apply",
     42    checkActiveUpdate: { state: STATE_PENDING },
     43    continueFile: null,
     44  },
     45 ];
     46 
     47 add_task(async function test() {
     48  await SpecialPowers.pushPrefEnv({
     49    set: [["browser.urlbar.suggest.quickactions", false]],
     50  });
     51 
     52  // Disable the pref that automatically downloads and installs updates.
     53  await UpdateUtils.setAppUpdateAutoEnabled(false);
     54 
     55  // Set up the "download and install" update state.
     56  await initUpdate(params);
     57  UrlbarProviderInterventions.checkForBrowserUpdate(true);
     58  await processUpdateSteps(preSteps);
     59 
     60  // Pick the tip and continue with the mock update, which should attempt to
     61  // restart the browser.
     62  await doUpdateTest({
     63    searchString: SEARCH_STRINGS.UPDATE,
     64    tip: UrlbarProviderInterventions.TIP_TYPE.UPDATE_ASK,
     65    title: /^A new version of .+ is available\.$/,
     66    button: "Install and Restart to Update",
     67    awaitCallback() {
     68      return Promise.all([
     69        processUpdateSteps(postSteps),
     70        awaitAppRestartRequest(),
     71      ]);
     72    },
     73  });
     74 });