-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wdspec] Implement "browser.getClientWindows" command tests.
Differential Revision: https://phabricator.services.mozilla.com/D225691 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1855025 gecko-commit: 346312f12562054e80b4d85fbb563ff29132e0f3 gecko-reviewers: whimboo, webdriver-reviewers
- Loading branch information
1 parent
01b6697
commit d2b38b3
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
59 changes: 59 additions & 0 deletions
59
webdriver/tests/bidi/browser/get_client_windows/get_client_windows.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import pytest | ||
|
||
pytestmark = pytest.mark.asyncio | ||
|
||
async def test_open_and_close(bidi_session): | ||
initial_windows = await bidi_session.browser.get_client_windows() | ||
assert len(initial_windows) == 1 | ||
|
||
new_browsing_context = await bidi_session.browsing_context.create(type_hint="window") | ||
try: | ||
updated_windows = await bidi_session.browser.get_client_windows() | ||
assert isinstance(updated_windows, list) | ||
assert len(updated_windows) == 2 | ||
assert updated_windows[0]["clientWindow"] != updated_windows[1]["clientWindow"] | ||
finally: | ||
await bidi_session.browsing_context.close(context=new_browsing_context["context"]) | ||
|
||
final_windows = await bidi_session.browser.get_client_windows() | ||
assert final_windows == initial_windows | ||
|
||
|
||
async def test_activate_client_windows(bidi_session): | ||
initial_windows = await bidi_session.browser.get_client_windows() | ||
assert len(initial_windows) == 1 | ||
initial_window = initial_windows[0] | ||
initial_window_id = initial_window["clientWindow"] | ||
|
||
initial_contexts = await bidi_session.browsing_context.get_tree() | ||
assert len(initial_contexts) == 1 | ||
initial_context_id = initial_contexts[0]["context"] | ||
|
||
try: | ||
new_browsing_context = await bidi_session.browsing_context.create(type_hint="window") | ||
all_windows = await bidi_session.browser.get_client_windows() | ||
assert len(all_windows) == 2 | ||
|
||
first_window = next(window for window in all_windows if window["clientWindow"] == initial_window_id) | ||
second_window = next(window for window in all_windows if window["clientWindow"] != initial_window_id) | ||
|
||
assert second_window["active"] | ||
assert not first_window["active"] | ||
|
||
await bidi_session.browsing_context.activate(context=initial_context_id) | ||
|
||
all_windows = await bidi_session.browser.get_client_windows() | ||
|
||
first_window = next(window for window in all_windows if window["clientWindow"] == initial_window_id) | ||
second_window = next(window for window in all_windows if window["clientWindow"] != initial_window_id) | ||
|
||
assert first_window["active"] | ||
assert not second_window["active"] | ||
finally: | ||
await bidi_session.browsing_context.close(context=new_browsing_context["context"]) | ||
|
||
final_windows = await bidi_session.browser.get_client_windows() | ||
assert(final_windows[0]["active"]) == True | ||
assert final_windows[0]["clientWindow"] == initial_window_id | ||
|
||
|