Skip to content

Commit 3352d85

Browse files
authored
fix: hide page.route calls from traces (microsoft#2614)
1 parent 8cb44c5 commit 3352d85

File tree

6 files changed

+19
-14
lines changed

6 files changed

+19
-14
lines changed

playwright/_impl/_connection.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,18 @@ def __init__(self, connection: "Connection", object: "ChannelOwner") -> None:
5454
self._guid = object._guid
5555
self._object = object
5656
self.on("error", lambda exc: self._connection._on_event_listener_error(exc))
57+
self._is_internal_type = False
5758

5859
async def send(self, method: str, params: Dict = None) -> Any:
5960
return await self._connection.wrap_api_call(
60-
lambda: self.inner_send(method, params, False)
61+
lambda: self._inner_send(method, params, False),
62+
self._is_internal_type,
6163
)
6264

6365
async def send_return_as_dict(self, method: str, params: Dict = None) -> Any:
6466
return await self._connection.wrap_api_call(
65-
lambda: self.inner_send(method, params, True)
67+
lambda: self._inner_send(method, params, True),
68+
self._is_internal_type,
6669
)
6770

6871
def send_no_reply(self, method: str, params: Dict = None) -> None:
@@ -73,7 +76,7 @@ def send_no_reply(self, method: str, params: Dict = None) -> None:
7376
)
7477
)
7578

76-
async def inner_send(
79+
async def _inner_send(
7780
self, method: str, params: Optional[Dict], return_as_dict: bool
7881
) -> Any:
7982
if params is None:
@@ -108,6 +111,9 @@ async def inner_send(
108111
key = next(iter(result))
109112
return result[key]
110113

114+
def mark_as_internal_type(self) -> None:
115+
self._is_internal_type = True
116+
111117

112118
class ChannelOwner(AsyncIOEventEmitter):
113119
def __init__(
@@ -132,7 +138,6 @@ def __init__(
132138
self._channel: Channel = Channel(self._connection, self)
133139
self._initializer = initializer
134140
self._was_collected = False
135-
self._is_internal_type = False
136141

137142
self._connection._objects[guid] = self
138143
if self._parent:
@@ -157,9 +162,6 @@ def _adopt(self, child: "ChannelOwner") -> None:
157162
self._objects[child._guid] = child
158163
child._parent = self
159164

160-
def mark_as_internal_type(self) -> None:
161-
self._is_internal_type = True
162-
163165
def _set_event_to_subscription_mapping(self, mapping: Dict[str, str]) -> None:
164166
self._event_to_subscription_mapping = mapping
165167

@@ -359,7 +361,12 @@ def _send_message_to_server(
359361
"params": self._replace_channels_with_guids(params),
360362
"metadata": metadata,
361363
}
362-
if self._tracing_count > 0 and frames and not object._is_internal_type:
364+
if (
365+
self._tracing_count > 0
366+
and frames
367+
and frames
368+
and object._guid != "localUtils"
369+
):
363370
self.local_utils.add_stack_to_tracing_no_reply(id, frames)
364371

365372
self._transport.send(message)

playwright/_impl/_local_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(
2525
self, parent: ChannelOwner, type: str, guid: str, initializer: Dict
2626
) -> None:
2727
super().__init__(parent, type, guid, initializer)
28-
self.mark_as_internal_type()
28+
self._channel.mark_as_internal_type()
2929
self.devices = {
3030
device["name"]: parse_device_descriptor(device["descriptor"])
3131
for device in initializer["deviceDescriptors"]

playwright/_impl/_network.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def __init__(
317317
self, parent: ChannelOwner, type: str, guid: str, initializer: Dict
318318
) -> None:
319319
super().__init__(parent, type, guid, initializer)
320-
self.mark_as_internal_type()
320+
self._channel.mark_as_internal_type()
321321
self._handling_future: Optional[asyncio.Future["bool"]] = None
322322
self._context: "BrowserContext" = cast("BrowserContext", None)
323323
self._did_throw = False
@@ -603,7 +603,7 @@ def __init__(
603603
self, parent: ChannelOwner, type: str, guid: str, initializer: Dict
604604
) -> None:
605605
super().__init__(parent, type, guid, initializer)
606-
self.mark_as_internal_type()
606+
self._channel.mark_as_internal_type()
607607
self._on_page_message: Optional[Callable[[Union[str, bytes]], Any]] = None
608608
self._on_page_close: Optional[Callable[[Optional[int], Optional[str]], Any]] = (
609609
None

playwright/_impl/_tracing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(
2525
self, parent: ChannelOwner, type: str, guid: str, initializer: Dict
2626
) -> None:
2727
super().__init__(parent, type, guid, initializer)
28-
self.mark_as_internal_type()
28+
self._channel.mark_as_internal_type()
2929
self._include_sources: bool = False
3030
self._stacks_id: Optional[str] = None
3131
self._is_tracing: bool = False

tests/async/test_tracing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ async def test_should_collect_trace_with_resources_but_no_js(
119119
"Page.wait_for_timeout",
120120
"Page.route",
121121
"Page.goto",
122-
"Route.continue_",
123122
"Page.goto",
124123
"Page.close",
125124
]

tests/sync/test_tracing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ def test_should_collect_trace_with_resources_but_no_js(
112112
"Page.wait_for_timeout",
113113
"Page.route",
114114
"Page.goto",
115-
"Route.continue_",
116115
"Page.goto",
117116
"Page.close",
118117
]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy