w3c / webdriver

Remote control interface that enables introspection and control of user agents.
https://w3c.github.io/webdriver/
Other
676 stars 190 forks source link

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

Open whimboo opened 1 year ago

whimboo commented 1 year ago

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?