Skip to content

Commit 2db296d

Browse files
committed
Fix Chromium tracing tests
1 parent 633b160 commit 2db296d

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

playwright/_impl/_assertions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ async def to_have_url(
138138
ignoreCase: bool = None,
139139
) -> None:
140140
__tracebackhide__ = True
141-
base_url = self._actual_page.context.base_url
141+
base_url = self._actual_page.context._base_url
142142
if isinstance(urlOrRegExp, str) and base_url:
143143
urlOrRegExp = urljoin(base_url, urlOrRegExp)
144144
expected_text = to_expected_text_values([urlOrRegExp], ignoreCase=ignoreCase)

playwright/_impl/_frame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def predicate(event: Any) -> bool:
224224
return True
225225
waiter.log(f' navigated to "{event["url"]}"')
226226
return url_matches(
227-
cast("Page", self._page)._browser_context.base_url,
227+
cast("Page", self._page)._browser_context._base_url,
228228
event["url"],
229229
url,
230230
)
@@ -257,7 +257,7 @@ async def wait_for_url(
257257
timeout: float = None,
258258
) -> None:
259259
assert self._page
260-
if url_matches(self._page._browser_context.base_url, self.url, url):
260+
if url_matches(self._page._browser_context._base_url, self.url, url):
261261
await self._wait_for_load_state_impl(state=waitUntil, timeout=timeout)
262262
return
263263
async with self.expect_navigation(

playwright/_impl/_page.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ def frame(self, name: str = None, url: URLMatch = None) -> Optional[Frame]:
388388
for frame in self._frames:
389389
if name and frame.name == name:
390390
return frame
391-
if url and url_matches(self._browser_context.base_url, frame.url, url):
391+
if url and url_matches(self._browser_context._base_url, frame.url, url):
392392
return frame
393393

394394
return None
@@ -680,7 +680,7 @@ async def route(
680680
self._routes.insert(
681681
0,
682682
RouteHandler(
683-
self._browser_context.base_url,
683+
self._browser_context._base_url,
684684
url,
685685
handler,
686686
True if self._dispatcher_fiber else False,
@@ -722,7 +722,7 @@ async def route_web_socket(
722722
) -> None:
723723
self._web_socket_routes.insert(
724724
0,
725-
WebSocketRouteHandler(self._browser_context.base_url, url, handler),
725+
WebSocketRouteHandler(self._browser_context._base_url, url, handler),
726726
)
727727
await self._update_web_socket_interception_patterns()
728728

@@ -1268,7 +1268,7 @@ def expect_request(
12681268
def my_predicate(request: Request) -> bool:
12691269
if not callable(urlOrPredicate):
12701270
return url_matches(
1271-
self._browser_context.base_url,
1271+
self._browser_context._base_url,
12721272
request.url,
12731273
urlOrPredicate,
12741274
)
@@ -1300,7 +1300,7 @@ def expect_response(
13001300
def my_predicate(request: Response) -> bool:
13011301
if not callable(urlOrPredicate):
13021302
return url_matches(
1303-
self._browser_context.base_url,
1303+
self._browser_context._base_url,
13041304
request.url,
13051305
urlOrPredicate,
13061306
)

tests/async/test_chromium_tracing.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ async def test_should_create_directories_as_needed(
4444
assert os.path.getsize(output_file) > 0
4545

4646

47+
async def rafraf(target: Page, count: int = 1) -> None:
48+
for _ in range(count):
49+
await target.evaluate(
50+
"async () => await new Promise(f => window.requestAnimationFrame(() => window.requestAnimationFrame(f)));"
51+
)
52+
53+
4754
@pytest.mark.only_browser("chromium")
4855
async def test_should_run_with_custom_categories_if_provided(
4956
browser: Browser, page: Page, tmp_path: Path
@@ -54,6 +61,7 @@ async def test_should_run_with_custom_categories_if_provided(
5461
path=output_file,
5562
categories=["disabled-by-default-cc.debug"],
5663
)
64+
await rafraf(page)
5765
await browser.stop_tracing()
5866
with open(output_file, mode="r") as of:
5967
trace_json = json.load(of)

0 commit comments

Comments
 (0)