Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fec1320486 | ||
|
|
428c36aa30 | ||
|
|
9d66fd437a | ||
|
|
6d61df460a | ||
|
|
85ebef6698 | ||
|
|
6d1180499c | ||
|
|
8956035edc | ||
|
|
5b888467ed | ||
|
|
0e09ae57ee |
No files matched your search
@@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.49.1] - 2026-11-10
|
||||
|
||||
### Fixed
|
||||
- `page.request_gc()` works on a served browser. It sent the engine's `Heap.collectGarbage` on the
|
||||
browser-level connection, whose handler does not have it, so every call failed with
|
||||
`Handler for does not implement method "Heap.collectGarbage"`; it is now sent with the session
|
||||
of the page, as the engine answers it.
|
||||
|
||||
## [0.49.0] - 2026-11-10
|
||||
|
||||
### Changed
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "invisible_playwright"
|
||||
version = "0.49.0"
|
||||
version = "0.49.1"
|
||||
description = "Playwright wrapper for a patched Firefox with deterministic stealth profile."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.11"
|
||||
|
||||
@@ -3478,8 +3478,10 @@ class PageDispatcher(Dispatcher):
|
||||
"""⛔ `Heap.collectGarbage` really does collect, and it is SLOW - it was
|
||||
once used as a "bare command" to measure transport latency and reported
|
||||
26,8 ms of browser work as if it were ours. It is the right command
|
||||
here, and the wrong one to benchmark with."""
|
||||
self.conn.send("Heap.collectGarbage", {}, timeout=None)
|
||||
here, and the wrong one to benchmark with. Sent with this page's session
|
||||
(`self.send`): Juggler answers it from its PAGE handler, and the browser-level
|
||||
connection (`self.conn`) gets 'Handler for does not implement method'."""
|
||||
self.send("Heap.collectGarbage", {}, timeout=None)
|
||||
return None
|
||||
|
||||
def op_add_script_tag(self, params: Dict) -> Any:
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
"""`page.request_gc()` (Playwright's own API) reaches the engine, which answers it.
|
||||
|
||||
⛔ THE KNOWN-BAD INPUT, measured on a real engine: `Page.requestGC` was answered by `op_request_gc` with
|
||||
`Heap.collectGarbage` sent on the BROWSER connection, and Juggler's browser-level handler does not have it:
|
||||
`Page.request_gc: Heap.collectGarbage: Handler for does not implement method "Heap.collectGarbage"`, on every
|
||||
call. The command is a page command (`PageHandler`), so it goes with the session of the page.
|
||||
|
||||
No browser: the page dispatcher is built the way tests/test_navigation_*.py build one, with the two senders
|
||||
replaced by mocks.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
|
||||
from invisible_core.juggler.connection import EventListeners
|
||||
from invisible_core.juggler.lifecycle import Lifecycle
|
||||
from invisible_playwright._juggler.dispatcher import Dispatcher
|
||||
from invisible_playwright._juggler.server import (
|
||||
FrameDispatcher,
|
||||
JugglerServer,
|
||||
PageDispatcher,
|
||||
)
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
|
||||
def make_page(server):
|
||||
server.attach(SimpleNamespace(emit_message=lambda m: None))
|
||||
context = Dispatcher(server, None)
|
||||
context.options = {}
|
||||
page = object.__new__(PageDispatcher)
|
||||
page.context = context
|
||||
page.lifecycle = Lifecycle(EventListeners(), "session")
|
||||
page.injected = Mock()
|
||||
page.actions = Mock()
|
||||
page._frames = {}
|
||||
page._navigation_requests = {}
|
||||
page._announced_closed = False
|
||||
Dispatcher.__init__(page, server, context)
|
||||
page.frame = FrameDispatcher(server, page, "main")
|
||||
for fid, parent in (("main", None), ("sub", "main")):
|
||||
page.lifecycle._on_event("Page.frameAttached", {"frameId": fid, "parentFrameId": parent})
|
||||
return page
|
||||
|
||||
|
||||
def test_page_request_gc_is_sent_with_the_page_session_not_the_browser_connection():
|
||||
page = make_page(JugglerServer())
|
||||
page.send = Mock()
|
||||
page.context.browser = SimpleNamespace(conn=Mock())
|
||||
assert page.op_request_gc({}) is None
|
||||
page.send.assert_called_once_with("Heap.collectGarbage", {}, timeout=None)
|
||||
page.context.browser.conn.send.assert_not_called()
|
||||
|
||||
|
||||
def test_the_protocol_name_it_writes_is_the_one_the_engine_declares():
|
||||
from invisible_core.juggler.protocol import COMMANDS
|
||||
|
||||
assert "Heap.collectGarbage" in COMMANDS
|
||||
Reference in new issue
Block a user