Closed Bug 1715105 Opened 3 years ago Closed 3 years ago

Incorrect KeyboardEvent are created when the Cyrillic keyboard is used with `privacy.resistFingerprinting = true`

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

defect

Tracking

()

RESOLVED INVALID

People

(Reporter: kozackunisoft, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0

Steps to reproduce:

  1. Create keydown event listener:
    window.addEventListener('keydown', console.log)
  2. Press some key, for example L. In browser console you should saw log with new event.
  3. Change the keyboard layout. In my case it is the Ukrainian language (Cyrillic).
  4. Press same key.

Reproduction demo:
https://codepen.io/cawa-93/pen/YzZvajb?editors=1010

Actual results:

In first case (on English/Latin) I got KeyboardEvent:

{
  code: "KeyL",
  key: "L",
  keyCode: 76,
}

But in second case (on Ukrainian/Cyrillic) I got KeyboardEvent:

{
  code: "",
  key: "Д",
  keyCode: 0,
}

Expected results:

In second case must creating similar KeyboardEvent with same, language-insensitive code.

If you open my Reproduction demo and press "W" you should see alert. In Firefox it works only for Latin keyboard. In other browser (In my case it's Edge) it work in latin and cyrillic keyboards.

The Bugbug bot thinks this bug should belong to the 'Core::DOM: UI Events & Focus Handling' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → DOM: UI Events & Focus Handling
Product: Firefox → Core

Yes, the expected behavior described above is according to the spec.

With Nightly and Firefox 89, this works as expected on Ubuntu 20.04.

I Agree. In nightly (91.0a1 (2021-06-07)) is work as expected. I faced the problem in Developer edition 90.0b4.

Unfortunately I was not able to reproduce this issue on Windows 10 Insider Preview using Developer Edition 90.0b4 (en-US and uk).

I installed Ukrainian (Enhanced) keyboard layout on my PC (I also tried with Azerbaijani (Cyrillic)), I then visited the demo page from comment 0 https://codepen.io/cawa-93/pen/YzZvajb?editors=1010.
If I hit L or Д I still got the same value for code and that is KeyL, Also hitting W or Ц brings up the modal alert.

Looks like a problem leads some browser settings. Previously, I reported that for me in the Nightly 91.0a1 all works as expected. However, if I enable sync in the Nightly with my firefox accounting - then again I have this problem.

Even if I turn off the synchronization, or exit my account - the problem remains.

If I go to https://support.mozilla.org/en-us/kb/refresh-firefox-Reset-ADD-ons-and-Settings and Restore browser - all works again as expected until I have been on synchronization.

What additional information can I provide?

After experimenting for a while, I found that this problem occurs (in 91.0a and 90.0b4) if the privacy.resistFingerprinting parameter is true.
Can somebody confirm that?

(In reply to Alex from comment #7)

After experimenting for a while, I found that this problem occurs (in 91.0a and 90.0b4) if the privacy.resistFingerprinting parameter is true.
Can somebody confirm that?

I can confirm that having privacy.resistFingerprinting set to true will indeed cause the issue reported in comment 0.

I used mozregression in order to see what might have caused this and ended up with the following pushlog (it's a very old one): https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=e4107773cffb1baefd5446666fce22c4d6eb0517&tochange=b2cb61e83ac50115a28f04aaa8a32d4db90aad23

Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Unspecified → All
Hardware: Unspecified → All
Version: 78 Branch → Trunk

Alex, Bogdan: thanks for your efforts.

This seems intended; from https://support.mozilla.org/en-US/kb/firefox-protection-against-fingerprinting:

"Your keyboard layout and language is disguised ".

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → INVALID
Summary: Incorrect KeyboardEvent are created when the Cyrillic keyboard is used → Incorrect KeyboardEvent are created when the Cyrillic keyboard is used with `privacy.resistFingerprinting = true`

(In reply to Mirko Brodesser (:mbrodesser) from comment #9)

Alex, Bogdan: thanks for your efforts.

This seems intended; from https://support.mozilla.org/en-US/kb/firefox-protection-against-fingerprinting:

"Your keyboard layout and language is disguised ".

But the current behavior is the exact opposite:

"Your keyboard layout and language is disguised ".

The client can still read the key (which is dependent on the installed language and keyboard layout).

Instead of masking, it just destroys keyboard shortcut support on most websites (such as YouTube). For this to work as intended instead of there events:

{
  code: "",
  key: "Д",
  keyCode: 0,
}

it should create events the following:

{
  code: "KeyL",
  key: "",
  keyCode: 76,
}

or

{
  code: "KeyL",
  key: "L",
  keyCode: 76,
}

... for ANY keyboard layout and language.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: