Skip to content

Commit

Permalink
test: test no events for initial navigation (#2794)
Browse files Browse the repository at this point in the history
Repro for #2793
  • Loading branch information
sadym-chromium authored Nov 21, 2024
1 parent 321af13 commit aabb783
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions tests/browsing_context/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,66 @@ async def test_browsingContext_create_eventContextCreatedEmitted(
} == load_event


@pytest.mark.asyncio
async def test_browsingContext_create_noNavigationEventsEmitted(
websocket, context_id, read_sorted_messages):
pytest.xfail(
"https://github.com/GoogleChromeLabs/chromium-bidi/issues/2793")

await subscribe(websocket, [
"browsingContext.contextCreated", "browsingContext.domContentLoaded",
"browsingContext.load", "browsingContext.navigationStarted"
])

command_id = await send_JSON_command(websocket, {
"method": "browsingContext.create",
"params": {
"type": "tab"
}
})

[command_result, context_created_event] = await read_sorted_messages(2)

assert command_result == AnyExtending({
'id': command_id,
'type': 'success',
})

assert context_created_event == {
'method': 'browsingContext.contextCreated',
'params': {
'children': None,
'clientWindow': '',
'context': ANY_STR,
'originalOpener': context_id,
'parent': None,
'url': 'about:blank',
'userContext': 'default',
},
'type': 'event',
}
new_context_id = context_created_event["params"]["context"]

# Assert no other events.
command_id = await send_JSON_command(
websocket, {
"method": "script.evaluate",
"params": {
"expression": "1",
"target": {
"context": new_context_id,
},
"awaitPromise": False
}
})

response = await read_JSON_message(websocket)
assert response == AnyExtending({
'id': command_id,
'type': 'success',
})


@pytest.mark.asyncio
async def test_browsingContext_createWithNestedSameOriginContexts_eventContextCreatedEmitted(
websocket, context_id, html, iframe):
Expand Down

0 comments on commit aabb783

Please sign in to comment.