Bug 211548

Summary: [WebDriver][GTK] W3C test element_click/navigate.py::test_link_closes_window is flaky with window too slow to close
Product: WebKit Reporter: Lauro Moura <lmoura>
Component: WebDriverAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: bburg, bugs-noreply
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Lauro Moura 2020-05-06 22:02:40 PDT
The test imported/w3c/webdriver/tests/element_click/navigate.py::test_link_closes_window is flaky failing in the Release bot (Failure message below).

Checking the order of the messages in the WebAutomationSession and the Load events from the WebView, it shows the command "getBrowsingContext" (used to get the session handles) being called before the load of the new page (with the close command) finishes. And adding a 1s time before this last assert indeed makes the test pass.

Failure: 
session = <Session b5584a68-e7e0-49c9-9909-fe4b10f18a67>
create_window = <function create_window at 0x7faf41d4b578>

    def test_link_closes_window(session, create_window):
        new_handle = create_window()
        session.window_handle = new_handle
    
        session.url = inline("""<a href="/webdriver/tests/element_click/support/close_window.html">asdf</a>""")
        element = session.find.css("a", all=False)
        response = element_click(session, element)
        assert_success(response)
>       assert new_handle not in session.handles
E       AssertionError: assert 'page-0CB84772-57CF-4E77-81F5-09A2F65A05C0' not in ['page-2BE3673B-CE41-4F70-97F4-1218E205BCCC', 'page-0CB84772-57CF-4E77-81F5-09A2F65A05C0']
E        +  where ['page-2BE3673B-CE41-4F70-97F4-1218E205BCCC', 'page-0CB84772-57CF-4E77-81F5-09A2F65A05C0'] = <Session b5584a68-e7e0-49c9-9909-fe4b10f18a67>.handles