Files
sousa-gecko/widget/tests/browser/browser_test_ime_request_commit_sync.js
Masayuki Nakano 02c332d879 Bug 2052939 - Improve the async commit composition which is in a content process r=m_kato
When `TextComposition` in a content process requests to commit
composition, the request is sent to the parent process synchronously.
Then, if IME handles the request synchronously,
`PuppetWidget::RequestIMEToCommitComposition` dispatches a
`eCompositionCommit` event synchronously. However, if IME handles it
asynchronously, `RequestIMEToCommitComposition` does nothing and
`TextComposition::RequestToCommit` dispatches `eCompositionCommit` or
`eCompositionCommitAsIs` before receiving next event (in the most
cases). However, the puppet widget won't receive the delayed commit
event in this case because `TextComposition::DispatchCompositionEvent`
in the parent process does not send the delayed commit event. Therefore,
`PuppetWidget::DispatchEvent` cannot notify `TextEventDispatcher` of
the commit event. Therefore, `TextEventDispatcher` will have wrong
composition state.

So, fixing this issue, we need to make
`TextComposition::DispatchCompositionEvent` in the parent process should
send the commit event as usual. To avoid the `ContentCacheInParent`
to misunderstand the native IME's composition state,
`TextComposition::RequestToCommit` should not dispatch
`eCompositionCommit` nor `eCompositionCommitAsIs` because the event
causes `ContentCacheInParent` thinks the composition is actually
committed in IME.

Differential Revision: https://phabricator.services.mozilla.com/D319302
2026-08-20 05:13:49 +00:00

29 lines
846 B
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* import-globals-from ../file_ime_state_test_helper.js */
/* import-globals-from ../file_test_ime_request_commit.js */
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/widget/tests/browser/file_ime_state_test_helper.js",
this
);
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/widget/tests/browser/file_test_ime_request_commit.js",
this
);
add_task(async function () {
await BrowserTestUtils.withNewTab("about:blank", async function (browser) {
const tipWrapper = new TIPWrapper(window);
Assert.ok(
tipWrapper.isAvailable(),
"TextInputProcessor should've been initialized"
);
await runTest(tipWrapper, browser, false);
});
});