Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI events containing lone surrogates #227

Open
annevk opened this issue Apr 2, 2019 · 11 comments
Open

UI events containing lone surrogates #227

annevk opened this issue Apr 2, 2019 · 11 comments

Comments

@annevk
Copy link
Member

annevk commented Apr 2, 2019

Per WebAssembly/interface-types#21 (comment) it's possible for input events to contain lone surrogates, at least on Windows. Perhaps we should require browsers to coalesce such events, if possible, to prevent none scalar values from being handed to JavaScript.

cc @Pauan @alexcrichton @lukewagner

@Pauan
Copy link

Pauan commented Apr 2, 2019

@annevk Thanks a lot for getting the ball rolling on this!

I created a reduced test case (JS only, no wasm): http://paaru.pbworks.com/w/file/fetch/132853233/input-bug.html

I was able to reproduce it with Windows 10 (64-bit) with the following browsers:

  • Mozilla Firefox Developer Edition 67.0b7 (64-bit)
  • Google Chrome 73.0.3683.86 (Official Build) (64-bit)

Interestingly, I could not reproduce it with these browsers (they do not have this bug):

  • Microsoft Edge 42.17134.1.0
  • Microsoft Internet Explorer 11.648.17134.0

@hsivonen
Copy link
Member

hsivonen commented Apr 3, 2019

https://hsivonen.com/test/moz/input.html is probably of interest when testing.

@hsivonen
Copy link
Member

hsivonen commented Apr 3, 2019

The Windows 10 onscreen keyboard generates a keydown/keyup pair for each surrogate in Firefox but a keydown/keyup pair per scalar value in Edge. (Note that multi-scalar value emoji generate multiple keydown/keyup pairs in Edge, i.e. every scalar value of an emoji is a keystroke.)

@hsivonen
Copy link
Member

hsivonen commented Apr 3, 2019

Hah. https://docs.microsoft.com/en-us/windows/desktop/inputdev/wm-unichar says this goes back to XP!

@hsivonen
Copy link
Member

hsivonen commented Apr 3, 2019

Correction: Edge doesn't issue keyup events for emoji.

@hsivonen
Copy link
Member

hsivonen commented Apr 3, 2019

Gecko bug

@hsivonen
Copy link
Member

hsivonen commented Apr 3, 2019

Chrome seems to expose the unpaired surrogate in input and beforeinput events as well as the observable value of the HTML input element but not as the key of keydown and keyup.

@hsivonen
Copy link
Member

hsivonen commented Apr 3, 2019

Chrome bug

@Pauan
Copy link

Pauan commented Apr 4, 2019

@hsivonen Thanks! I'm excited to see this fixed in browsers proper, so we won't need any more workarounds.

@hsivonen
Copy link
Member

hsivonen commented Apr 8, 2019

IE has been able to report a single keystroke (with a surrogate pair in the key string) per astral keystroke since at least IE9 on Windows 7. (The test case is incompatible with earlier IE.)

@hsivonen
Copy link
Member

hsivonen commented Apr 8, 2019

@travisleithead, are you aware of any reason why other browsers shouldn't adopt the Trident/EdgeHTML behavior here?

(Firefox on Linux appears to have been shy to report astral keystrokes as keystrokes and instead emits fake composition events for them. Based on the source comments, it looks this wasn't motivated by a concrete Web compat reason and was done just in case.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants