summaryrefslogtreecommitdiffstats
path: root/toolkit/modules/tests/browser/browser_FinderHighlighter2.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /toolkit/modules/tests/browser/browser_FinderHighlighter2.js
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/modules/tests/browser/browser_FinderHighlighter2.js')
-rw-r--r--toolkit/modules/tests/browser/browser_FinderHighlighter2.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/toolkit/modules/tests/browser/browser_FinderHighlighter2.js b/toolkit/modules/tests/browser/browser_FinderHighlighter2.js
new file mode 100644
index 0000000000..bb58a20e9e
--- /dev/null
+++ b/toolkit/modules/tests/browser/browser_FinderHighlighter2.js
@@ -0,0 +1,70 @@
+"use strict";
+
+const kPrefHighlightAll = "findbar.highlightAll";
+const kPrefModalHighlight = "findbar.modalHighlight";
+
+add_setup(async function() {
+ await SpecialPowers.pushPrefEnv({
+ set: [
+ [kPrefHighlightAll, true],
+ [kPrefModalHighlight, true],
+ ],
+ });
+});
+
+add_task(async function testIframeOffset() {
+ let url = kFixtureBaseURL + "file_FinderIframeTest.html";
+
+ await BrowserTestUtils.withNewTab(url, async function(browser) {
+ let findbar = gBrowser.getFindBar();
+ await promiseOpenFindbar(findbar);
+
+ let word = "frame";
+ let expectedResult = {
+ rectCount: 12,
+ insertCalls: [2, 4],
+ removeCalls: [0, 2],
+ };
+ let promise = promiseTestHighlighterOutput(
+ browser,
+ word,
+ expectedResult,
+ (maskNode, outlineNode, rects) => {
+ Assert.equal(
+ rects.length,
+ expectedResult.rectCount,
+ "Rect counts should match"
+ );
+ // Checks to guard against regressing this functionality:
+ let expectedOffsets = [
+ { x: 16, y: 60 },
+ { x: 68, y: 104 },
+ { x: 21, y: 215 },
+ { x: 78, y: 264 },
+ { x: 21, y: 375 },
+ { x: 78, y: 424 },
+ { x: 20, y: 534 },
+ { x: 93, y: 534 },
+ { x: 71, y: 577 },
+ { x: 145, y: 577 },
+ ];
+ for (let i = 1, l = rects.length - 1; i < l; ++i) {
+ let rect = rects[i];
+ let expected = expectedOffsets[i - 1];
+ Assert.equal(
+ Math.floor(rect.x),
+ expected.x,
+ "Horizontal offset should match for rect " + i
+ );
+ Assert.equal(
+ Math.floor(rect.y),
+ expected.y,
+ "Vertical offset should match for rect " + i
+ );
+ }
+ }
+ );
+ await promiseEnterStringIntoFindField(findbar, word);
+ await promise;
+ });
+});