Skip to content

Commit

Permalink
build(chrome): update the pinned browser version + fix (#2206)
Browse files Browse the repository at this point in the history
Addressing
#2205.
* Bump from #2197
* Fix e2e test. Filter out optional initial load event.

---------

Co-authored-by: Browser Automation Bot <browser-automation-bot@google.com>
  • Loading branch information
sadym-chromium and browser-automation-bot authored May 15, 2024
1 parent 2b15dd9 commit 7c810f2
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .browser
Original file line number Diff line number Diff line change
@@ -1 +1 @@
chrome@126.0.6465.2
chrome@126.0.6478.2
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"chai": "4.4.1",
"chai-as-promised": "7.1.1",
"debug": "4.3.4",
"devtools-protocol": "0.0.1297280",
"devtools-protocol": "0.0.1299070",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-import-resolver-typescript": "3.6.1",
Expand Down
97 changes: 42 additions & 55 deletions tests/browsing_context/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,69 +205,56 @@ async def test_browsingContext_create_withUserGesture_eventsEmitted(
}
})

# Read event messages. The order can vary, so read all and sort them.
# Read event messages. The order can vary, so read all and sort them. Ignore
# optional "browsingContext.domContentLoaded" event for "about:blank" pages.
# Expected sorted messages order:
# 1. Command result.
# 2. "browsingContext.contextCreated" event.
# 3. "browsingContext.domContentLoaded" event for "about:blank".
# 4. "browsingContext.domContentLoaded" event for the example_url.
# 5. "browsingContext.load" event.
messages = await read_sorted_messages(5)
# (optional). "browsingContext.domContentLoaded" event for "about:blank".
# Omitted in headful mode.
# 3. "browsingContext.domContentLoaded" event for the example_url.
# 4. "browsingContext.load" event.
messages = await read_sorted_messages(
4, lambda m: 'method' not in m or
(m['method'] != 'browsingContext.domContentLoaded') or m['params'][
'url'] != 'about:blank')

# Get the new context id from the "browsingContext.contextCreated" event.
new_context_id = messages[1]['params']['context']

assert messages == [
{
'id': command_id,
'type': 'success',
'result': ANY_DICT
},
{
'type': 'event',
'method': 'browsingContext.contextCreated',
'params': {
'context': ANY_STR,
'url': 'about:blank',
'children': None,
'parent': None,
'userContext': 'default'
}
},
# TODO: CDP sends Lifecycle events when we send Lifecycle event enable
# These events correspond to the initial about:blank creation
# We should try to ignore the from Mapper.
{
'type': 'event',
'method': 'browsingContext.domContentLoaded',
'params': {
'context': new_context_id,
'navigation': ANY_STR,
'timestamp': ANY_TIMESTAMP,
'url': 'about:blank'
}
},
{
'type': 'event',
'method': 'browsingContext.domContentLoaded',
'params': {
'context': new_context_id,
'navigation': ANY_STR,
'timestamp': ANY_TIMESTAMP,
'url': example_url
}
},
{
'type': 'event',
'method': 'browsingContext.load',
'params': {
'context': new_context_id,
'navigation': ANY_STR,
'timestamp': ANY_TIMESTAMP,
'url': example_url
}
assert messages == [{
'id': command_id,
'type': 'success',
'result': ANY_DICT
}, {
'type': 'event',
'method': 'browsingContext.contextCreated',
'params': {
'context': ANY_STR,
'url': 'about:blank',
'children': None,
'parent': None,
'userContext': 'default'
}
}, {
'type': 'event',
'method': 'browsingContext.domContentLoaded',
'params': {
'context': new_context_id,
'navigation': ANY_STR,
'timestamp': ANY_TIMESTAMP,
'url': example_url
}
}, {
'type': 'event',
'method': 'browsingContext.load',
'params': {
'context': new_context_id,
'navigation': ANY_STR,
'timestamp': ANY_TIMESTAMP,
'url': example_url
}
]
}]


@pytest.mark.asyncio
Expand Down
14 changes: 11 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import asyncio
import os
import ssl
from collections.abc import Callable
from pathlib import Path
from uuid import uuid4

Expand Down Expand Up @@ -294,11 +295,18 @@ def cacheable_url(local_server: LocalHttpServer):
@pytest.fixture
def read_sorted_messages(websocket):
"""Read the given number of messages from the websocket, and returns them
in consistent order."""
async def read_sorted_messages(message_count):
in consistent order. Ignore messages that do not match the filter."""
async def read_sorted_messages(
message_count,
filter_lambda: Callable[[dict], bool] = lambda _: True):
messages = []
for _ in range(message_count):
messages.append(await read_JSON_message(websocket))
# Get the next message matching the filter.
while True:
message = await read_JSON_message(websocket)
if filter_lambda(message):
break
messages.append(message)
messages.sort(key=lambda x: x["method"]
if "method" in x else str(x["id"]) if "id" in x else "")
return messages
Expand Down

0 comments on commit 7c810f2

Please sign in to comment.