Bug 1776339, if the iframe where the last find in page was performed is no longer visible, use the root page instead, r=aminomancer

Differential Revision: https://phabricator.services.mozilla.com/D168441
This commit is contained in:
Neil Deakin 2023-05-31 19:46:50 +00:00
Родитель 18f5e1220a
Коммит 3b7d2a7151
3 изменённых файлов: 68 добавлений и 1 удалений

Просмотреть файл

@ -98,6 +98,7 @@ skip-if = (os == "win" && processor == "aarch64") # aarch64 due to 1536573
[browser_findbar.js]
skip-if = os == "linux" && bits == 64 && os_version == "18.04" # Bug 1614739
[browser_findbar_disabled_manual.js]
[browser_findbar_hiddenframes.js]
[browser_findbar_marks.js]
[browser_isSynthetic.js]
[browser_keyevents_during_autoscrolling.js]

Просмотреть файл

@ -0,0 +1,59 @@
const TEST_PAGE = "https://example.com/document-builder.sjs?html=";
let content =
"<html><body><iframe id='a' src='data:text/html,This is the first page'></iframe><iframe id='b' src='data:text/html,That is another page'></iframe></body></html>";
async function doAndCheckFind(bc, text) {
await promiseFindFinished(gBrowser, text, false);
let foundText = await SpecialPowers.spawn(bc, [], () => {
return content.getSelection().toString();
});
is(foundText, text, text + " is found");
}
// This test verifies that find continues to work when a find begins and the frame
// is hidden during the next find step.
add_task(async function test_frame() {
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
TEST_PAGE + content
);
let browser = gBrowser.getBrowserForTab(tab);
let findbar = await gBrowser.getFindBar();
await doAndCheckFind(browser.browsingContext.children[0], "This");
await SpecialPowers.spawn(browser, [], () => {
content.document.getElementById("a").style.display = "none";
content.document.getElementById("a").getBoundingClientRect(); // flush
});
await doAndCheckFind(browser.browsingContext.children[1], "another");
await SpecialPowers.spawn(browser, [], () => {
content.document.getElementById("a").style.display = "";
content.document.getElementById("a").getBoundingClientRect();
});
await doAndCheckFind(browser.browsingContext.children[0], "first");
await SpecialPowers.spawn(browser, [], () => {
content.document.getElementById("a").style.visibility = "hidden";
content.document.getElementById("a").getBoundingClientRect();
});
await doAndCheckFind(browser.browsingContext.children[1], "That");
await SpecialPowers.spawn(browser, [], () => {
content.document.getElementById("a").style.visibility = "";
content.document.getElementById("a").getBoundingClientRect();
});
await doAndCheckFind(browser.browsingContext.children[0], "This");
await closeFindbarAndWait(findbar);
gBrowser.removeTab(tab);
});

Просмотреть файл

@ -103,7 +103,10 @@ FinderParent.prototype = {
// browsing context where the result was found. However,
// ensure that this browsing context is still valid, and
// if not, return null.
if (aList.includes(this._lastFoundBrowsingContext)) {
if (
aList.includes(this._lastFoundBrowsingContext) &&
!this._lastFoundBrowsingContext.isUnderHiddenEmbedderElement
) {
return this._lastFoundBrowsingContext;
}
@ -159,6 +162,10 @@ FinderParent.prototype = {
},
gatherBrowsingContexts(aBrowsingContext) {
if (aBrowsingContext.isUnderHiddenEmbedderElement) {
return [];
}
let list = [aBrowsingContext];
for (let child of aBrowsingContext.children) {