summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_downloadOptIn.js
blob: 6b8a5dad6c165e4796e213b3f97180dae5c8b5e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

add_task(async function doorhanger_bc_downloadOptIn() {
  await SpecialPowers.pushPrefEnv({
    set: [
      [
        "app.releaseNotesURL.prompt",
        `${URL_HOST}/%LOCALE%/firefox/%VERSION%/releasenotes/?utm_source=firefox-browser&utm_medium=firefox-desktop&utm_campaign=updateprompt`,
      ],
    ],
  });
  await UpdateUtils.setAppUpdateAutoEnabled(false);

  let version = "9999999.0";

  let params = {
    checkAttempts: 1,
    queryString: "&invalidCompleteSize=1&promptWaitTime=0",
    version,
  };

  let versionString = version;
  switch (UpdateUtils.getUpdateChannel(false)) {
    case "beta":
    case "aurora":
      versionString += "beta";
      break;
  }

  await runDoorhangerUpdateTest(params, [
    {
      // Test that the Learn More link opens the correct release notes page.
      notificationId: "update-available",
      button: n => n.querySelector(".popup-notification-learnmore-link"),
      checkActiveUpdate: null,
      pageURLs: {
        manual: Services.urlFormatter.formatURL(
          `${URL_HOST}/%LOCALE%/firefox/${versionString}/releasenotes/?utm_source=firefox-browser&utm_medium=firefox-desktop&utm_campaign=updateprompt`
        ),
      },
    },
    {
      notificationId: "update-available",
      button: "button",
      checkActiveUpdate: null,
      popupShown: true,
    },
    {
      notificationId: "update-restart",
      button: "secondaryButton",
      checkActiveUpdate: { state: STATE_PENDING },
    },
  ]);
});