Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Errors
- This test failed 130 times in the preceding 30 days. quicksearch this test
- Manifest: devtools/client/responsive/test/browser/browser.toml
/* Any copyright is dedicated to the Public Domain.
"use strict";
// Test global screenshot button and screenshot size with and without a viewport meta tag.
const TEST_URL = "data:text/html;charset=utf-8,";
const TEST_URL2 =
TEST_URL + "<meta name='viewport' content='width=device-width' />";
for (const URL of [TEST_URL, TEST_URL2]) {
addRDMTask(URL, async function ({ ui }) {
info(
`Test global screenshot button and screenshot size ${URL.includes("viewport") ? "with" : "without"} a viewport meta tag`
);
const { toolWindow } = ui;
const { document } = toolWindow;
const whenScreenshotSucceeded = waitUntilDownload();
info("Click the screenshot button");
const screenshotButton = document.getElementById("screenshot-button");
screenshotButton.click();
const filePath = await whenScreenshotSucceeded;
const image = new Image();
// the same filename, so we need to add a cache buster.
image.src = PathUtils.toFileURI(filePath) + `?nocache=${Date.now()}`;
await once(image, "load");
const { width, height, ratio } = await spawnViewportTask(ui, {}, () => {
return {
width: content.innerWidth,
height: content.innerHeight,
ratio: content.devicePixelRatio,
};
});
is(image.width, width * ratio, "screenshot has the expected width");
is(image.height, height * ratio, "screenshot has the expected height");
await IOUtils.remove(filePath);
await resetDownloads();
});
}