Skip to content

Commit

Permalink
Bug 1885410 - Update inputConnection_multiple_commitText_into_batchEd…
Browse files Browse the repository at this point in the history
…it to fix failure. r=geckoview-reviewers,owlish

This test was added by bug 1837931. But according to bug 1885410, it is rarely failure.

So I re-write this to use keyboard event to wait for completion.

Differential Revision: https://phabricator.services.mozilla.com/D209989
  • Loading branch information
makotokato committed May 14, 2024
1 parent b879d6f commit 5b37f1d
Showing 1 changed file with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1296,14 +1296,40 @@ class TextInputDelegateTest : BaseSessionTest() {
setupContent("")
val ic = mainSession.textInput.onCreateInputConnection(EditorInfo())!!

val promise = mainSession.evaluatePromiseJS(
when (id) {
"#designmode" -> """
new Promise(
r => document.querySelector('$id').contentDocument.addEventListener('keyup', function handler(e) {
if (e.key == "c") {
r();
document.querySelector('$id').contentDocument.removeEventListener('keyup', handler);
}
}))
""".trimIndent()

else -> """
new Promise(
r => document.querySelector('$id').addEventListener('keyup', function handler(e) {
if (e.key == "c") {
r();
document.querySelector('$id').removeEventListener('keyup', handler);
}
}))
""".trimIndent()
},
)

// Emulate GBoard's InputConnection API calls
ic.beginBatchEdit()
ic.commitText("( ", 1)
ic.commitText(")", -1)
ic.commitText("ab", 1)
ic.commitText("c", -1)
ic.endBatchEdit()

promise.value
processChildEvents()

assertText("commit ()", ic, "( )")
assertText("committed text is \"abc\"", ic, "abc")
}

// Bug 1593683 - Cursor is jumping when using the arrow keys in input field on GBoard
Expand Down

0 comments on commit 5b37f1d

Please sign in to comment.