webdriver icon indicating copy to clipboard operation
webdriver copied to clipboard

Navigation in `execute a function body` should abort script execution

Open whimboo opened this issue 6 years ago • 2 comments

If a navigation happens while a script is getting executed the script would always timeout if there isn't an early break out. As of now there is nothing listed in the Webdriver spec:

https://w3c.github.io/webdriver/#execute-script#x13-2-executing-script

With Marionette/geckodriver we currently return a JavascriptError.

CC'ing @jgraham, @andreastt, @AutomatedTester, @shs96c.

whimboo avatar Feb 13 '19 21:02 whimboo

If the proposed solution from @whimboo is ok, I would love to take a stab at this to bring this into the protocol. I created a wpt test for it at https://github.com/web-platform-tests/wpt/pull/15517

  • test_script_abortion_due_navigation_change_via_location
    esponse = execute_async_script(session, """
        const url = arguments[0];
        const resolve = arguments[1];
        setTimeout(() => resolve('navigation change'), 1000);
        window.location = url;
        """, [url])
    
    passes in Firefox, fails in Chrome because status code is 500, expected 400
  • I also added a test to check what happens if the context is being changed
    esponse = execute_async_script(session, """
        const url = arguments[0];
        const resolve = arguments[1];
        setTimeout(() => resolve('context change'), 1000);
        window.open(url);
        """, [url])
    
    passes both in Chrome and Firefox, is that expected?

What do you all think?

christian-bromann avatar Feb 22 '19 10:02 christian-bromann

At least in Firefox we already have that feature in place, so it should pass yes.

whimboo avatar Feb 26 '19 15:02 whimboo