-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WebDriverBiDi] Add test for
originalOpener
to `browsingContext.cre…
…ated` (#46754) * [WebDriverBiDi] Add test for `originalOpener` to `browsingContext.created` * chore: fix comments * chore: update comment * Update webdriver/tests/bidi/browsing_context/context_created/original_opener.py Co-authored-by: Henrik Skupin <[email protected]> --------- Co-authored-by: Alex Rudenko <[email protected]> Co-authored-by: Henrik Skupin <[email protected]>
- Loading branch information
1 parent
495533c
commit 3ed35e6
Showing
2 changed files
with
65 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
63 changes: 63 additions & 0 deletions
63
webdriver/tests/bidi/browsing_context/context_created/original_opener.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,63 @@ | ||
import pytest | ||
from webdriver.bidi.modules.script import ContextTarget | ||
|
||
from .. import assert_browsing_context | ||
|
||
pytestmark = pytest.mark.asyncio | ||
|
||
CONTEXT_CREATED_EVENT = "browsingContext.contextCreated" | ||
|
||
|
||
@pytest.mark.parametrize("type_hint", ["tab", "window"]) | ||
async def test_original_opener_context_create(bidi_session, wait_for_event, wait_for_future_safe, subscribe_events, type_hint): | ||
|
||
await subscribe_events([CONTEXT_CREATED_EVENT]) | ||
on_entry = wait_for_event(CONTEXT_CREATED_EVENT) | ||
|
||
top_level_context = await bidi_session.browsing_context.create(type_hint=type_hint) | ||
|
||
context_info = await wait_for_future_safe(on_entry) | ||
|
||
assert_browsing_context( | ||
context_info, | ||
context=top_level_context["context"], | ||
original_opener=None | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("type_hint", ["tab", "window"]) | ||
@pytest.mark.parametrize("domain", ["", "alt"], ids=["same_origin", "cross_origin"]) | ||
@pytest.mark.parametrize("features, returns_window", [ | ||
("", True), | ||
("popup", True), | ||
("noopener", False), | ||
("noreferrer", False) | ||
] | ||
) | ||
async def test_original_opener_window_open(bidi_session, wait_for_event, wait_for_future_safe, subscribe_events, inline, | ||
type_hint, domain, features, returns_window): | ||
|
||
top_level_context = await bidi_session.browsing_context.create(type_hint=type_hint) | ||
|
||
await subscribe_events([CONTEXT_CREATED_EVENT]) | ||
on_entry = wait_for_event(CONTEXT_CREATED_EVENT) | ||
|
||
url = inline("", domain=domain) | ||
|
||
result = await bidi_session.script.evaluate( | ||
expression=f"""window.open("{url}", "_blank", "{features}");""", | ||
target=ContextTarget(top_level_context["context"]), | ||
await_promise=False) | ||
|
||
context_info = await wait_for_future_safe(on_entry) | ||
|
||
# We use None here as evaluate not always returns value. | ||
context = None | ||
if returns_window: | ||
context = result["value"]["context"] | ||
|
||
assert_browsing_context( | ||
context_info, | ||
context=context, | ||
original_opener=top_level_context["context"] | ||
) |