tor-browser

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

commit 4d64217665ac0dde4db73418f9cf48e34acdb93a
parent 474e74032f21d6f7214fc080f32e07825be027ac
Author: Masayuki Nakano <masayuki@d-toybox.com>
Date:   Mon, 17 Nov 2025 14:41:03 +0000

Bug 2000479 - Make `ContentCacheInParent::HandleQueryContentEvent` not stop handling the query when the offset is relative and there is selection r=m_kato

This is just the typo of the condition, but this have made a lot of
queries failed when there is no IME selections.  This could be one of
the cause of bug 1824143.

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

Diffstat:
Mwidget/ContentCache.cpp | 2+-
Mwidget/tests/browser/browser_test_ContentCache.js | 33+++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/widget/ContentCache.cpp b/widget/ContentCache.cpp @@ -819,7 +819,7 @@ bool ContentCacheInParent::HandleQueryContentEvent( "Nothing", this)); return false; - } else if (NS_WARN_IF(mSelection->mHasRange)) { + } else if (NS_WARN_IF(!mSelection->mHasRange)) { MOZ_LOG(sContentCacheLog, LogLevel::Error, ("0x%p HandleQueryContentEvent(), FAILED due to there is no " "selection range, but the query requested with relative offset " diff --git a/widget/tests/browser/browser_test_ContentCache.js b/widget/tests/browser/browser_test_ContentCache.js @@ -243,6 +243,39 @@ add_task(async function () { })(); /** + * Test to query content with relative offsets + */ + notifications = []; + await SpecialPowers.spawn(browser, [], () => { + const editor = content.document.querySelector("div[contenteditable]"); + editor.innerHTML = "abcdef"; + content.getSelection().collapse(editor.firstChild, "abc".length); + }); + + await waitForSendingIMENotificationsInContent(); + + (function () { + for (let i = -3; i < 3; i++) { + const text = EventUtils.synthesizeQueryTextContent( + i, + 1, + /* isRelative= */ true + ); + ok( + text?.succeeded, + `synthesizeQueryTextContent(${i}, 1, true) should've succeeded` + ); + if (text?.succeeded) { + is( + text.text, + "abcdef".charAt(i + 3), + `synthesizeQueryTextContent(${i}, 1, true) should return the character at offset relative to the caret offset, 3` + ); + } + } + })(); + + /** * Test when no editable element has focus. */ notifications = [];