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/test/browser_inspector_highlighter-csstransform_02.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 'devtools/client/inspector/test/browser_inspector_highlighter-csstransform_02.js')
-rw-r--r-- | devtools/client/inspector/test/browser_inspector_highlighter-csstransform_02.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/devtools/client/inspector/test/browser_inspector_highlighter-csstransform_02.js b/devtools/client/inspector/test/browser_inspector_highlighter-csstransform_02.js new file mode 100644 index 0000000000..9903a40da0 --- /dev/null +++ b/devtools/client/inspector/test/browser_inspector_highlighter-csstransform_02.js @@ -0,0 +1,69 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +/* +Bug 1014547 - CSS transforms highlighter +Test that the highlighter elements created have the right size and coordinates. + +Note that instead of hard-coding values here, the assertions are made by +comparing with the result of getAdjustedQuads. + +There's a separate test for checking that getAdjustedQuads actually returns +sensible values +(devtools/client/shared/test/browser_layoutHelpers-getBoxQuads.js), +so the present test doesn't care about that, it just verifies that the css +transform highlighter applies those values correctly to the SVG elements +*/ + +const TEST_URL = URL_ROOT + "doc_inspector_highlighter_csstransform.html"; + +add_task(async function () { + const { inspector, highlighterTestFront } = await openInspectorForURL( + TEST_URL + ); + const front = inspector.inspectorFront; + + const highlighter = await front.getHighlighterByType( + "CssTransformHighlighter" + ); + + const nodeFront = await getNodeFront("#test-node", inspector); + + info("Displaying the transform highlighter on test node"); + await highlighter.show(nodeFront); + + const data = await getAllAdjustedQuadsForContentPageElement("#test-node"); + const [expected] = data.border; + + const points = await highlighterTestFront.getHighlighterNodeAttribute( + "css-transform-transformed", + "points", + highlighter + ); + const polygonPoints = points.split(" ").map(p => { + return { + x: +p.substring(0, p.indexOf(",")), + y: +p.substring(p.indexOf(",") + 1), + }; + }); + + for (let i = 1; i < 5; i++) { + is( + polygonPoints[i - 1].x, + expected["p" + i].x, + "p" + i + " x coordinate is correct" + ); + is( + polygonPoints[i - 1].y, + expected["p" + i].y, + "p" + i + " y coordinate is correct" + ); + } + + info("Hiding the transform highlighter"); + await highlighter.hide(); + await highlighter.finalize(); +}); |