Skip to content

Let input JS event be dispatched by keydown instead of keypress#37078

Merged
xiaochengh merged 1 commit intoservo:mainfrom
yezhizhen:fix-input
May 28, 2025
Merged

Let input JS event be dispatched by keydown instead of keypress#37078
xiaochengh merged 1 commit intoservo:mainfrom
yezhizhen:fix-input

Conversation

@yezhizhen
Copy link
Copy Markdown
Member

@yezhizhen yezhizhen commented May 22, 2025

  1. Let input JS event be dispatched by keydown instead of keypress, according to spec
  2. Fire input event for Backspace and Delete. But do so only when something is actually deleted

Testing: Manually tested and compared with other browsers.
Fixes: #37051
cc @xiaochengh

@xiaochengh
Copy link
Copy Markdown
Contributor

There should be some test cases using testdriver.js. Have you checked locally?

And I still don't feel so good to merge a patch without CI coverage... What's the priority of this issue?

@yezhizhen
Copy link
Copy Markdown
Member Author

yezhizhen commented May 22, 2025

There should be some test cases using testdriver.js. Have you checked locally?

Can't test this locally because after #36932, all the perform actions and release actions test would TIMEOUT now. Need to fix that first.😥Otherwise, I might need to rebase before #36932 and test..

This one can hold.

@mrobinson mrobinson added the T-linux-wpt Do a try run of the WPT label May 23, 2025
@github-actions github-actions bot removed the T-linux-wpt Do a try run of the WPT label May 23, 2025
@github-actions
Copy link
Copy Markdown

