diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
commit | a90a5cba08fdf6c0ceb95101c275108a152a3aed (patch) | |
tree | 532507288f3defd7f4dcf1af49698bcb76034855 /browser/base/content/test/contextMenu/browser_contextmenu_cross_boundary_selection.js | |
parent | Adding debian version 126.0.1-1. (diff) | |
download | firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/base/content/test/contextMenu/browser_contextmenu_cross_boundary_selection.js')
-rw-r--r-- | browser/base/content/test/contextMenu/browser_contextmenu_cross_boundary_selection.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/browser/base/content/test/contextMenu/browser_contextmenu_cross_boundary_selection.js b/browser/base/content/test/contextMenu/browser_contextmenu_cross_boundary_selection.js new file mode 100644 index 0000000000..3137a1e136 --- /dev/null +++ b/browser/base/content/test/contextMenu/browser_contextmenu_cross_boundary_selection.js @@ -0,0 +1,73 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +const PAGE = ` + data:text/html, + <div>OuterText<div> + <div id="host"> + <template shadowrootmode="open"> + <span id="innerText">InnerText</span> + </template> + </div> + `; +/** + * Tests that right click on a cross boundary selection shows the context menu + */ +add_task(async function () { + await SpecialPowers.pushPrefEnv({ + set: [["dom.shadowdom.selection_across_boundary.enabled", true]], + }); + await BrowserTestUtils.withNewTab( + { + gBrowser, + url: PAGE, + }, + async function (browser) { + let contextMenu = document.getElementById("contentAreaContextMenu"); + let awaitPopupShown = BrowserTestUtils.waitForEvent( + contextMenu, + "popupshown" + ); + + let awaitPopupHidden = BrowserTestUtils.waitForEvent( + contextMenu, + "popuphidden" + ); + + await SpecialPowers.spawn(browser, [], () => { + let host = content.document.getElementById("host"); + content.getSelection().setBaseAndExtent( + content.document.body, + 0, + host.shadowRoot.getElementById("innerText").firstChild, + 3 // Only select the first three characters of the inner text + ); + }); + + await BrowserTestUtils.synthesizeMouseAtCenter( + "div", // Click on the div for OuterText + { + type: "contextmenu", + button: 2, + }, + browser + ); + + await awaitPopupShown; + + const allVisibleMenuItems = Array.from(contextMenu.children) + .filter(elem => { + return !elem.hidden; + }) + .map(elem => elem.id); + + ok( + allVisibleMenuItems.includes("context-copy"), + "copy button should exist" + ); + + contextMenu.hidePopup(); + await awaitPopupHidden; + } + ); +}); |