Skip to content

Investigate how to handle autofocus tests for newly inserted elements #1720

@whimboo

Description

@whimboo

With whatwg/html#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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions