tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_markup_screenshot_node_warning.js (1232B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const TEST_URL = `data:text/html;charset=utf8,
      7  <div id="blue-node" style="width:30px;height:11000px;background:rgb(0, 0, 255)"></div>`;
      8 
      9 // Test taking a screenshot of a tall node displays a warning message in the notification box.
     10 add_task(async function () {
     11  const { inspector, toolbox } = await openInspectorForURL(encodeURI(TEST_URL));
     12 
     13  info("Select the blue node");
     14  await selectNode("#blue-node", inspector);
     15 
     16  info("Take a screenshot of the blue node and verify it looks as expected");
     17  const blueScreenshot = await takeNodeScreenshot(inspector);
     18  await assertSingleColorScreenshotImage(blueScreenshot, 30, 10000, {
     19    r: 0,
     20    g: 0,
     21    b: 255,
     22  });
     23 
     24  info(
     25    "Check that a warning message was displayed to indicate the screenshot was truncated"
     26  );
     27  const notificationBox = await waitFor(() =>
     28    toolbox.doc.querySelector(".notificationbox")
     29  );
     30 
     31  const message = notificationBox.querySelector(".notification").textContent;
     32  ok(
     33    message.startsWith("The image was cut off"),
     34    `The warning message is rendered as expected (${message})`
     35  );
     36 
     37  await toolbox.destroy();
     38 });