🔨 Triggering try run (#15203430038) for Linux (WPT)

@yezhizhen
Copy link
Copy Markdown
Member Author

https://github.com/yezhizhen/servo/actions/runs/15178815879

Actually I ran the action yesterday.. Everything is passing because this requires testdriver to check.

@mrobinson
Copy link
Copy Markdown
Member

Does #37081 fix the test driver issue?

@yezhizhen
Copy link
Copy Markdown
Member Author

Does #37081 fix the test driver issue?

We still won't be able to run testdriver after #37081. Because synchronization PR #36932 would make all related test "TIMEOUT" due to greatly increased chance of failing hit-test.
Have to either rebase before #36932 and test locally, or wait for hit-test to be fixed..

@github-actions
Copy link
Copy Markdown

Test results for linux-wpt from try job (#15203430038):

Flaky unexpected result (18)
  • ERROR [expected OK] /cookies/partitioned-cookies/partitioned-cookies-a-b-a-embed.tentative.https.html
  • OK /css/css-fonts/variations/at-font-face-font-matching.html (#20684)
    • FAIL [expected PASS] subtest: Matching font-style: 'oblique -10deg' should prefer 'oblique -20deg -15deg' over 'oblique -60deg -30deg'

      assert_equals: Unexpected font on test element expected 487 but got 532
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/005.html (#27062)
    • PASS [expected FAIL] subtest: Link with onclick navigation and href navigation
  • OK /html/browsers/browsing-the-web/navigating-across-documents/empty-iframe-load-event.html (#29066)
    • FAIL [expected PASS] subtest: Check execution order from nested timeout

      assert_equals: Expected nested setTimeout to run second expected true but got false
      

    • FAIL [expected PASS] subtest: Check execution order on load handler

      assert_equals: Expected onload to run first expected false but got true
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/iframe-src-aboutblank-navigate-immediately.html (#29048)
    • FAIL [expected PASS] subtest: Navigating to a different document with form submission

      assert_equals: expected "http://web-platform.test:8000/common/blank.html?1=" but got "about:blank"
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/refresh/same-document-refresh.html (#34597)
    • FAIL [expected PASS] subtest: Same-Document Referrer from Refresh

      assert_equals: original page loads expected "http://web-platform.test:8000/html/browsers/browsing-the-web/navigating-across-documents/refresh/resources/refresh-with-section.sub.html?url=%23section" but got "http://web-platform.test:8000/html/browsers/browsing-the-web/navigating-across-documents/refresh/resources/refresh-with-section.sub.html?url=%23section#section"
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/a-click.html (#28697)
    • FAIL [expected PASS] subtest: aElement.click() before the load event must NOT replace

      assert_equals: history.length must change after waiting for the load expected 3 but got 2
      

  • PASS [expected FAIL] /html/canvas/element/manual/drawing-text-to-the-canvas/canvas.2d.disconnected-font-size-math.html (#30063)
  • CRASH [expected TIMEOUT] /html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage.https.html
  • TIMEOUT [expected OK] /html/interaction/focus/the-autofocus-attribute/update-the-rendering.html (#24145)
    • TIMEOUT [expected FAIL] subtest: "Flush autofocus candidates" should be happen before a scroll event and animation frame callbacks

      Test timed out
      

  • OK /html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-reload-location-reload.html (#32595)
    • FAIL [expected PASS] subtest: Reloading iframe loading='lazy' before it is loaded: location.reload

      uncaught exception: Error: assert_equals: expected "http://web-platform.test:8000/html/semantics/embedded-content/the-iframe-element/support/blank.htm?src" but got "about:blank"
      

  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.html (#22647)
    • FAIL [expected TIMEOUT] subtest: Check that popups from a sandboxed iframe escape the sandbox if allow-popups-to-escape-sandbox is used

      assert_equals: It came from a sandboxed iframe expected "null" but got "http://web-platform.test:8000"
      

  • CRASH [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.html (#22154)
  • TIMEOUT [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-3.html (#24066)
    • NOTRUN [expected FAIL] subtest: Check that popups from a sandboxed iframe do not escape the sandbox
  • OK /html/semantics/forms/historical.html (#28568)
    • PASS [expected FAIL] subtest: <input name=isindex> should not be supported
  • OK /resize-observer/change-layout-in-error.html (#32629)
    • FAIL [expected PASS] subtest: Changing layout in window error handler should not result in lifecyle loop when resize observer loop limit is reached.

      assert_equals: expected 1 but got 2
      

  • TIMEOUT [expected OK] /resource-timing/nested-context-navigations-iframe.html (#24311)
    • TIMEOUT [expected PASS] subtest: Test that cross-site iframe navigations are not observable by the parent, even after history navigations by the parent

      Test timed out
      

    • NOTRUN [expected PASS] subtest: Test that iframe navigations are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that crossorigin iframe navigations are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that cross-site iframe navigations are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that iframe refreshes are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that crossorigin iframe refreshes are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that cross-site iframe refreshes are not observable by the parent
  • ERROR /service-workers/idlharness.https.any.html (#36250)
    • PASS [expected TIMEOUT] subtest: ServiceWorkerContainer interface: operation register((TrustedScriptURL or USVString), optional RegistrationOptions)
    • PASS [expected TIMEOUT] subtest: NavigationPreloadManager interface: operation enable()
    • PASS [expected TIMEOUT] subtest: NavigationPreloadManager interface: operation disable()
    • PASS [expected TIMEOUT] subtest: NavigationPreloadManager interface: operation setHeaderValue(ByteString)
    • PASS [expected TIMEOUT] subtest: NavigationPreloadManager interface: operation getState()
Stable unexpected results that are known to be intermittent (17)
  • TIMEOUT [expected OK] /_mozilla/mozilla/window_resizeTo.html (#36741)
    • TIMEOUT [expected PASS] subtest: Popup onresize event fires after resizeTo

      Test timed out
      

  • OK /_webgl/conformance/textures/misc/texture-upload-size.html (#21770)
    • FAIL [expected PASS] subtest: WebGL test #44

      assert_true: could not create image (SVG) expected true got false
      

  • PASS [expected FAIL] /css/css-overflow/overflow-video.html (#34720)
  • OK /fetch/metadata/generated/css-font-face.https.sub.tentative.html (#32732)
    • PASS [expected FAIL] subtest: sec-fetch-site - Same-Site -> Same-Site
    • PASS [expected FAIL] subtest: sec-fetch-dest
    • PASS [expected FAIL] subtest: sec-fetch-user
  • OK [expected ERROR] /fetch/nosniff/importscripts.html (#27144)
    • PASS [expected TIMEOUT] subtest: Test importScripts()
  • OK /html/browsers/browsing-the-web/navigating-across-documents/009.html (#24456)
    • FAIL [expected PASS] subtest: Link with onclick form submit to javascript url with document.write and href navigation

      assert_array_equals: expected property 1 to be "href" but got "click" (expected array ["write", "href"] got ["write", "click"])
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/iframe-nosrc.html (#34819)
    • PASS [expected FAIL] subtest: link click
  • OK /html/browsers/history/the-history-interface/traverse_the_history_3.html (#21383)
    • FAIL [expected PASS] subtest: Multiple history traversals, last would be aborted

      assert_array_equals: Pages opened during history navigation lengths differ, expected array [6, 3] length 2, got [6, 3, 3] length 3
      

  • OK /html/browsers/history/the-history-interface/traverse_the_history_4.html (#21383)
    • FAIL [expected PASS] subtest: Multiple history traversals, last would be aborted

      assert_array_equals: Pages opened during history navigation expected property 1 to be 5 but got 3 (expected array [6, 5] got [6, 3])
      

  • OK [expected TIMEOUT] /html/canvas/element/manual/imagebitmap/createImageBitmap-origin.sub.html (#31931)
  • ERROR [expected OK] /html/canvas/element/manual/imagebitmap/createImageBitmap-serializable.html (#34120)
  • TIMEOUT /html/interaction/focus/the-autofocus-attribute/supported-elements.html (#24145)
    • TIMEOUT [expected FAIL] subtest: Element with tabindex should support autofocus

      Test timed out
      

    • NOTRUN [expected PASS] subtest: Non-HTMLElement should not support autofocus
  • OK [expected CRASH] /html/semantics/embedded-content/media-elements/media_fragment_seek.html (#24114)
  • TIMEOUT /html/semantics/embedded-content/the-canvas-element/security.pattern.fillStyle.sub.html (#36989)
    • TIMEOUT [expected FAIL] subtest: redirected to cross-origin HTMLVideoElement: Setting fillStyle to an origin-unclean pattern makes the canvas origin-unclean

      Test timed out
      

    • NOTRUN [expected TIMEOUT] subtest: redirected to same-origin HTMLVideoElement: Setting fillStyle to an origin-unclean pattern makes the canvas origin-unclean
  • OK /html/semantics/forms/form-submission-0/form-submit-iframe-then-location-navigate.html (#29634)
    • PASS [expected FAIL] subtest: Verifies that location navigations take precedence when following form submissions.
  • OK /navigation-timing/test-navigation-type-reload.html (#33334)
    • FAIL [expected PASS] subtest: Reload domContentLoadedEventEnd > Original domContentLoadedEventEnd

      assert_true: Reload domContentLoadedEventEnd > Original domContentLoadedEventEnd expected true got false
      

    • PASS [expected FAIL] subtest: Reload domContentLoadedEventStart > Original domContentLoadedEventStart
    • PASS [expected FAIL] subtest: Reload domInteractive > Original domInteractive
    • PASS [expected FAIL] subtest: Reload fetchStart > Original fetchStart
  • OK /webaudio/the-audio-api/the-audiobuffersourcenode-interface/sub-sample-buffer-stitching.html (#22849)
    • FAIL [expected PASS] subtest: X Stitched sine-wave buffers at sample rate 43800 does not equal [0,0.06264832615852356,0.12505052983760834,0.18696144223213196,0.24813786149024963,0.308339387178421,0.36732959747314453,0.4248766601085663,0.480754554271698,0.5347436666488647,0.5866320133209229,0.6362156271934509,0.6832997798919678,0.7276994585990906,0.7692402601242065,0.8077589869499207...] with an element-wise tolerance of {"absoluteThreshold":0.0038986,"relativeThreshold":0}. Index Actual Expected AbsError RelError Test threshold [14650] 9.6808637088094640e-20 8.6956524848937988e-1 8.6956524848937988e-1 1.0000000000000000e+0 3.8985999999999999e-3 [14651] 3.0547976493835449e-1 8.9879405498504639e-1 5.9331429004669189e-1 6.6012262403823208e-1 3.8985999999999999e-3 Max AbsError of 8.6956524848937988e-1 at index of 14650. Max RelError of 1.0000000000000000e+0 at index of 14650.

      assert_true: expected true got false
      

@github-actions
Copy link
Copy Markdown

✨ Try run (#15203430038) succeeded.

@longvatrong111
Copy link
Copy Markdown
Contributor

Does #37081 fix the test driver issue?

We still won't be able to run testdriver after #37081. Because synchronization PR #36932 would make all related test "TIMEOUT" due to greatly increased chance of failing hit-test. Have to either rebase before #36932 and test locally, or wait for hit-test to be fixed..

Correct: PR #36932 add a blocking wait in dispatch_actions even if the action requires no response. I added a PR to filter it: #37095
About hit test result, I don't think it relates. Hit test failings for MouseMove happens in main branch and for non-webdriver events. Now it is more visible because if hit test fail, webdriver still wait for the reponse. It is intentional.

@yezhizhen
Copy link
Copy Markdown
Member Author

yezhizhen commented May 28, 2025

And I still don't feel so good to merge a patch without CI coverage... What's the priority of this issue?

This PR will make everything easier for embedder & related event fix, according to @stevennovaryo

I think we should still review and merge this. Since there are multiple input related fix going on now, and this one is kinda fundamental. @xiaochengh

Copy link
Copy Markdown
Contributor

@xiaochengh xiaochengh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but please remove unused code

@xiaochengh
Copy link
Copy Markdown
Contributor

And I still don't feel so good to merge a patch without CI coverage... What's the priority of this issue?

This PR will make everything easier for embedder & related event fix, according to @stevennovaryo

I think we should still review and merge this. Since there are multiple input related fix going on now, and this one is kinda fundamental. @xiaochengh

OK, that's a fair justification.

@xiaochengh xiaochengh enabled auto-merge May 28, 2025 08:31
@xiaochengh xiaochengh added this pull request to the merge queue May 28, 2025
Merged via the queue into servo:main with commit 45072ae May 28, 2025
21 checks passed
@yezhizhen yezhizhen deleted the fix-input branch May 28, 2025 12:38
github-merge-queue bot pushed a commit that referenced this pull request May 30, 2025
At `egl/app_state.rs`, send keydown and keyup with PROCESS KEY when
inserting text. This fixes OHOS input event, but maybe also for Android
in the future (if it implements `ime_insert_text`). We will get input
event since keydown is dispatched
(#37078).

This implementation is similar to
[Chromium's](https://source.chromium.org/chromium/chromium/src/+/main:content/public/android/java/src/org/chromium/content/browser/input/ImeAdapterImpl.java;drc=404e8d654e8b26336d2cb103b9c21faecbf7f73a;bpv=1;bpt=1;l=851?gsn=sendCompositionToNative&gs=KYTHE%3A%2F%2Fkythe%3A%2F%2Fchromium.googlesource.com%2Fcodesearch%2Fchromium%2Fsrc%2F%2Fmain%3Flang%3Djava%3Fpath%3Dorg.chromium.content.browser.input.ImeAdapterImpl%23d840961d441fd4bb569f9689c86da91fb714c0c153366e3198a85e9c7a098dce)
Android key event.

Testing: manually checked on OHOS device
For: #36259, but only in OHOS

Signed-off-by: PotatoCP <[email protected]>
Co-authored-by: PotatoCP <[email protected]>
Co-authored-by: stevennovaryo <[email protected]>
PotatoCP pushed a commit to PotatoCP/servo that referenced this pull request Jun 4, 2025
…servo#37078)

1. Let `input` JS event be dispatched by `keydown` instead of
`keypress`, according to spec
2. Fire `input` event for Backspace and Delete. But do so only when
something is actually deleted

Testing: Manually tested and compared with other browsers.
Fixes: servo#37051
cc @xiaochengh

Signed-off-by: Euclid Ye <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

input event is not properly triggered by Backspace and Delete

4 participants