tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 150f1e1c4280365b38c159a53f70d8ed089a13bb
parent a78eaeedbe9911065d648280d9f87eb89a60eecf
Author: Jan-Niklas Jaeschke <jjaschke@mozilla.com>
Date:   Thu, 11 Dec 2025 09:52:52 +0000

Bug 2004502 - Text Fragments: Show "Copy Link to Highlight" context menu item if strip-on-share is disabled. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D275574

Diffstat:
Mbrowser/base/content/nsContextMenu.sys.mjs | 6++++--
Mbrowser/base/content/test/contextMenu/browser_copy_link_to_highlight.js | 25+++++++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/browser/base/content/nsContextMenu.sys.mjs b/browser/base/content/nsContextMenu.sys.mjs @@ -450,7 +450,6 @@ export class nsContextMenu { initTextFragmentItems() { const shouldShow = lazy.TEXT_FRAGMENTS_ENABLED && - lazy.STRIP_ON_SHARE_ENABLED && !( this.inPDFViewer || this.inFrame || @@ -459,7 +458,10 @@ export class nsContextMenu { ) && (this.hasTextFragments || this.isContentSelected); this.showItem("context-copy-link-to-highlight", shouldShow); - this.showItem("context-copy-clean-link-to-highlight", shouldShow); + this.showItem( + "context-copy-clean-link-to-highlight", + shouldShow && lazy.STRIP_ON_SHARE_ENABLED + ); // disables both options by default, while API tries to build a text fragment this.setItemAttr("context-copy-link-to-highlight", "disabled", true); diff --git a/browser/base/content/test/contextMenu/browser_copy_link_to_highlight.js b/browser/base/content/test/contextMenu/browser_copy_link_to_highlight.js @@ -304,6 +304,31 @@ add_task(async function removesAllHighlightsWithNonEmptyFragment() { ); }); +/* Bug 2004502: When strip_on_share is disabled, "Copy Link to Highlight" + * should still be visible but "Copy Clean Link to Highlight" should be hidden. + */ +add_task(async function copyLinkVisibleWhenStripOnShareDisabled() { + await SpecialPowers.pushPrefEnv({ + set: [["privacy.query_stripping.strip_on_share.enabled", false]], + }); + + await testCopyLinkToHighlight({ + testPage: loremIpsumTestPage(true), + runTests: async ({ copyLinkToHighlight, copyCleanLinkToHighlight }) => { + Assert.ok( + BrowserTestUtils.isVisible(copyLinkToHighlight), + "Copy Link to Highlight Menu item is visible when strip_on_share is disabled" + ); + Assert.ok( + !BrowserTestUtils.isVisible(copyCleanLinkToHighlight), + "Copy Clean Link to Highlight Menu item is not visible when strip_on_share is disabled" + ); + }, + }); + + await SpecialPowers.popPrefEnv(); +}); + /** * Creates a document which contains a contenteditable element with some content. * Additionally selects the editable content.