summaryrefslogtreecommitdiffstats
path: root/browser/components/screenshots/tests/browser/browser_screenshots_focus_test.js
blob: 5e9937f8e11bdf7cd6db11dd515caea885fc1d2f (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const SCREENSHOTS_EVENTS = [
  { category: "screenshots", method: "started", object: "toolbar_button" },
  { category: "screenshots", method: "canceled", object: "escape" },
];

add_task(async function testPanelFocused() {
  await BrowserTestUtils.withNewTab(
    {
      gBrowser,
      url: TEST_PAGE,
    },
    async browser => {
      await clearAllTelemetryEvents();
      let helper = new ScreenshotsHelper(browser);

      helper.triggerUIFromToolbar();

      await helper.waitForOverlay();

      let screenshotsButtons = gBrowser.selectedBrowser.ownerDocument
        .querySelector("#screenshotsPagePanel")
        .querySelector("screenshots-buttons").shadowRoot;

      let focusedElement = screenshotsButtons.querySelector(".visible-page");

      is(
        focusedElement,
        screenshotsButtons.activeElement,
        "Visible button is focused"
      );

      EventUtils.synthesizeKey("KEY_Escape");

      await helper.waitForOverlayClosed();

      await assertScreenshotsEvents(SCREENSHOTS_EVENTS);
    }
  );
});