gecko-dev/testing
Masayuki Nakano 8224e1138c Bug 1840519 - Make typing surrogate pair behavior switchable with prefs r=m_kato,smaug
A lone surrogate should not appear in `DOMString` at least when the attribute
values of events because of ill-formed UTF-16 string.

`TextEventDispatcher` does not handle surrogate pairs correctly. It should not
split surrogate pairs when it sets `KeyboardEvent.key` value for avoiding the
problem in some DOM API wrappers, e.g., Rust-running-as-wasm.

On the other hand, `.charCode` is an unsigned long attribute and web apps
may use `String.fromCharCode(event.charCode)` to convert the input to string,
and unfortunately, `fromCharCode` does not support Unicode character code
points over `0xFFFF`.  Therefore, we may need to keep dispatching 2 `keypress`
events per surrogate pair for the backward compatibility.

Therefore, this patch creates 2 prefs.  One is for using single-keypress
event model and double-keypress event model.  The other is for the latter,
whether `.key` value never has ill-formed UTF-16 or it's allowed.

If using the single-keypress event model --this is compatible with Safari and
Chrome in non-Windows platforms--, one `keypress` event is dispatched for
typing a surrogate pair.  Then, its `.charCode` is over `0xFFFF` which can
work with `String.fromCodePoint()` instead of `String.fromCharCode()` and
`.key` value is set to simply the surrogate pair (i.e., its length is 2).

If using the double-keypress event model and disallowing ill-formed UTF-16
--this is the new default behavior for both avoiding ill-formed UTF-16 string
creation and keeping backward compatibility with not-maintained web apps using
`String.fromCharCode`--, 2 `keypress` events are dispatched.  `.charCode` for
first one is the code of the high-surrogate, but `.key` is the surrogate pair.
Then, `.charCode` for second one is the low-surrogate and `.key` is empty
string.  In this mode, `TextEditor` and `HTMLEditor` ignores the second
`keypress`.  Therefore, web apps can cancel it only with the first `keypress`,
but it indicates the `keypress` introduces a surrogate pair with `.key`
attribute.

Otherwise, if using the double-keypress event model and allowing ill-formed
UTF-16 --this is the traditional our behavior and compatible with Chrome in
Windows--, 2 `keypress` events are dispatched with same `.charCode` values as
the previous mode, but first `.key` is the high-surrogate and the other's is
the low surrogate.  Therefore, web apps can cancel either one of them or
both of them.

Finally, this patch makes `TextEditor` and `HTMLEditor` handle text input
with `keypress` events properly.  Except in the last mode, `beforeinput` and
`input` events are fired once and their `data` values are the surrogate pair.
On the other hand, in the last mode, 2 sets of `beforeinput` and `input` are
fired and their `.data` values has only the surrogate so that ill-formed
UTF-16 values.

Note that this patch also fixes an issue on Windows.  Windows may send a high
surrogate and a low surrogate with 2 sets of `WM_KEYDOWN` and `WM_KEYUP` whose
virtual keycode is `VK_PACKET` (typically, this occurs with `SendInput` API).
For handling this correctly, this patch changes `NativeKey` class to make it
just store the high surrogate for the first `WM_KEYDOWN` and `WM_KEYUP` and use
it when it'll receive another `WM_KEYDOWN` for a low surrogate.

Differential Revision: https://phabricator.services.mozilla.com/D182142
2023-08-23 01:16:59 +00:00
..
awsy
condprofile
config
crashtest
docs
extensions
firefox-ui
geckodriver Bug 1682497 - [geckodriver] Added Page Range for Integers r=webdriver-reviewers,whimboo 2023-08-21 09:01:34 +00:00
gtest
jsshell
marionette Bug 1849227 - [marionette] Add "scroll" action for Wheel input source to Marionette client. r=webdriver-reviewers,jdescottes 2023-08-21 15:21:46 +00:00
mochitest Bug 1840519 - Make typing surrogate pair behavior switchable with prefs r=m_kato,smaug 2023-08-23 01:16:59 +00:00
modules
mozbase Bug 1849084 - fix moznetwork doc generation r=firefox-source-docs-reviewers,sylvestre DONTBUILD 2023-08-21 10:52:36 +00:00
mozharness Bug 1848262 - Set appdir from mozharness config when processing coverage files. r=jmaher 2023-08-17 14:44:06 +00:00
perfdocs Bug 1849157 - Reduce M2 test list to assist with limited capacity. r=perftest-reviewers,sparky 2023-08-17 19:41:24 +00:00
performance
profiles
raptor Bug 1846276 - Alert on the speculative connect performance test (browsertime-speculative) r=perftest-reviewers,afinder,sparky 2023-08-16 12:57:47 +00:00
runtimes
specialpowers
talos Bug 1849432 - [devtools] Stop adding main.js bundle to the index.html file r=devtools-reviewers,perftest-reviewers,jdescottes,AlexandruIonescu 2023-08-22 11:47:32 +00:00
tools
tps
web-platform Bug 1846853 - Clamp negative outline-offset per spec r=emilio 2023-08-23 00:59:43 +00:00
webcompat
webdriver Bug 1682497 - [geckodriver] Added Page Range for Integers r=webdriver-reviewers,whimboo 2023-08-21 09:01:34 +00:00
xpcshell
README.txt
addtest.py
cppunittest.ini
mach_commands.py
moz.build
parse_build_tests_ccov.py
remotecppunittests.py
runcppunittests.py
testinfo.py
testsuite-targets.mk

README.txt

Common testing tools for mozilla codebase projects, test suite definitions
for automated test runs, tests that don't fit anywhere else, and other fun
stuff