w3c / w3c/webdriver

Investigate how to handle autofocus tests for newly inserted elements

Open
#1,720 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Get Active Element needs-discussion
Dominant language
HTML
Stars
718
Forks
228
PR merge metrics
No merged PRs in 30d

Description

With https://github.com/whatwg/html/pull/3488 a change landed in the HTML spec quiet some time ago which moved out the autofocus step into a separate task. It means that for newly inserted elements (eg. attachChild or due to a navigation) the autofocus is not rendered immediately but after the next request animation frame task.

With bug 1444491 this has been finally implemented in Firefox. With that landing we have seen new test failures (bug 1816955) for autofocus wdspec tests. We landed a temporary fix so that the test keeps working but also is still compliant to the current WebDriver classic specification. This basically runs the following Execute Async Script command before the Get Active Element command:

    session.execute_async_script(
        """
        const resolve = arguments[0];
        window.requestAnimationFrame(function() {
            window.requestAnimationFrame(resolve);
        });
        """
    )

To not require consumers to have to run this step on the client side we should probably update the Get Active Element command to request an animation frame first before actually trying to get the active element in step 3.

CC @jgraham, @foolip, @sadym-chromium what do you think?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the WebDriver Get Active Element command and the linked HTML autofocus change, then compare current behavior with the temporary Execute Async Script workaround. Determine whether requesting an animation frame belongs before active-element retrieval, and update the relevant autofocus wdspec tests to verify newly inserted elements and navigation cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.