diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/tests/mochitest/bugs/test_no_find_showDialog.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | dom/tests/mochitest/bugs/test_no_find_showDialog.html | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/dom/tests/mochitest/bugs/test_no_find_showDialog.html b/dom/tests/mochitest/bugs/test_no_find_showDialog.html new file mode 100644 index 0000000000..5cfa36ebc0 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_no_find_showDialog.html @@ -0,0 +1,88 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1348409</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + <iframe src="about:blank"></iframe> + <script type="text/javascript"> + + async function checkForFindDialog() { + let chromeScript = SpecialPowers.loadChromeScript(_ => { + /* eslint-env mozilla/chrome-script */ + addMessageListener("test:check", () => { + let sawFind = false; + let findDialog = Services.wm.getMostRecentWindow("findInPage"); + if (findDialog) { + findDialog.close(); + sawFind = true; + } + + return sawFind; + }); + + }); + + let sawFind = await chromeScript.sendQuery("test:check"); + chromeScript.destroy(); + return sawFind; + } + + function ensureFinished(chromeScript) { + return new Promise(resolve => { + chromeScript.addMessageListener("test:disarm:done", (sawWindow) => { + resolve(sawWindow); + }); + chromeScript.sendAsyncMessage("test:disarm"); + }); + } + + function doWraparoundFind(findString, showDialog) { + let result = window.find(findString, + false /* aCaseSensitive */, + false /* aBackwards*/, + true /* aWrapAround */, + false /* aWholeWord */, + false /* aSearchInFrames */, + showDialog /* aShowInDialog */) + // Collapse selection so that we can do another find outside + // of the selection result. + document.getSelection().collapseToStart(); + return result; + } + + function startTest() { + add_task(async function() { + ok(doWraparoundFind("text to search for", false), + "Found the text in the document body."); + + // We're asking for the dialog now. We should just ignore that request. + ok(doWraparoundFind("fhqwhgads", true), + "Should return true and not show a dialog if the string exists in the page."); + ok(!doWraparoundFind(null, true), + "Should return false and not show a dialog if we pass a null string."); + ok(!doWraparoundFind("", true), + "Should return false and not show a dialog if we pass an empty string."); + + // Double check to ensure that the parent didn't open a find dialog + let sawWindow = await checkForFindDialog(); + ok(!sawWindow, "Should never have seen the dialog."); + }); + } + </script> +</head> +<body onload="startTest()"> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1348409">Mozilla Bug 1348409</a> + +<p> + Here's some text to search for: fhqwhgads! A hovercraft full of eels! +</p> + +<p id="display"></p> +<div id="content" style="display: none"> +</div> +<pre id="test"> +</pre> +</body> +</html> |