summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/browser/browser_webconsole_webextension_promise_rejection.js
blob: a575e3e13f2723d177c0ddb9d64007c799c86ed5 (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

// Tests that an uncaught promise rejection from a content script
// is reported to the tabs' webconsole.

"use strict";

const TEST_URI =
  "https://example.com/browser/devtools/client/webconsole/" +
  "test/browser/test-blank.html";

add_task(async function () {
  const extension = ExtensionTestUtils.loadExtension({
    manifest: {
      content_scripts: [
        {
          matches: [TEST_URI],
          js: ["content-script.js"],
        },
      ],
    },

    files: {
      "content-script.js": function () {
        Promise.reject("abc");
      },
    },
  });

  await extension.startup();

  const hud = await openNewTabAndConsole(TEST_URI);
  await waitFor(() => findErrorMessage(hud, "uncaught exception: abc"));

  await extension.unload();
});