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

"use strict";

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

      helper.triggerUIFromToolbar();
      await helper.waitForOverlay();

      await helper.clickTestPageElement();

      let rect = await helper.getTestPageElementRect();
      let region = await helper.getSelectionRegionDimensions();

      is(
        region.left,
        rect.left,
        "The selected region left is the same as the element left"
      );
      is(
        region.right,
        rect.right,
        "The selected region right is the same as the element right"
      );
      is(
        region.top,
        rect.top,
        "The selected region top is the same as the element top"
      );
      is(
        region.bottom,
        rect.bottom,
        "The selected region bottom is the same as the element bottom"
      );

      mouse.click(10, 10);
      await helper.waitForStateChange(["crosshairs"]);

      let hoverElementRegionValid = await helper.isHoverElementRegionValid();

      ok(!hoverElementRegionValid, "Hover element rect is null");

      mouse.click(10, 10);
      await helper.waitForStateChange(["crosshairs"]);
    }
  );
});