diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /devtools/client/inspector/markup/test/browser_markup_screenshot_node_about_page.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | devtools/client/inspector/markup/test/browser_markup_screenshot_node_about_page.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/devtools/client/inspector/markup/test/browser_markup_screenshot_node_about_page.js b/devtools/client/inspector/markup/test/browser_markup_screenshot_node_about_page.js new file mode 100644 index 0000000000..4d8f4ff6a6 --- /dev/null +++ b/devtools/client/inspector/markup/test/browser_markup_screenshot_node_about_page.js @@ -0,0 +1,46 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const TEST_URL = `about:preferences`; + +// Test that the "Screenshot Node" feature works in about:preferences (See Bug 1691349). + +function hexToCSS(hex) { + if (!hex) { + return null; + } + const rgba = InspectorUtils.colorToRGBA(hex); + info(`rgba: '${JSON.stringify(rgba)}'`); + // Drop off the 'a' component since the color will be opaque + return `rgb(${rgba.r}, ${rgba.g}, ${rgba.b})`; +} + +add_task(async function () { + const { inspector, toolbox } = await openInspectorForURL(TEST_URL); + + info("Select the main content node"); + await selectNode(".main-content", inspector); + + let inContentPageBackgroundColor = await getComputedStyleProperty( + ":root", + null, + "--in-content-page-background" + ); + inContentPageBackgroundColor = inContentPageBackgroundColor.trim(); + + info("Take a screenshot of the element and verify it looks as expected"); + const image = await takeNodeScreenshot(inspector); + // We only check that we have the right background color, since it would be difficult + // to assert the look of any other area in the page. + await checkImageColorAt({ + image, + x: 0, + y: 0, + expectedColor: hexToCSS(inContentPageBackgroundColor), + label: "The screenshot was taken", + }); + + await toolbox.destroy(); +}); |