summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_addons_warnings.js
blob: db46754caa43d9630ec0ab70bd29be4a1dcd6af0 (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
/* 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 extension warnings are displayed in about:debugging.
add_task(async function () {
  const EXTENSION_NAME = "Temporary web extension";
  const EXTENSION_ID = "test-devtools@mozilla.org";

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

  await pushPref("extensions.webextensions.warnings-as-errors", false);
  await installTemporaryExtensionFromXPI(
    {
      id: EXTENSION_ID,
      name: EXTENSION_NAME,
      extraProperties: {
        // This property is not expected in the manifest and should trigger a warning!
        wrongProperty: {},
      },
    },
    document
  );
  await SpecialPowers.popPrefEnv();

  info("Wait until a debug target item appears");
  await waitUntil(() => findDebugTargetByText(EXTENSION_NAME, document));
  const target = findDebugTargetByText(EXTENSION_NAME, document);

  const warningMessage = target.querySelector(".qa-message");
  ok(
    !!warningMessage,
    "A warning message is displayed for the installed addon"
  );

  const warningText = warningMessage.textContent;
  ok(
    warningText.includes("wrongProperty"),
    "The warning message mentions wrongProperty"
  );

  await removeTemporaryExtension(EXTENSION_NAME, document);
  await removeTab(tab);
});