Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wdspec] change test_..._closes_browsing_context #49765

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sadym-chromium
Copy link
Contributor

Classic tests. Open context with window.open to allow it to be closed by script.

@sadym-chromium
Copy link
Contributor Author

@whimboo it looks like this functionality does not work properly on ChromeDriver Classic, so I cannot verify if the test actually works. Could you please confirm it works for Firefox?

Copy link
Contributor

@whimboo whimboo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. I commented yesterday but forgot to actually submit the comments.

webdriver/tests/classic/perform_actions/key.py Outdated Show resolved Hide resolved
webdriver/tests/classic/perform_actions/key.py Outdated Show resolved Hide resolved
Copy link
Contributor

@whimboo whimboo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just a small nit. Could you check why the Chrome stability job is failing?

webdriver/tests/classic/perform_actions/key.py Outdated Show resolved Hide resolved
Copy link
Contributor

@whimboo whimboo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the tests for Firefox are failing because the input element cannot be located. We should actually wait until the page in the new window is loaded, or the element is present.

@whimboo
Copy link
Contributor

whimboo commented Jan 14, 2025

@sadym-chromium actually something is wrong with your implementation of https://w3c.github.io/webdriver/#new-window. When a new tab gets opened by chromedriver I can see about:blank in the session history, which actually prevents closing the window because session history entry size is 2. Why is about:blank added to the session history?

@sadym-chromium
Copy link
Contributor Author

sadym-chromium commented Jan 15, 2025

@sadym-chromium actually something is wrong with your implementation of https://w3c.github.io/webdriver/#new-window. When a new tab gets opened by chromedriver I can see about:blank in the session history, which actually prevents closing the window because session history entry size is 2. Why is about:blank added to the session history?

I assume this is not related to this tests, as we don't use "POST /session/{session id}/window/new" in the test, but open a new window via web API

@sadym-chromium
Copy link
Contributor Author

@sadym-chromium actually something is wrong with your implementation of https://w3c.github.io/webdriver/#new-window. When a new tab gets opened by chromedriver I can see about:blank in the session history, which actually prevents closing the window because session history entry size is 2. Why is about:blank added to the session history?

I filed a related ChromeDriver issue: https://crbug.com/390100762

@whimboo
Copy link
Contributor

whimboo commented Jan 16, 2025

I filed a related ChromeDriver issue: https://crbug.com/390100762

Hm, this is not what I'm referring to. The test actually fails the assertion in Chrome because the window is not closed. Please run window.open("about:blank", "_blank", "chrome,menubar,resizable,scrollbars,status,toolbar") manually in Chrome and then load a new URL in that opened window. You can see that about:blank is not added to the session history of this tab. Running the same steps with Chromedriver adds about:blank to the session history when navigating to a different page (like the test page).

@OrKoN
Copy link
Contributor

OrKoN commented Jan 16, 2025

@sadym-chromium indeed, I think if navigation happens from about:blank, the URL navigated to should replace https://html.spec.whatwg.org/#the-navigation-must-be-a-replace the about:blank, thus making it script-closable due to the history entry size staying 1.

Classic tests. Open context with `window.open` to allow it to be closed by script.
@sadym-chromium sadym-chromium force-pushed the sadym/classic-input-tests-browsing-context-closed branch from 6860a93 to d4a1035 Compare January 16, 2025 11:34
@@ -24,10 +24,17 @@ def test_no_browsing_context(session, closed_frame, key_chain):
def test_key_down_closes_browsing_context(
session, configuration, http_new_tab, inline, key_chain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that a window gets opened by the script we do no longer need the http_new_tab fixture here and in all the other tests.

Suggested change
session, configuration, http_new_tab, inline, key_chain
session, configuration, inline, key_chain

new_window = session.execute_script(f"return window.open('{url}')")

# Switch to the new window.
session.window_handle = new_window.id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still failing Firefox tests because none of the tests are waiting for the navigation to be completed. We need to wait for the input element to have the focus before we can start performing the action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants