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 /browser/extensions/formautofill/test/browser/focus-leak | |
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 'browser/extensions/formautofill/test/browser/focus-leak')
4 files changed, 81 insertions, 0 deletions
diff --git a/browser/extensions/formautofill/test/browser/focus-leak/browser.ini b/browser/extensions/formautofill/test/browser/focus-leak/browser.ini new file mode 100644 index 0000000000..fc4aca4a35 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/focus-leak/browser.ini @@ -0,0 +1,12 @@ +[DEFAULT] +support-files = + doc_iframe_typecontent_input_focus.xhtml + doc_iframe_typecontent_input_focus_frame.html + ../head.js + +# This test is used to detect a leak. +# Keep it isolated in a dedicated test folder to make sure the leak is cleaned +# up as a sideeffect of another test. +[browser_iframe_typecontent_input_focus.js] +skip-if = + apple_silicon # Disabled due to bleedover with other tests when run in regular suites; passes in "failures" jobs diff --git a/browser/extensions/formautofill/test/browser/focus-leak/browser_iframe_typecontent_input_focus.js b/browser/extensions/formautofill/test/browser/focus-leak/browser_iframe_typecontent_input_focus.js new file mode 100644 index 0000000000..407c2b5163 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/focus-leak/browser_iframe_typecontent_input_focus.js @@ -0,0 +1,56 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const URL_ROOT = + "chrome://mochitests/content/browser/browser/extensions/formautofill/test/browser/focus-leak/"; + +const XUL_FRAME_URI = URL_ROOT + "doc_iframe_typecontent_input_focus.xhtml"; +const INNER_HTML_FRAME_URI = + URL_ROOT + "doc_iframe_typecontent_input_focus_frame.html"; + +/** + * Check that focusing an input in a frame with type=content embedded in a xul + * document does not leak. + */ +add_task(async function () { + const doc = gBrowser.ownerDocument; + const linkedBrowser = gBrowser.selectedTab.linkedBrowser; + const browserContainer = gBrowser.getBrowserContainer(linkedBrowser); + + info("Load the test page in a frame with type content"); + const frame = doc.createXULElement("iframe"); + frame.setAttribute("type", "content"); + browserContainer.appendChild(frame); + + info("Wait for the xul iframe to be loaded"); + const onXulFrameLoad = BrowserTestUtils.waitForEvent(frame, "load", true); + frame.setAttribute("src", XUL_FRAME_URI); + await onXulFrameLoad; + + const panelFrame = frame.contentDocument.querySelector("#html-iframe"); + + info("Wait for the html iframe to be loaded"); + const onFrameLoad = BrowserTestUtils.waitForEvent(panelFrame, "load", true); + panelFrame.setAttribute("src", INNER_HTML_FRAME_URI); + await onFrameLoad; + + info("Focus an input inside the iframe"); + const focusMeInput = panelFrame.contentDocument.querySelector(".focusme"); + const onFocus = BrowserTestUtils.waitForEvent(focusMeInput, "focus"); + await SimpleTest.promiseFocus(panelFrame); + focusMeInput.focus(); + await onFocus; + + // This assert is not really meaningful, the main purpose of the test is + // to check against leaks. + is( + focusMeInput, + panelFrame.contentDocument.activeElement, + "The .focusme input is the active element" + ); + + info("Remove the focused input"); + focusMeInput.remove(); +}); diff --git a/browser/extensions/formautofill/test/browser/focus-leak/doc_iframe_typecontent_input_focus.xhtml b/browser/extensions/formautofill/test/browser/focus-leak/doc_iframe_typecontent_input_focus.xhtml new file mode 100644 index 0000000000..ec3aaa2648 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/focus-leak/doc_iframe_typecontent_input_focus.xhtml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + xmlns:html="http://www.w3.org/1999/xhtml"> + <box> + <html:iframe id="html-iframe"/> + </box> +</window> diff --git a/browser/extensions/formautofill/test/browser/focus-leak/doc_iframe_typecontent_input_focus_frame.html b/browser/extensions/formautofill/test/browser/focus-leak/doc_iframe_typecontent_input_focus_frame.html new file mode 100644 index 0000000000..00853d8eec --- /dev/null +++ b/browser/extensions/formautofill/test/browser/focus-leak/doc_iframe_typecontent_input_focus_frame.html @@ -0,0 +1,6 @@ +<!DOCTYPE html> +<html> + <body> + <input type="text" name="test" class="focusme"> + </body> +</html> |