diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /devtools/client/responsive/test/browser/browser_screenshot_button_warning.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/responsive/test/browser/browser_screenshot_button_warning.js')
-rw-r--r-- | devtools/client/responsive/test/browser/browser_screenshot_button_warning.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/devtools/client/responsive/test/browser/browser_screenshot_button_warning.js b/devtools/client/responsive/test/browser/browser_screenshot_button_warning.js new file mode 100644 index 0000000000..46d0371f98 --- /dev/null +++ b/devtools/client/responsive/test/browser/browser_screenshot_button_warning.js @@ -0,0 +1,59 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test that warning messages emitted when taking a screenshot are displayed in the UI. + +const TEST_URL = `http://example.net/document-builder.sjs?html= + <style> + body { + margin: 0; + height: 10001px; + } + </style>Hello world`; + +addRDMTask( + TEST_URL, + async function ({ ui, browser, manager }) { + const { toolWindow } = ui; + const { document } = toolWindow; + + info( + "Set a big viewport and high dpr so the screenshot dpr gets downsized" + ); + // The viewport can't be bigger than 9999×9999 + await setViewportSize(ui, manager, 9999, 9999); + const dpr = 3; + await selectDevicePixelRatio(ui, dpr); + await waitForDevicePixelRatio(ui, dpr); + + info("Click the screenshot button"); + const onScreenshotDownloaded = waitUntilScreenshot(); + const screenshotButton = document.getElementById("screenshot-button"); + screenshotButton.click(); + + const filePath = await onScreenshotDownloaded; + ok(filePath, "The screenshot was taken"); + + info( + "Check that a warning message was displayed to indicate the dpr was changed" + ); + + const box = gBrowser.getNotificationBox(browser); + await waitUntil(() => box.currentNotification); + + const notificationEl = box.currentNotification; + ok(notificationEl, "Notification should be visible"); + is( + notificationEl.messageText.textContent, + "The device pixel ratio was reduced to 1 as the resulting image was too large", + "The expected warning was displayed" + ); + + //Remove the downloaded screenshot file + await IOUtils.remove(filePath); + await resetDownloads(); + }, + { waitForDeviceList: true } +); |