Skip to content

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

@OrKoN

Description

@OrKoN

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions