summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/markup/test/browser_markup_screenshot_node_warning.js
blob: 2ae713455a84f0851ebb7db4ec96d8703576e5e2 (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
/* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const TEST_URL = `data:text/html;charset=utf8,
  <div id="blue-node" style="width:30px;height:11000px;background:rgb(0, 0, 255)"></div>`;

// Test taking a screenshot of a tall node displays a warning message in the notification box.
add_task(async function () {
  const { inspector, toolbox } = await openInspectorForURL(encodeURI(TEST_URL));

  info("Select the blue node");
  await selectNode("#blue-node", inspector);

  info("Take a screenshot of the blue node and verify it looks as expected");
  const blueScreenshot = await takeNodeScreenshot(inspector);
  await assertSingleColorScreenshotImage(blueScreenshot, 30, 10000, {
    r: 0,
    g: 0,
    b: 255,
  });

  info(
    "Check that a warning message was displayed to indicate the screenshot was truncated"
  );
  const notificationBox = await waitFor(() =>
    toolbox.doc.querySelector(".notificationbox")
  );

  const message = notificationBox.querySelector(".notification").textContent;
  ok(
    message.startsWith("The image was cut off"),
    `The warning message is rendered as expected (${message})`
  );

  await toolbox.destroy();
});