mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1755438 - Make ContentCacheInParent::GetTextRect
check mSelection
before referring it r=m_kato
Unfortunately, the adding test cannot reproduce the crash, but I have no idea how to make `mSelection` being `Nothing` until next native event loop. Anyway, it's worthwhile to add new tests. This patch just avoids `ContentCacheInParent::GetTextRect` referring `mSelection` when there is no text rects and `mSelection` is `Nothing`. Differential Revision: https://phabricator.services.mozilla.com/D138876
This commit is contained in:
parent
0d5e6228bb
commit
e1ad4921b9
@ -880,6 +880,8 @@ bool ContentCacheInParent::HandleQueryContentEvent(
|
||||
("0x%p HandleQueryContentEvent(aEvent={ "
|
||||
"mMessage=eQueryEditorRect }, aWidget=0x%p)",
|
||||
this, aWidget));
|
||||
// XXX This query should fail if no editable elmenet has focus. Or,
|
||||
// perhaps, should return rect of the window instead.
|
||||
aEvent.EmplaceReply();
|
||||
aEvent.mReply->mFocusedWidget = aWidget;
|
||||
aEvent.mReply->mRect = mEditorRect;
|
||||
@ -968,8 +970,13 @@ bool ContentCacheInParent::GetTextRect(uint32_t aOffset,
|
||||
|
||||
if (mTextRectArray.isNothing() || !mTextRectArray->HasRects()) {
|
||||
// If there are no rects in mTextRectArray, we should refer the start of
|
||||
// the selection because IME must query a char rect around it if there is
|
||||
// no composition.
|
||||
// the selection if there is because IME must query a char rect around it if
|
||||
// there is no composition.
|
||||
if (mSelection.isNothing()) {
|
||||
// Unfortunately, there is no data about text rect...
|
||||
aTextRect.SetEmpty();
|
||||
return false;
|
||||
}
|
||||
aTextRect = mSelection->StartCharRect();
|
||||
return !aTextRect.IsEmpty();
|
||||
}
|
||||
|
@ -247,6 +247,56 @@ add_task(async function() {
|
||||
);
|
||||
}
|
||||
})();
|
||||
|
||||
/**
|
||||
* Test when no editable element has focus.
|
||||
*/
|
||||
notifications = [];
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
content.document.body.innerHTML = "abcdef";
|
||||
});
|
||||
|
||||
await waitForSendingIMENotificationsInContent();
|
||||
|
||||
(function() {
|
||||
checkNotifications(
|
||||
[
|
||||
{ type: "notify-focus", expected: false },
|
||||
{ type: "notify-blur", expected: true },
|
||||
],
|
||||
"removing editor should make ContentCacheInParent not have any data"
|
||||
);
|
||||
const text = EventUtils.synthesizeQueryTextContent(0, 1000);
|
||||
ok(
|
||||
!text?.succeeded,
|
||||
"query text content should fail because no editable element has focus"
|
||||
);
|
||||
const selection = EventUtils.synthesizeQuerySelectedText();
|
||||
ok(
|
||||
!selection?.succeeded,
|
||||
"query selected text should fail because no editable element has focus"
|
||||
);
|
||||
const caret = EventUtils.synthesizeQueryCaretRect(0);
|
||||
ok(
|
||||
!caret?.succeeded,
|
||||
"query caret rect should fail because no editable element has focus"
|
||||
);
|
||||
const textRect = EventUtils.synthesizeQueryTextRect(0, 5, false);
|
||||
ok(
|
||||
!textRect?.succeeded,
|
||||
"query text rect should fail because no editable element has focus"
|
||||
);
|
||||
const textRectArray = EventUtils.synthesizeQueryTextRectArray(0, 5);
|
||||
ok(
|
||||
!textRectArray?.succeeded,
|
||||
"query text rect array should fail because no editable element has focus"
|
||||
);
|
||||
const editorRect = EventUtils.synthesizeQueryEditorRect();
|
||||
todo(
|
||||
!editorRect?.succeeded,
|
||||
"query editor rect should fail because no editable element has focus"
|
||||
);
|
||||
})();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user