Skip to content

script: Fully integrate key event handling - #48324

Merged
mrobinson merged 1 commit into
servo:mainfrom
mrobinson:fully-integrate-key-event-handling
Sep 24, 2026
Merged

mrobinson merged 1 commit into
servo:mainfrom
mrobinson:fully-integrate-key-event-handling

Conversation

@mrobinson

Copy link
Copy Markdown
Member

This change makes it so that key events for both text inputs and for the
Document are handled in the same place. In addition, it ensures that
all edits from key events happen after keypress events fire.

Testing: This causes some subtests to start passing. In addition two tests
have neutral result changes:

  • paste-on-detaching-iframe.https.html: Moves from timeout to crash but this
    crash is the one caused by the harness still timing out. This is due to an
    issue where handled events for closed iframes are never communicated to the
    WebDriver harness.
  • onselectstart-on-key-in-contenteditable.html: One more subtest starts failing
    due to getting further along in the process of the test. This should be fixed
    with the implementation of the selectstart event.

@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Sep 23, 2026
@mrobinson mrobinson added the T-linux-wpt Do a try run of the WPT label Sep 23, 2026
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Sep 23, 2026
@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

Flaky unexpected result (39)
  • CRASH [expected OK] /_mozilla/mozilla/iframe-contentDocument.html
  • OK /_webgl/conformance/textures/misc/texture-upload-size.html (#21770)
    • FAIL [expected PASS] subtest: WebGL test #53

      assert_true: Texture was smaller than the expected size 2x2 expected true got false
      

    • FAIL [expected PASS] subtest: WebGL test #55

      assert_true: getError expected: INVALID_VALUE. Was NO_ERROR : when calling texSubImage2D with the same texture upload with offset 1, 1 expected true got false
      

    • FAIL [expected PASS] subtest: WebGL test #57

      assert_true: Texture was smaller than the expected size 2x2 expected true got false
      

    • FAIL [expected PASS] subtest: WebGL test #59

      assert_true: getError expected: INVALID_VALUE. Was NO_ERROR : when calling texSubImage2D with the same texture upload with offset 1, 1 expected true got false
      

    • PASS [expected FAIL] subtest: WebGL test #61
    • PASS [expected FAIL] subtest: WebGL test #63
    • PASS [expected FAIL] subtest: WebGL test #65
    • PASS [expected FAIL] subtest: WebGL test #67
    • FAIL [expected PASS] subtest: WebGL test #69

      assert_true: Texture was smaller than the expected size 2x2 expected true got false
      

    • FAIL [expected PASS] subtest: WebGL test #71

      assert_true: getError expected: INVALID_VALUE. Was NO_ERROR : when calling texSubImage2D with the same texture upload with offset 1, 1 expected true got false
      

    • And 6 more unexpected results...
  • TIMEOUT [expected OK] /_webgl/conformance/uniforms/no-over-optimization-on-uniform-array-09.html
    • NOTRUN [expected PASS] subtest: Overall test
  • CRASH [expected OK] /_webgl/conformance/uniforms/no-over-optimization-on-uniform-array-14.html
  • CRASH [expected OK] /_webgl/conformance/uniforms/no-over-optimization-on-uniform-array-16.html
  • CRASH [expected OK] /_webgl/conformance/uniforms/no-over-optimization-on-uniform-array-17.html
  • CRASH [expected OK] /_webgl/conformance2/sync/sync-webgl-specific.html
  • TIMEOUT [expected CRASH] /content-security-policy/inheritance/blob-url-in-main-window-self-navigate-inherits.sub.html (#41490)
  • FAIL [expected PASS] /css/css-backgrounds/background-size-041.html
  • FAIL [expected PASS] /css/css-fonts/font-feature-settings-descriptor-01.html (#45418)
  • OK /css/css-fonts/variations/at-font-face-font-matching.html (#20684)
    • FAIL [expected PASS] subtest: Matching font-weight: '430' should prefer '501 550' over '502 560'

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

    • FAIL [expected PASS] subtest: Matching font-style: 'oblique 20deg' should prefer 'oblique 0deg' over 'oblique -50deg -20deg'

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

  • OK /dom/nodes/moveBefore/iframe-document-preserve.window.html (#43152)
    • FAIL [expected PASS] subtest: moveBefore(): cross-origin iframe is preserved: remove new parent

      assert_equals: iframe does not fire a second load event expected 1 but got 0
      

    • FAIL [expected PASS] subtest: moveBefore(): cross-origin iframe is preserved: remove self

      assert_equals: iframe does not fire a second load event expected 1 but got 0
      

    • FAIL [expected PASS] subtest: moveBefore(): cross-origin iframe is preserved: remove self via innerHTML

      assert_equals: iframe does not fire a second load event expected 1 but got 0
      

  • OK [expected TIMEOUT] /fetch/api/redirect/redirect-keepalive.https.any.html (#32153)
    • PASS [expected TIMEOUT] subtest: [keepalive][iframe][load] mixed content redirect; setting up
  • 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 [expected TIMEOUT] /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-requestsubmit.html (#44098)
    • FAIL [expected TIMEOUT] subtest: Replace before load, triggered by formElement.requestSubmit()

      assert_equals: expected "http://web-platform.test:8000/common/blank.html?thereplacement=" but got "http://web-platform.test:8000/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20form%20%3D%20document.createElement(%22form%22)%3B%0A%20%20%20%20form.action%20%3D%20%22%2Fcommon%2Fblank.html%22%3B%0A%0A%20%20%20%20const%20input%20%3D%20document.createElement(%22input%22)%3B%0A%20%20%20%20input.type%20%3D%20%22hidden%22%3B%0A%20%20%20%20input.name%20%3D%20%22thereplacement%22%3B%0A%20%20%20%20form.append(input)%3B%0A%0A%20%20%20%20document.currentScript.before(form)%3B%0A%20%20%20%20form.requestSubmit()%3B%0A%20%20"
      

  • TIMEOUT /html/browsers/history/the-history-interface/001.html (#12580)
    • FAIL [expected PASS] subtest: traversing history must also traverse hash changes

      assert_equals: (this could cause other failures later on) expected "" but got "test"
      

  • TIMEOUT [expected OK] /html/browsers/windows/consume-user-activation/window-open-multi-global.html (#47399)
    • TIMEOUT [expected FAIL] subtest: window.open() and consuming user activation with multiple globals in play

      Test timed out
      

  • OK /html/dom/render-blocking/remove-attr-unblocks-rendering.optional.html
    • PASS [expected FAIL] subtest: Render-blocking on script-inserted module script is cancellable
  • OK /html/semantics/embedded-content/media-elements/media_fragment_seek.html (#24114)
    • FAIL [expected PASS] subtest: Video should seek to time specified in media fragment syntax

      assert_equals: expected 3 but got 0
      

  • OK /html/semantics/embedded-content/media-elements/track/track-element/track-cues-sorted-before-dispatch.html (#48292)
    • FAIL [expected PASS] subtest: All events are triggered in chronological order

      assert_equals: expected 14 but got 16
      

  • OK [expected CRASH] /html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-reload-location-reload.html (#32595)
  • TIMEOUT [expected OK] /html/user-activation/navigation-state-reset-sameorigin.html (#45151)
    • TIMEOUT [expected FAIL] subtest: Post-navigation state reset.

      Test timed out
      

  • OK /html/webappapis/user-prompts/print-during-unload.html (#35944)
    • PASS [expected FAIL] subtest: print() during unload
  • OK /infrastructure/testdriver/click_window.html (#47303)
    • FAIL [expected PASS] subtest: TestDriver click method in window

      Unhandled rejection: assert_unreached: click failed Reached unreachable code
      

  • OK /mixed-content/tentative/autoupgrades/video-upgrade.https.sub.html (#41135)
    • FAIL [expected PASS] subtest: Video of other host autoupgraded

      assert_equals: Length. Other host expected 1 but got Infinity
      

  • ERROR [expected TIMEOUT] /performance-timeline/not-restored-reasons/abort-block-bfcache.window.html (#42802)
  • TIMEOUT [expected OK] /pointerevents/compat/pointerevent_touch-action_two-finger_interaction.html (#44693)
    • NOTRUN [expected PASS] subtest: touch two-finger pan on 'touch-action: pan-x pan-y'
    • NOTRUN [expected FAIL] subtest: touch two-finger pan on 'touch-action: pinch-zoom'
  • CRASH [expected OK] /pointerevents/pointerevent_sequence_at_implicit_release_on_click.html?mouse
  • TIMEOUT [expected OK] /referrer-policy/gen/iframe.meta/strict-origin/svg-a-tag.http.html
    • TIMEOUT [expected FAIL] subtest: Referrer Policy: Expects origin for svg-a-tag to same-https origin and no-redirect redirection from http context.

      Test timed out
      

  • OK /resource-timing/buffer-full-then-increased.html (#44408)
    • FAIL [expected PASS] subtest: Test that overflowing the buffer and immediately increasing its limit does not trigger the resourcetimingbufferfull event

      assert_equals: Number of entries does not match the expected value. expected 3 but got 1
      

  • OK /sanitizer-api/sanitizer-inert-document.html (#45260)
    • PASS [expected FAIL] subtest: Test whether setHTML loads the image.
    • FAIL [expected PASS] subtest: Test whether setHTMLUnsafe loads the image.

      promise_test: Unhandled rejection with value: "The server observed a request. It shouldn't have."
      

  • OK /touch-events/single-tap-when-touchend-listener-use-sync-xhr.html (#41175)
    • PASS [expected FAIL] subtest: Click event should be fired when touchend opens synchronous XHR
  • TIMEOUT [expected OK] /trusted-types/trusted-types-navigation.html?31-35 (#38034)
    • TIMEOUT [expected PASS] subtest: Navigate a frame via form-submission with javascript:-urls in report-only mode.

      Test timed out
      

    • NOTRUN [expected PASS] subtest: Navigate a frame via form-submission with javascript:-urls w/ default policy in report-only mode.
    • NOTRUN [expected FAIL] subtest: Navigate a window via form-submission with javascript:-urls w/ a default policy throwing an exception in enforcing mode.
    • NOTRUN [expected FAIL] subtest: Navigate a window via form-submission with javascript:-urls w/ a default policy throwing an exception in report-only mode.
    • NOTRUN [expected FAIL] subtest: Navigate a window via form-submission with javascript:-urls w/ a default policy making the URL invalid in enforcing mode.
  • OK /upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/websocket.https.html
    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects allowed for websocket to cross-ws-downgrade origin and no-redirect redirection from https context.

      assert_equals: The resource request should be 'allowed'. expected "allowed" but got "blocked"
      

    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects allowed for websocket to same-ws-downgrade origin and no-redirect redirection from https context.

      assert_equals: The resource request should be 'allowed'. expected "allowed" but got "blocked"
      

  • OK /wasm/webapi/abort.any.worker.html (#40013)
    • FAIL [expected PASS] subtest: compileStreaming() asynchronously racing with abort should succeed or reject with AbortError

      assert_equals: expected "AbortError" but got "CompileError"
      

  • OK /webdriver/tests/classic/perform_actions/pointer_pen.py (#47618)
    • FAIL [expected PASS] subtest: test_pen_pointer_in_shadow_tree[outer-open]

      AssertionError
      

    • FAIL [expected PASS] subtest: test_pen_pointer_in_shadow_tree[inner-open]

      AssertionError
      

  • OK /webdriver/tests/classic/set_window_rect/user_prompts.py
    • ERROR [expected PASS] subtest: test_accept[alert-None]

      teardown error: http.client.RemoteDisconnected: Remote end closed connection without response
      

    • ERROR [expected PASS] subtest: test_accept[confirm-True]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_accept[prompt-]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_accept_and_notify[alert-None]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_accept_and_notify[confirm-True]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_accept_and_notify[prompt-]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_dismiss[alert-None]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_dismiss[confirm-False]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_dismiss[prompt-None]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_dismiss_and_notify[alert-None]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • And 8 more unexpected results...
  • TIMEOUT [expected OK] /webstorage/storage_local_setitem_quotaexceedederr.window.html
  • CRASH [expected OK] /webstorage/storage_session_setitem_quotaexceedederr.window.html
Stable unexpected results that are known to be intermittent (12)
  • TIMEOUT [expected OK] /_mozilla/mozilla/window-resize-event.html (#36741)
    • TIMEOUT [expected PASS] subtest: Popup onresize event fires after resizeTo

      Test timed out
      

  • OK /beacon/beacon-basic.https.window.html (#41723)
    • PASS [expected FAIL] subtest: Payload size restriction should be accumulated: type = arraybuffer
  • OK [expected ERROR] /focus/focus-event-after-switching-iframes.sub.html (#40368)
  • CRASH [expected TIMEOUT] /html/browsers/history/the-location-interface/location_replace_session_history.html (#41896)
  • OK [expected CRASH] /html/browsers/history/the-location-interface/replace-with-nested-iframe.html (#48219)
  • OK [expected TIMEOUT] /html/semantics/embedded-content/media-elements/autoplay-default-permissions-policy.https.sub.html (#46805)
    • PASS [expected TIMEOUT] subtest: Default "autoplay" feature policy ["self"] allows same-origin iframes.
  • OK /html/webappapis/dynamic-markup-insertion/document-write/iframe_005.html (#43671)
    • PASS [expected FAIL] subtest: document.write external script into iframe write back into parent
  • ERROR [expected OK] /intersection-observer/v2/animated-opacity.html (#40827)
  • OK /pointerevents/pointerevent_pointercapture_in_frame.html?pen (#45536)
    • PASS [expected FAIL] subtest: Test penpointer capture in same-origin frame: Pointer down at inner frame and set pointer capture.
    • PASS [expected FAIL] subtest: Test penpointer capture in same-origin frame: Pointer down at inner frame and set pointer capture to outer frame should not capture.
  • OK /resource-timing/test_resource_timing.https.html (#25216)
    • PASS [expected FAIL] subtest: PerformanceEntry has correct name, initiatorType, startTime, and duration (link)
  • OK [expected TIMEOUT] /trusted-types/trusted-types-navigation.html?16-20 (#44835)
    • PASS [expected TIMEOUT] subtest: Navigate a frame via area with javascript:-urls in report-only mode.
    • PASS [expected NOTRUN] subtest: Navigate a frame via area with javascript:-urls w/ default policy in report-only mode.
  • OK [expected TIMEOUT] /webstorage/localstorage-about-blank-3P-iframe-opens-3P-window.partitioned.html (#29053)
    • FAIL [expected TIMEOUT] subtest: StorageKey: test 3P about:blank window opened from a 3P iframe

      assert_true: about:blank window opened by 3P iframe does not inherit 3P iframe's StorageKey expected true got false
      

@github-actions

Copy link
Copy Markdown

✨ Try run (#35842678458) succeeded.

})
.shortcut(CMD_OR_CONTROL, 'A', || {
self.select_all();
/// Process a given `EditorAction` and return an action for the caller to execute.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should probably be EditingAction?


pub(crate) fn perform_editing_action(&self, cx: &mut JSContext, action: EditingAction) -> bool {
// A couple editing actions can be performed via the external interface of
// `EditincContext`. If that's the case we want to do that so that the same

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Small typo here


let mut is_space = false;
let scroll = match event.key() {
let scroll = match &event.key {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could cursor movement editing actions be implemented in Document's perform_editing_action instead of re-checking the keyboard scroll keys? Not sure if there's some inconsistency that prevents doing that but it could make the logic less spread out.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Cursor movement and keyboard scrolling a two entirely separate concepts where cursor motion supersedes keyboard scrolling when it is available. In addition, it is interesting to keep editing actions (such as cursor movement) integrated for text inputs and the contenteditable, whereas keyboard scrolling doesn't apply to text inputs.

@dzfrias dzfrias Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah ok! That makes sense especially with respect to contenteditable elements.

This change makes it so that key events for both text inputs and for the
`Document` are handled in the same place. In addition, it ensures that
all edits from key events happen *after* `keypress` events fire.

Signed-off-by: Martin Robinson <[email protected]>
@mrobinson
mrobinson force-pushed the fully-integrate-key-event-handling branch from d644dc1 to 4744428 Compare September 24, 2026 13:50

@mrobinson mrobinson left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks. I've addressed the typos.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Sep 24, 2026
@jdm

jdm commented Sep 24, 2026

Copy link
Copy Markdown
Member

This is a very nice consolidation. Thanks!

@mrobinson
mrobinson added this pull request to the merge queue Sep 24, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Sep 24, 2026
Merged via the queue into servo:main with commit fd4d5d0 Sep 24, 2026
33 checks passed
@mrobinson
mrobinson deleted the fully-integrate-key-event-handling branch September 24, 2026 16:35
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Sep 24, 2026
@mrobinson mrobinson mentioned this pull request Sep 25, 2026
25 of 40 tasks
RichardTjokroutomo pushed a commit to RichardTjokroutomo/servo that referenced this pull request Oct 6, 2026
This change makes it so that key events for both text inputs and for the
`Document` are handled in the same place. In addition, it ensures that
all edits from key events happen *after* `keypress` events fire.

Testing: This causes some subtests to start passing. In addition two
tests
have neutral result changes:
- `paste-on-detaching-iframe.https.html`: Moves from timeout to crash
but this
crash is the one caused by the harness still timing out. This is due to
an
issue where handled events for closed iframes are never communicated to
the
   WebDriver harness.
- `onselectstart-on-key-in-contenteditable.html`: One more subtest
starts failing
due to getting further along in the process of the test. This should be
fixed
    with the implementation of the `selectstart` event.

Signed-off-by: Martin Robinson <[email protected]>
hhhwsqhhh pushed a commit to hhhwsqhhh/servo that referenced this pull request Oct 12, 2026
This change makes it so that key events for both text inputs and for the
`Document` are handled in the same place. In addition, it ensures that
all edits from key events happen *after* `keypress` events fire.

Testing: This causes some subtests to start passing. In addition two
tests
have neutral result changes:
- `paste-on-detaching-iframe.https.html`: Moves from timeout to crash
but this
crash is the one caused by the harness still timing out. This is due to
an
issue where handled events for closed iframes are never communicated to
the
   WebDriver harness.
- `onselectstart-on-key-in-contenteditable.html`: One more subtest
starts failing
due to getting further along in the process of the test. This should be
fixed
    with the implementation of the `selectstart` event.

Signed-off-by: Martin Robinson <[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.

4 participants