summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_addons_temporary_addon_buttons.js
blob: 26b558ff378656c73a9857c2c9578d2e5b4371e7 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";

/* import-globals-from helper-addons.js */
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-addons.js", this);

// Test that the reload button updates the addon list with the correct metadata.
add_task(async function () {
  const { document, tab, window } = await openAboutDebugging();
  await selectThisFirefoxPage(document, window.AboutDebugging.store);

  const ORIGINAL_EXTENSION_NAME = "Temporary web extension (original)";
  const UPDATED_EXTENSION_NAME = "Temporary web extension (updated)";
  const EXTENSION_ID = "test-devtools@mozilla.org";

  const { xpiFile: addonFile } = await installTemporaryExtensionFromXPI(
    {
      id: EXTENSION_ID,
      name: ORIGINAL_EXTENSION_NAME,
    },
    document
  );

  const originalTarget = findDebugTargetByText(
    ORIGINAL_EXTENSION_NAME,
    document
  );
  ok(
    !!originalTarget,
    "The temporary extension isinstalled with the expected name"
  );

  info("Update the name of the temporary extension in the manifest");
  updateTemporaryXPI(
    { id: EXTENSION_ID, name: UPDATED_EXTENSION_NAME },
    addonFile
  );

  info("Click on the reload button for the temporary extension");
  const reloadButton = originalTarget.querySelector(
    ".qa-temporary-extension-reload-button"
  );
  reloadButton.click();

  info(
    "Wait until the debug target with the original extension name disappears"
  );
  await waitUntil(
    () => !findDebugTargetByText(ORIGINAL_EXTENSION_NAME, document)
  );

  info("Wait until the debug target with the updated extension name appears");
  await waitUntil(() =>
    findDebugTargetByText(UPDATED_EXTENSION_NAME, document)
  );

  const updatedTarget = findDebugTargetByText(UPDATED_EXTENSION_NAME, document);
  ok(!!updatedTarget, "The temporary extension name has been updated");

  info("Click on the remove button for the temporary extension");
  const removeButton = updatedTarget.querySelector(
    ".qa-temporary-extension-remove-button"
  );
  removeButton.click();

  info(
    "Wait until the debug target with the updated extension name disappears"
  );
  await waitUntil(
    () => !findDebugTargetByText(UPDATED_EXTENSION_NAME, document)
  );

  await removeTab(tab);
});

add_task(async function () {
  const PACKAGED_EXTENSION_ID = "packaged-extension@tests";
  const PACKAGED_EXTENSION_NAME = "Packaged extension";

  const { document, tab, window } = await openAboutDebugging();
  await selectThisFirefoxPage(document, window.AboutDebugging.store);

  await installRegularExtension(
    "resources/packaged-extension/packaged-extension.xpi"
  );

  info("Wait until extension appears in about:debugging");
  await waitUntil(() =>
    findDebugTargetByText(PACKAGED_EXTENSION_NAME, document)
  );
  const target = findDebugTargetByText(PACKAGED_EXTENSION_NAME, document);

  const reloadButton = target.querySelector(
    ".qa-temporary-extension-reload-button"
  );
  ok(
    !reloadButton,
    "No reload button displayed for a regularly installed extension"
  );

  const removeButton = target.querySelector(
    ".qa-temporary-extension-remove-button"
  );
  ok(
    !removeButton,
    "No remove button displayed for a regularly installed extension"
  );

  await removeExtension(
    PACKAGED_EXTENSION_ID,
    PACKAGED_EXTENSION_NAME,
    document
  );
  await removeTab(tab);
});