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

WebDriver: Should Set Permission apply to future browsing contexts? #437

Open
OrKoN opened this issue Jan 16, 2024 · 0 comments
Open

WebDriver: Should Set Permission apply to future browsing contexts? #437

OrKoN opened this issue Jan 16, 2024 · 0 comments

Comments

@OrKoN
Copy link
Contributor

OrKoN commented Jan 16, 2024

While adding support for the automation over WebDriver BiDi, I have noticed that Set a permission specifies that the permissions should be changed for only currently existing browsing contexts (unless I am misinterpreting?):

Let targets be a list containing all environment settings objects whose origin is same origin with target origin.

It does sound like if a new browsing context (and IIUC a new context would have a new environment settings object) with a previously configured origin gets created, it should not inherit the previously set permissions. I think that current implementation in Chrome does propagate previously set permissions to new contexts and I think this is what would be expected because the origin (and not a context) is an input for the method.

Test case:

@pytest.mark.asyncio
async def test_set_permission_new_context(bidi_session, new_tab, url):
    test_url = url("/common/blank.html", protocol="https")

    await bidi_session.browsing_context.navigate(
        context=new_tab["context"],
        url=test_url,
        wait="complete",
    )

    origin = await get_context_origin(bidi_session, new_tab)

    assert await get_permission_state(bidi_session, new_tab,  "geolocation") == "prompt"

    await bidi_session.permissions.set_permission(
        descriptor={"name": "geolocation"},
        state="granted",
        origin=origin,
    )

    assert await get_permission_state(bidi_session, new_tab,  "geolocation") == "granted"

    new_context = await bidi_session.browsing_context.create(type_hint="tab")
    assert new_tab["context"] != new_context["context"]
    await bidi_session.browsing_context.navigate(
        context=new_context["context"],
        url=test_url,
        wait="complete",
    )

    assert await get_permission_state(bidi_session, new_context,  "geolocation") == "granted" # Expected: prompt if I interpret the spec right.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant