tor-browser

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

browser_screenshot_button.js (1090B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test global screenshot button
      7 
      8 const TEST_URL = "data:text/html;charset=utf-8,";
      9 
     10 addRDMTask(TEST_URL, async function ({ ui }) {
     11  const { toolWindow } = ui;
     12  const { store, document } = toolWindow;
     13 
     14  info("Click the screenshot button");
     15  const screenshotButton = document.getElementById("screenshot-button");
     16  screenshotButton.click();
     17 
     18  const whenScreenshotSucceeded = waitUntilDownload();
     19 
     20  const filePath = await whenScreenshotSucceeded;
     21  const image = new Image();
     22  image.src = PathUtils.toFileURI(filePath);
     23 
     24  await once(image, "load");
     25 
     26  // We have only one viewport at the moment
     27  const viewport = store.getState().viewports[0];
     28  const ratio = window.devicePixelRatio;
     29 
     30  is(
     31    image.width,
     32    viewport.width * ratio,
     33    "screenshot width has the expected width"
     34  );
     35 
     36  is(
     37    image.height,
     38    viewport.height * ratio,
     39    "screenshot width has the expected height"
     40  );
     41 
     42  await IOUtils.remove(filePath);
     43  await resetDownloads();
     44 });