browser-tools 0.6.0__tar.gz → 0.7.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {browser_tools-0.6.0 → browser_tools-0.7.1}/PKG-INFO +1 -1
- {browser_tools-0.6.0 → browser_tools-0.7.1}/pyproject.toml +1 -1
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/GUIDE.txt +54 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/cdp_handler.py +154 -9
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/cli.py +36 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/curated.py +52 -12
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/frame_manager.py +122 -13
- browser_tools-0.7.1/src/browser_tools/frame_sessions.py +401 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/step_list.py +12 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/step_run.py +4 -1
- browser_tools-0.7.1/tests/test_cross_origin_frames.py +156 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_curated_verbs.py +8 -1
- browser_tools-0.7.1/tests/test_error_prefix.py +71 -0
- browser_tools-0.7.1/tests/test_frame_session_discovery.py +321 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_interaction_targeting.py +8 -1
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_session_hygiene.py +117 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_shared_session.py +2 -2
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_step_run.py +50 -2
- {browser_tools-0.6.0 → browser_tools-0.7.1}/.gitignore +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/LICENSE +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/NOTICE +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/README.md +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/__init__.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/attached_session.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/camoufox_runner.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/cdp_client.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/cdp_constants.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/__init__.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/attach.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/cdp_client.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/connection.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/__init__.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/accessibility.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/animation.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/audits.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/autofill.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/background_service.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/bluetooth_emulation.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/browser.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/cache_storage.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/cast.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/console.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/css.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/debugger.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/device_access.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/device_orientation.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/dom.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/dom_debugger.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/dom_snapshot.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/dom_storage.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/emulation.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/event_breakpoints.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/extensions.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/fed_cm.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/fetch.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/file_system.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/headless_experimental.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/heap_profiler.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/indexed_db.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/input.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/inspector.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/io.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/layer_tree.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/log.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/media.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/memory.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/network.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/overlay.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/page.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/performance.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/performance_timeline.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/preload.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/profiler.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/pwa.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/runtime.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/schema.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/security.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/service_worker.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/smart_card_emulation.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/storage.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/system_info.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/target.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/tethering.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/tracing.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/web_audio.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/domains/web_authn.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/errors.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/fingerprint.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/instance_status.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/launcher.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/protocol.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/registry.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/supervisor.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/core/utils.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/detect_interstitial.js +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/endpoint.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/events.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/extras.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/interstitial.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/lifecycle.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/list_verbs.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/mcp_response.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/native_interaction.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/native_snapshot.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/one_shot.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/passthrough.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/process_utils.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/profiler.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/screencast.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/screenshot_utils.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/tool_registry.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/usage.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/src/browser_tools/user_settings.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/conftest.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/doubles.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/CORPUS.md +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/camoufox_session.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/conftest.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/fixtures/dynamic.html +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/fixtures/form.html +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/fixtures/iframe.html +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/fixtures/iframe_child.html +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/fixtures/plain.html +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/fixtures/shadow.html +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/live_chromium.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/node_broker.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/parity_comparison.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/parity_corpus.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/parity_engines.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/run_baseline.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/test_camoufox_live_launch.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/test_camoufox_session.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/test_e2e_camoufox.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/test_node_broker.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/test_parity_baseline.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/test_parity_corpus.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/test_parity_engine.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/test_parity_gate.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/test_parity_native.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/test_parity_native_interaction.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/parity/test_parity_operator.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_async_discovery.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_attached_session.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_cdp_client.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_cli_grammar.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_cli_lifecycle.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_cli_surface.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_core_launcher.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_core_send_timeout.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_detached_tasks.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_diagnostics_name_real_verbs.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_endpoint.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_events.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_frame_manager.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_guide.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_handler_transport.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_interstitial.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_list_verbs.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_native_backend.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_native_interaction.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_native_snapshot.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_new_tools.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_one_shot.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_packaging.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_passthrough.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_profile_liveness.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_profile_path_hardening.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_profile_root_move.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_profile_verbs.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_profiler.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_retained_contracts.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_step_dispatch.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_step_list.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_stop_target.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_supervisor_document_liveness.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_supervisor_never_pauses.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_supervisor_profile_preservation.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_supervisor_visibility.py +0 -0
- {browser_tools-0.6.0 → browser_tools-0.7.1}/tests/test_window_marking.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: browser-tools
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.1
|
|
4
4
|
Summary: Browser automation, debugging, and anti-detect browsing CLI
|
|
5
5
|
Project-URL: Homepage, https://github.com/dungle-scrubs/browser-tools
|
|
6
6
|
Project-URL: Repository, https://github.com/dungle-scrubs/browser-tools
|
|
@@ -160,6 +160,60 @@ CURATED VERBS
|
|
|
160
160
|
Inspect and select page frames. PATTERN is a frame URL substring. Any
|
|
161
161
|
other sub-action is a usage error (exit 2).
|
|
162
162
|
|
|
163
|
+
SAME-PROCESS FRAMES ONLY, unless you pass --frames all. A cross-origin
|
|
164
|
+
iframe runs in its own renderer process under Chrome's site isolation,
|
|
165
|
+
with its own CDP target. By default it is absent from `frames list`,
|
|
166
|
+
`frames select` cannot select it, and `snapshot` shows the Iframe node
|
|
167
|
+
with nothing under it. `--target` does not reach it either: only page
|
|
168
|
+
targets are attachable. Logins, payment forms and consent banners are
|
|
169
|
+
usually cross-origin iframes, so this is the common case rather than
|
|
170
|
+
the exotic one. `frames select` says so when it can tell that is what
|
|
171
|
+
happened.
|
|
172
|
+
|
|
173
|
+
--frames page | --frames all
|
|
174
|
+
Which frames `frames list` and `frames select` can see. Default `page`,
|
|
175
|
+
which is the behaviour above. `all` attaches to each cross-origin
|
|
176
|
+
iframe as well and splices its frames into the one tree.
|
|
177
|
+
|
|
178
|
+
READ THIS BEFORE YOU USE IT. Today the flag does exactly two things:
|
|
179
|
+
it lists cross-origin iframes, and it lets you select one. NOTHING
|
|
180
|
+
READS FROM THE FRAME YOU SELECT. A cross-origin iframe has no
|
|
181
|
+
execution context in this tool yet, so:
|
|
182
|
+
|
|
183
|
+
storage get returns cookies only, with no localStorage and
|
|
184
|
+
no sessionStorage, and exits 0
|
|
185
|
+
snapshot still prints the Iframe node with nothing under
|
|
186
|
+
it, so there is no uid inside the frame
|
|
187
|
+
click, fill have no uid to address, so they cannot reach it
|
|
188
|
+
|
|
189
|
+
Routing a read to the frame's own session is the next phase of the
|
|
190
|
+
work (RFC-04, Decisions 4 and 5) and is not built. Until it is, drive
|
|
191
|
+
the iframe's URL as a page of its own when you need to read or click
|
|
192
|
+
inside it.
|
|
193
|
+
|
|
194
|
+
What the flag is good for today is finding out what is there: which
|
|
195
|
+
cross-origin iframes the page has, their URLs, and where they sit in
|
|
196
|
+
the tree.
|
|
197
|
+
|
|
198
|
+
`frames list --frames all` marks a frame in another process
|
|
199
|
+
[out-of-process]. A frame past a bound is listed [unreachable] with its
|
|
200
|
+
URL rather than dropped, so a frame you cannot reach is still a row you
|
|
201
|
+
can see. The bounds are 32 frame sessions and 10 levels of nesting.
|
|
202
|
+
|
|
203
|
+
Accepted by `frames list`, `frames select`, `frames reset`, `storage
|
|
204
|
+
get`, `snapshot`, `click`, `fill`, and `run`, where it covers every
|
|
205
|
+
step of the run. The last four accept it so that a run can carry one
|
|
206
|
+
flag throughout; it does not make them see into the frame.
|
|
207
|
+
|
|
208
|
+
Off by default because it is opt-in for this release, not because it
|
|
209
|
+
costs much: measured over 9 runs each on a page with twenty sibling
|
|
210
|
+
cross-origin iframes, `frames list` took 109.2 ms by default and
|
|
211
|
+
119.7 ms with --frames all. On a page with no cross-origin iframe the
|
|
212
|
+
flag costs one CDP round trip, about 8 ms.
|
|
213
|
+
|
|
214
|
+
It does not change `screenshot` or `screencast`. Neither is
|
|
215
|
+
frame-scoped; both capture the page, with or without the flag.
|
|
216
|
+
|
|
163
217
|
storage get [--key K]
|
|
164
218
|
The selected frame's storage. --key is a frame URL pattern to select
|
|
165
219
|
before reading. It is NOT a cookie name or a local-storage key. Without
|
|
@@ -338,6 +338,8 @@ class CDPRuntime:
|
|
|
338
338
|
#: Rebound rather than mutated, so the class-level default cannot be
|
|
339
339
|
#: shared by two runtimes built without `__init__`.
|
|
340
340
|
_caller_enabled: frozenset[str] = frozenset()
|
|
341
|
+
_all_frames: bool = False
|
|
342
|
+
_frame_sessions: Any = None
|
|
341
343
|
|
|
342
344
|
def __init__(
|
|
343
345
|
self,
|
|
@@ -346,6 +348,7 @@ class CDPRuntime:
|
|
|
346
348
|
stealth: bool = False,
|
|
347
349
|
target_spec: str | None = None,
|
|
348
350
|
target_by: str | None = None,
|
|
351
|
+
all_frames: bool = False,
|
|
349
352
|
) -> None:
|
|
350
353
|
"""Initialize the CDP runtime.
|
|
351
354
|
|
|
@@ -367,6 +370,11 @@ class CDPRuntime:
|
|
|
367
370
|
self._stealth = stealth
|
|
368
371
|
self._target_spec = target_spec
|
|
369
372
|
self._target_by = target_by
|
|
373
|
+
# RFC-04, Decision 8: off unless the caller asked for it. A cross-
|
|
374
|
+
# origin iframe is reached only with `--frames all`, for the first
|
|
375
|
+
# release, because the correctness work behind it is new.
|
|
376
|
+
self._all_frames = all_frames
|
|
377
|
+
self._frame_sessions: Any = None
|
|
370
378
|
self._loop: asyncio.AbstractEventLoop | None = None
|
|
371
379
|
self._ready = threading.Event()
|
|
372
380
|
self._stop_event: asyncio.Event | None = None
|
|
@@ -390,8 +398,23 @@ class CDPRuntime:
|
|
|
390
398
|
|
|
391
399
|
@property
|
|
392
400
|
def available(self) -> bool:
|
|
393
|
-
"""Whether the CDP client is connected and
|
|
394
|
-
|
|
401
|
+
"""Whether the CDP client is connected and setup has finished.
|
|
402
|
+
|
|
403
|
+
`_ready` is the second half, and it is not decoration. The caller in
|
|
404
|
+
`curated._cdp_handler_session` polls this property to decide the
|
|
405
|
+
invocation may start, and `_connect_cdp` assigns `_cdp_client` as its
|
|
406
|
+
first statement - before `Page.enable`, before the frame tree, before
|
|
407
|
+
`Runtime.enable`, before Frame Sessions. Without `_ready` the poll
|
|
408
|
+
returns true in the gap and the verb runs against a half-built map.
|
|
409
|
+
|
|
410
|
+
It stayed hidden because the poll sleeps 20 ms and setup usually
|
|
411
|
+
beats it. Setup that does more does not: on a page with twenty
|
|
412
|
+
cross-origin iframes, `frames list --frames all` returned 20, then
|
|
413
|
+
8, then 20, then 4 out-of-process frames over consecutive identical
|
|
414
|
+
runs, each answer being however much of the map existed when the
|
|
415
|
+
read won the race.
|
|
416
|
+
"""
|
|
417
|
+
return self._cdp_client is not None and self._cdp_client.connected and self._ready.is_set()
|
|
395
418
|
|
|
396
419
|
@property
|
|
397
420
|
def connect_error(self) -> str | None:
|
|
@@ -420,6 +443,15 @@ class CDPRuntime:
|
|
|
420
443
|
"""
|
|
421
444
|
return self._deadline
|
|
422
445
|
|
|
446
|
+
@property
|
|
447
|
+
def frame_sessions(self) -> Any:
|
|
448
|
+
"""Every Frame Session below the page session (RFC-04).
|
|
449
|
+
|
|
450
|
+
``None`` when the caller did not ask for them with ``--frames all``,
|
|
451
|
+
and when the browser refused ``Target.setAutoAttach``.
|
|
452
|
+
"""
|
|
453
|
+
return self._frame_sessions
|
|
454
|
+
|
|
423
455
|
@property
|
|
424
456
|
def caller_enabled(self) -> frozenset[str]:
|
|
425
457
|
"""Domains a raw step in this run turned on by hand.
|
|
@@ -466,7 +498,14 @@ class CDPRuntime:
|
|
|
466
498
|
# it unwinds could run four graces past a deadline the caller set.
|
|
467
499
|
if self._grace_until is None:
|
|
468
500
|
self._grace_until = now + DEADLINE_GRACE_SECONDS
|
|
469
|
-
|
|
501
|
+
# Clamped to the grace itself, not just derived from it. `now + g - now`
|
|
502
|
+
# is not exactly `g` in binary floating point once `time.monotonic()`
|
|
503
|
+
# is large: on a CI runner the first call after the deadline came back
|
|
504
|
+
# with 5.000000000000014 against a grace of 5.0. The excess cannot
|
|
505
|
+
# matter to a timeout, but "no call gets more than one grace" is the
|
|
506
|
+
# rule this method exists to enforce, and a rule that holds to within
|
|
507
|
+
# a rounding error is a different rule.
|
|
508
|
+
left = min(self._grace_until - now, DEADLINE_GRACE_SECONDS)
|
|
470
509
|
# Never zero. A call given no time at all fails before it is sent, and
|
|
471
510
|
# then the teardown this grace exists for does not happen either.
|
|
472
511
|
return max(left, TEARDOWN_FLOOR_SECONDS)
|
|
@@ -680,11 +719,51 @@ class CDPRuntime:
|
|
|
680
719
|
self._frame_manager.handle_execution_contexts_cleared,
|
|
681
720
|
)
|
|
682
721
|
await self._cdp_client.send("Runtime.enable")
|
|
722
|
+
|
|
723
|
+
# RFC-04. Last, and only when asked: a page with no cross-origin
|
|
724
|
+
# iframe pays nothing, and a failure here must not cost the
|
|
725
|
+
# caller the page session that is already working.
|
|
726
|
+
if self._all_frames:
|
|
727
|
+
await self._start_frame_sessions(cdp, session_id)
|
|
728
|
+
|
|
729
|
+
# Setup is over, so the invocation may start. Set here rather
|
|
730
|
+
# than in `_main`, because this is the method that finishes the
|
|
731
|
+
# work `available` promises has been done, and it is also called
|
|
732
|
+
# on its own.
|
|
733
|
+
self._ready.set()
|
|
683
734
|
except Exception as exc:
|
|
684
735
|
self._connect_error = str(exc)
|
|
685
736
|
logger.exception("CDP session setup failed for %s", self._browser_url)
|
|
686
737
|
self._cdp_client = None
|
|
687
738
|
|
|
739
|
+
async def _start_frame_sessions(self, cdp: Any, session_id: str) -> None:
|
|
740
|
+
"""Turn auto-attach on, or carry on without it.
|
|
741
|
+
|
|
742
|
+
A browser that refuses `Target.setAutoAttach` leaves the page session
|
|
743
|
+
exactly as it was, and `frames select` keeps the diagnosis that says
|
|
744
|
+
a cross-origin iframe is out of reach. That is a worse answer than
|
|
745
|
+
reaching the frame and a much better one than no page at all.
|
|
746
|
+
"""
|
|
747
|
+
from .frame_sessions import FrameSessions
|
|
748
|
+
|
|
749
|
+
try:
|
|
750
|
+
# Which target this session is attached to. `one_shot_page_session`
|
|
751
|
+
# knows it and yields `(cdp, session_id)`, a shape six callers
|
|
752
|
+
# unpack, so it is asked for here rather than threaded through all
|
|
753
|
+
# of them. One round trip, on the opt-in path only.
|
|
754
|
+
info = await cdp.send(method="Target.getTargetInfo", session_id=session_id)
|
|
755
|
+
target_id = (info.get("targetInfo") or {}).get("targetId", "")
|
|
756
|
+
sessions = FrameSessions(cdp, self._frame_manager, session_id, target_id)
|
|
757
|
+
await sessions.start()
|
|
758
|
+
self._frame_sessions = sessions
|
|
759
|
+
# Discovery before the invocation reports itself ready. Without
|
|
760
|
+
# this, `frames select` on an Out-of-Process Frame races the
|
|
761
|
+
# splice and fails against a tree the child is not in yet.
|
|
762
|
+
await sessions.settle()
|
|
763
|
+
except Exception as exc:
|
|
764
|
+
logger.debug("auto-attach unavailable, driving the page session alone: %s", exc)
|
|
765
|
+
self._frame_sessions = None
|
|
766
|
+
|
|
688
767
|
def stop(self) -> None:
|
|
689
768
|
"""Signal the background loop to stop."""
|
|
690
769
|
if self._loop and self._stop_event:
|
|
@@ -836,6 +915,7 @@ class CDPHandler:
|
|
|
836
915
|
stealth: bool = False,
|
|
837
916
|
target_spec: str | None = None,
|
|
838
917
|
target_by: str | None = None,
|
|
918
|
+
all_frames: bool = False,
|
|
839
919
|
) -> None:
|
|
840
920
|
"""Initialize the handler registry over a fresh CDP runtime.
|
|
841
921
|
|
|
@@ -847,7 +927,12 @@ class CDPHandler:
|
|
|
847
927
|
target_spec: Which page to attach to; see :class:`CDPRuntime`.
|
|
848
928
|
"""
|
|
849
929
|
self._rt = CDPRuntime(
|
|
850
|
-
browser_url,
|
|
930
|
+
browser_url,
|
|
931
|
+
mode,
|
|
932
|
+
stealth=stealth,
|
|
933
|
+
target_spec=target_spec,
|
|
934
|
+
target_by=target_by,
|
|
935
|
+
all_frames=all_frames,
|
|
851
936
|
)
|
|
852
937
|
# Tool name -> bound handler. Built from the class-level _CDP_HANDLERS
|
|
853
938
|
# table, which is parity-checked against tool_registry.CDP_TOOLS above.
|
|
@@ -893,6 +978,11 @@ class CDPHandler:
|
|
|
893
978
|
"""Domains a raw step turned on by hand; see :attr:`CDPRuntime.caller_enabled`."""
|
|
894
979
|
return self._rt.caller_enabled
|
|
895
980
|
|
|
981
|
+
@property
|
|
982
|
+
def frame_sessions(self) -> Any:
|
|
983
|
+
"""The Frame Sessions below the page session; see :class:`CDPRuntime`."""
|
|
984
|
+
return self._rt.frame_sessions
|
|
985
|
+
|
|
896
986
|
def record_caller_enable(self, method: str) -> None:
|
|
897
987
|
"""See :meth:`CDPRuntime.record_caller_enable`."""
|
|
898
988
|
self._rt.record_caller_enable(method)
|
|
@@ -1136,7 +1226,18 @@ class CDPHandler:
|
|
|
1136
1226
|
indent = " " * frame["depth"]
|
|
1137
1227
|
selected = " [selected]" if frame["frameId"] == fm.selected_frame_id else ""
|
|
1138
1228
|
name = f' name="{frame["name"]}"' if frame.get("name") else ""
|
|
1139
|
-
|
|
1229
|
+
# A frame answered by its own session is out-of-process. Say so:
|
|
1230
|
+
# it is why its UIDs come from a different document, and why it is
|
|
1231
|
+
# absent altogether without `--frames all` (RFC-04).
|
|
1232
|
+
oopif = " [out-of-process]" if frame.get("frameSessionId") else ""
|
|
1233
|
+
lines.append(f"{indent}{frame['frameId']}: {frame['url']}{name}{oopif}{selected}")
|
|
1234
|
+
|
|
1235
|
+
# A frame a bound refused is listed and marked, never silently
|
|
1236
|
+
# dropped: a caller who cannot see it cannot ask why it is missing.
|
|
1237
|
+
sessions = self._rt.frame_sessions
|
|
1238
|
+
if sessions is not None:
|
|
1239
|
+
for target_id, url in sessions.unreachable.items():
|
|
1240
|
+
lines.append(f" {target_id}: {url or '(url unknown)'} [unreachable]")
|
|
1140
1241
|
return make_text("\n".join(lines))
|
|
1141
1242
|
|
|
1142
1243
|
async def _handle_select_frame(self, arguments: dict[str, Any]) -> dict[str, Any]:
|
|
@@ -1151,10 +1252,7 @@ class CDPHandler:
|
|
|
1151
1252
|
|
|
1152
1253
|
frame = fm.select_frame_by_url(url_pattern)
|
|
1153
1254
|
if frame is None:
|
|
1154
|
-
return make_error(
|
|
1155
|
-
f"E002: No frame found matching '{url_pattern}'. "
|
|
1156
|
-
"Run 'frames list' to see available frames."
|
|
1157
|
-
)
|
|
1255
|
+
return make_error(await self._no_frame_matched(url_pattern))
|
|
1158
1256
|
|
|
1159
1257
|
ctx_id = fm.get_selected_execution_context_id()
|
|
1160
1258
|
ctx_info = f", executionContextId={ctx_id}" if ctx_id else " (no execution context yet)"
|
|
@@ -1164,6 +1262,53 @@ class CDPHandler:
|
|
|
1164
1262
|
f"Origin: {frame.security_origin}{ctx_info}"
|
|
1165
1263
|
)
|
|
1166
1264
|
|
|
1265
|
+
async def _out_of_process_frames(self, url_pattern: str) -> list[str]:
|
|
1266
|
+
"""URLs of `iframe` targets matching the pattern, newest first.
|
|
1267
|
+
|
|
1268
|
+
A cross-origin iframe runs in its own renderer process under Chrome's
|
|
1269
|
+
site isolation, which gives it its own CDP target. It is not in
|
|
1270
|
+
`Page.getFrameTree` on the page session and its lifecycle events do
|
|
1271
|
+
not arrive there, so the frame manager cannot see it at all.
|
|
1272
|
+
|
|
1273
|
+
Asking the browser is the only way to tell "no such frame" apart from
|
|
1274
|
+
"a frame this tool cannot reach". The call is on the failure path
|
|
1275
|
+
only, and a browser that will not answer it leaves the caller with
|
|
1276
|
+
the plain message rather than an error about the diagnosis.
|
|
1277
|
+
"""
|
|
1278
|
+
cdp = self._cdp_client
|
|
1279
|
+
if cdp is None or not cdp.connected:
|
|
1280
|
+
return []
|
|
1281
|
+
try:
|
|
1282
|
+
result = await cdp.send(method="Target.getTargets")
|
|
1283
|
+
except (_get_cdp_error_class(), ConnectionError, TimeoutError, OSError):
|
|
1284
|
+
return []
|
|
1285
|
+
lowered = url_pattern.lower()
|
|
1286
|
+
return [
|
|
1287
|
+
info.get("url", "")
|
|
1288
|
+
for info in result.get("targetInfos", [])
|
|
1289
|
+
if info.get("type") == "iframe" and lowered in info.get("url", "").lower()
|
|
1290
|
+
]
|
|
1291
|
+
|
|
1292
|
+
async def _no_frame_matched(self, url_pattern: str) -> str:
|
|
1293
|
+
"""Why no frame matched, saying which of the two reasons it was."""
|
|
1294
|
+
out_of_process = await self._out_of_process_frames(url_pattern)
|
|
1295
|
+
if not out_of_process:
|
|
1296
|
+
return (
|
|
1297
|
+
f"E002: No frame found matching '{url_pattern}'. "
|
|
1298
|
+
"Run 'frames list' to see available frames."
|
|
1299
|
+
)
|
|
1300
|
+
listed = ", ".join(out_of_process[:3])
|
|
1301
|
+
return (
|
|
1302
|
+
f"E002: No frame found matching '{url_pattern}'. The browser has "
|
|
1303
|
+
f"a cross-origin iframe at {listed}, and this tool cannot reach "
|
|
1304
|
+
"it: site isolation puts it in its own process with its own CDP "
|
|
1305
|
+
"target, so it is absent from 'frames list' and 'snapshot' shows "
|
|
1306
|
+
"the Iframe node with nothing under it. There is no flag for "
|
|
1307
|
+
"this yet and --target does not reach it either. Drive the "
|
|
1308
|
+
"iframe's URL as a page instead, or work above it. See "
|
|
1309
|
+
"https://github.com/dungle-scrubs/browser-tools/issues/127."
|
|
1310
|
+
)
|
|
1311
|
+
|
|
1167
1312
|
async def _handle_reset_frame(self, arguments: dict[str, Any]) -> dict[str, Any]:
|
|
1168
1313
|
"""Handle reset_frame tool."""
|
|
1169
1314
|
fm = self._frame_manager
|
|
@@ -89,6 +89,27 @@ def _add_endpoint(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
|
|
|
89
89
|
return parser
|
|
90
90
|
|
|
91
91
|
|
|
92
|
+
#: What `--frames all` buys, in one line for `--help`.
|
|
93
|
+
FRAMES_HELP = (
|
|
94
|
+
"'all' also reaches cross-origin iframes, which run in their own process "
|
|
95
|
+
"and are otherwise invisible to frames list, frames select and snapshot. "
|
|
96
|
+
"Default 'page': same-process frames only."
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _add_frames(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
|
|
101
|
+
"""Give one frame-reading verb the ``--frames`` flag (RFC-04).
|
|
102
|
+
|
|
103
|
+
Off by default for this release. Reaching an Out-of-Process Frame opens a
|
|
104
|
+
CDP session per frame, and that lifecycle is new, so a caller asks for it
|
|
105
|
+
rather than every invocation paying for it.
|
|
106
|
+
"""
|
|
107
|
+
parser.add_argument(
|
|
108
|
+
"--frames", choices=("page", "all"), default="page", metavar="SCOPE", help=FRAMES_HELP
|
|
109
|
+
)
|
|
110
|
+
return parser
|
|
111
|
+
|
|
112
|
+
|
|
92
113
|
def _installed_version() -> str:
|
|
93
114
|
"""The running build's version, read from the installed distribution.
|
|
94
115
|
|
|
@@ -319,6 +340,7 @@ def _add_run_verb(
|
|
|
319
340
|
"--url", metavar="SUBSTRING", help="Select the page target by URL substring"
|
|
320
341
|
)
|
|
321
342
|
_add_endpoint(run_parser)
|
|
343
|
+
_add_frames(run_parser)
|
|
322
344
|
|
|
323
345
|
|
|
324
346
|
def _add_curated_verbs(
|
|
@@ -341,6 +363,7 @@ def _add_curated_verbs(
|
|
|
341
363
|
"--target", metavar="SPEC", help="Select the page target (1-based index or id)"
|
|
342
364
|
)
|
|
343
365
|
_add_endpoint(snapshot)
|
|
366
|
+
_add_frames(snapshot)
|
|
344
367
|
|
|
345
368
|
click = sub.add_parser("click", help="Native UID click")
|
|
346
369
|
click.add_argument(
|
|
@@ -351,6 +374,7 @@ def _add_curated_verbs(
|
|
|
351
374
|
"--target", metavar="SPEC", help="Select the page target (1-based index or id)"
|
|
352
375
|
)
|
|
353
376
|
_add_endpoint(click)
|
|
377
|
+
_add_frames(click)
|
|
354
378
|
|
|
355
379
|
fill = sub.add_parser("fill", help="Native UID fill")
|
|
356
380
|
fill.add_argument("instance", nargs="?", metavar="INSTANCE", help="Instance (omit if only one)")
|
|
@@ -360,6 +384,7 @@ def _add_curated_verbs(
|
|
|
360
384
|
"--target", metavar="SPEC", help="Select the page target (1-based index or id)"
|
|
361
385
|
)
|
|
362
386
|
_add_endpoint(fill)
|
|
387
|
+
_add_frames(fill)
|
|
363
388
|
|
|
364
389
|
wait_idle = sub.add_parser("wait-idle", help="Wait for network idle")
|
|
365
390
|
wait_idle.add_argument(
|
|
@@ -428,13 +453,16 @@ def _add_curated_verbs(
|
|
|
428
453
|
fl = frames_sub.add_parser("list", help="List frames")
|
|
429
454
|
fl.set_defaults(instance=None)
|
|
430
455
|
_add_endpoint(fl)
|
|
456
|
+
_add_frames(fl)
|
|
431
457
|
fs = frames_sub.add_parser("select", help="Select a frame by URL pattern")
|
|
432
458
|
fs.add_argument("pattern", metavar="PATTERN", help="Frame URL substring/pattern")
|
|
433
459
|
fs.set_defaults(instance=None)
|
|
434
460
|
_add_endpoint(fs)
|
|
461
|
+
_add_frames(fs)
|
|
435
462
|
fr = frames_sub.add_parser("reset", help="Clear frame selection")
|
|
436
463
|
fr.set_defaults(instance=None)
|
|
437
464
|
_add_endpoint(fr)
|
|
465
|
+
_add_frames(fr)
|
|
438
466
|
|
|
439
467
|
storage = sub.add_parser("storage", help="Read a frame's storage")
|
|
440
468
|
storage_sub = storage.add_subparsers(dest="storage_action", metavar="ACTION")
|
|
@@ -442,6 +470,7 @@ def _add_curated_verbs(
|
|
|
442
470
|
sg.add_argument("--key", metavar="K", help="Frame URL pattern to select before reading")
|
|
443
471
|
sg.set_defaults(instance=None)
|
|
444
472
|
_add_endpoint(sg)
|
|
473
|
+
_add_frames(sg)
|
|
445
474
|
|
|
446
475
|
screenshot = sub.add_parser("screenshot", help="Capture a page screenshot")
|
|
447
476
|
screenshot.add_argument(
|
|
@@ -750,6 +779,7 @@ def _run_step_list(args: argparse.Namespace, registry_path: str | None) -> int:
|
|
|
750
779
|
url=args.url,
|
|
751
780
|
registry_path=registry_path,
|
|
752
781
|
endpoint=args.endpoint,
|
|
782
|
+
all_frames=getattr(args, "frames", "page") == "all",
|
|
753
783
|
)
|
|
754
784
|
_print_json(document)
|
|
755
785
|
if succeeded:
|
|
@@ -849,6 +879,7 @@ def _curated_envelope(
|
|
|
849
879
|
registry_path=registry_path,
|
|
850
880
|
endpoint=args.endpoint,
|
|
851
881
|
handler=handler,
|
|
882
|
+
all_frames=getattr(args, "frames", "page") == "all",
|
|
852
883
|
)
|
|
853
884
|
|
|
854
885
|
if args.command == "click":
|
|
@@ -859,6 +890,7 @@ def _curated_envelope(
|
|
|
859
890
|
registry_path=registry_path,
|
|
860
891
|
endpoint=args.endpoint,
|
|
861
892
|
handler=handler,
|
|
893
|
+
all_frames=getattr(args, "frames", "page") == "all",
|
|
862
894
|
)
|
|
863
895
|
|
|
864
896
|
if args.command == "fill":
|
|
@@ -870,6 +902,7 @@ def _curated_envelope(
|
|
|
870
902
|
registry_path=registry_path,
|
|
871
903
|
endpoint=args.endpoint,
|
|
872
904
|
handler=handler,
|
|
905
|
+
all_frames=getattr(args, "frames", "page") == "all",
|
|
873
906
|
)
|
|
874
907
|
|
|
875
908
|
if args.command == "wait-idle":
|
|
@@ -912,6 +945,7 @@ def _curated_envelope(
|
|
|
912
945
|
registry_path=registry_path,
|
|
913
946
|
endpoint=args.endpoint,
|
|
914
947
|
handler=handler,
|
|
948
|
+
all_frames=getattr(args, "frames", "page") == "all",
|
|
915
949
|
)
|
|
916
950
|
|
|
917
951
|
if args.command == "screenshot":
|
|
@@ -953,6 +987,7 @@ def _frames_envelope(
|
|
|
953
987
|
registry_path=registry_path,
|
|
954
988
|
endpoint=args.endpoint,
|
|
955
989
|
handler=handler,
|
|
990
|
+
all_frames=getattr(args, "frames", "page") == "all",
|
|
956
991
|
)
|
|
957
992
|
if action == "select":
|
|
958
993
|
return curated.frames_select(
|
|
@@ -961,6 +996,7 @@ def _frames_envelope(
|
|
|
961
996
|
registry_path=registry_path,
|
|
962
997
|
endpoint=args.endpoint,
|
|
963
998
|
handler=handler,
|
|
999
|
+
all_frames=getattr(args, "frames", "page") == "all",
|
|
964
1000
|
)
|
|
965
1001
|
if action == "reset":
|
|
966
1002
|
return curated.frames_reset(
|
|
@@ -144,6 +144,7 @@ def run_session(
|
|
|
144
144
|
url: str | None,
|
|
145
145
|
registry_path: str | None,
|
|
146
146
|
endpoint: str | None,
|
|
147
|
+
all_frames: bool = False,
|
|
147
148
|
) -> Generator[CDPHandler]:
|
|
148
149
|
"""The one session a Step Run holds for all of its steps.
|
|
149
150
|
|
|
@@ -153,7 +154,9 @@ def run_session(
|
|
|
153
154
|
"""
|
|
154
155
|
spec, by = target_selector(target, url)
|
|
155
156
|
port = _resolve_port(instance, registry_path, endpoint)
|
|
156
|
-
with _cdp_handler_session(
|
|
157
|
+
with _cdp_handler_session(
|
|
158
|
+
port, spec, by, external=endpoint is not None, all_frames=all_frames
|
|
159
|
+
) as handler:
|
|
157
160
|
yield handler
|
|
158
161
|
|
|
159
162
|
|
|
@@ -165,6 +168,7 @@ def _handler_for(
|
|
|
165
168
|
target: str | None,
|
|
166
169
|
registry_path: str | None,
|
|
167
170
|
endpoint: str | None,
|
|
171
|
+
all_frames: bool = False,
|
|
168
172
|
) -> Generator[CDPHandler]:
|
|
169
173
|
"""Yield the session this verb runs on, opening one only if it must.
|
|
170
174
|
|
|
@@ -178,7 +182,9 @@ def _handler_for(
|
|
|
178
182
|
yield handler
|
|
179
183
|
return
|
|
180
184
|
port = _resolve_port(instance, registry_path, endpoint)
|
|
181
|
-
with _cdp_handler_session(
|
|
185
|
+
with _cdp_handler_session(
|
|
186
|
+
port, target, external=endpoint is not None, all_frames=all_frames
|
|
187
|
+
) as opened:
|
|
182
188
|
yield opened
|
|
183
189
|
|
|
184
190
|
|
|
@@ -189,6 +195,7 @@ def _cdp_handler_session(
|
|
|
189
195
|
target_by: str | None = None,
|
|
190
196
|
*,
|
|
191
197
|
external: bool = False,
|
|
198
|
+
all_frames: bool = False,
|
|
192
199
|
) -> Generator[CDPHandler]:
|
|
193
200
|
"""Yield a connected one-shot :class:`CDPHandler`, then tear it down.
|
|
194
201
|
|
|
@@ -208,7 +215,11 @@ def _cdp_handler_session(
|
|
|
208
215
|
look the browser up in (#97).
|
|
209
216
|
"""
|
|
210
217
|
handler = CDPHandler(
|
|
211
|
-
f"http://127.0.0.1:{port}",
|
|
218
|
+
f"http://127.0.0.1:{port}",
|
|
219
|
+
mode="full",
|
|
220
|
+
target_spec=target_spec,
|
|
221
|
+
target_by=target_by,
|
|
222
|
+
all_frames=all_frames,
|
|
212
223
|
)
|
|
213
224
|
thread = threading.Thread(target=handler.run, name="curated-cdp", daemon=True)
|
|
214
225
|
thread.start()
|
|
@@ -260,11 +271,33 @@ def _envelope_text(resp: dict[str, Any]) -> tuple[str, bool]:
|
|
|
260
271
|
return text, is_error
|
|
261
272
|
|
|
262
273
|
|
|
274
|
+
#: The envelope's own error prefix, which the CLI front replaces with its own.
|
|
275
|
+
_ENVELOPE_ERROR_PREFIX = "Error: "
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
def _reason(text: str) -> str:
|
|
279
|
+
"""The envelope's error text, without the prefix the CLI adds back.
|
|
280
|
+
|
|
281
|
+
`mcp_response.make_error` prefixes `Error: ` for a daemon socket that no
|
|
282
|
+
longer exists (RFC-01 deleted the MCP front), and `cli.py` prefixes
|
|
283
|
+
`error: ` on the way to stderr. Together they printed
|
|
284
|
+
`error: Error: E002: ...`. Only one prefix belongs to the CLI, and it is
|
|
285
|
+
the CLI's.
|
|
286
|
+
|
|
287
|
+
Stripped here rather than at the print, because this is where envelope
|
|
288
|
+
text becomes an exception message and the message is what every caller
|
|
289
|
+
then reads. A message that carries no prefix is returned unchanged, so
|
|
290
|
+
the diagnostics that write their own wording through `error_response`
|
|
291
|
+
are untouched.
|
|
292
|
+
"""
|
|
293
|
+
return text[len(_ENVELOPE_ERROR_PREFIX):] if text.startswith(_ENVELOPE_ERROR_PREFIX) else text
|
|
294
|
+
|
|
295
|
+
|
|
263
296
|
def _tool_or_raise(handler: CDPHandler, name: str, arguments: dict[str, Any]) -> str:
|
|
264
297
|
"""Run a CDP tool through the handler; raise ``LifecycleError`` on tool error."""
|
|
265
298
|
text, is_error = _envelope_text(handler.call_tool(name, arguments))
|
|
266
299
|
if is_error:
|
|
267
|
-
raise LifecycleError(text)
|
|
300
|
+
raise LifecycleError(_reason(text))
|
|
268
301
|
return text
|
|
269
302
|
|
|
270
303
|
|
|
@@ -272,7 +305,7 @@ def _native_or_raise(handler: CDPHandler, name: str, arguments: dict[str, Any])
|
|
|
272
305
|
"""Run a native tool through the handler; raise ``LifecycleError`` on tool error."""
|
|
273
306
|
text, is_error = _envelope_text(handler.call_native(name, arguments))
|
|
274
307
|
if is_error:
|
|
275
|
-
raise LifecycleError(text)
|
|
308
|
+
raise LifecycleError(_reason(text))
|
|
276
309
|
return text
|
|
277
310
|
|
|
278
311
|
|
|
@@ -305,6 +338,7 @@ def snapshot(
|
|
|
305
338
|
registry_path: str | None = None,
|
|
306
339
|
endpoint: str | None = None,
|
|
307
340
|
handler: CDPHandler | None = None,
|
|
341
|
+
all_frames: bool = False,
|
|
308
342
|
) -> dict[str, Any]:
|
|
309
343
|
"""Return the native UID accessibility tree (frozen ``take_snapshot``).
|
|
310
344
|
|
|
@@ -312,7 +346,7 @@ def snapshot(
|
|
|
312
346
|
not focus-guarded. ``target`` selects the page whose UIDs are returned,
|
|
313
347
|
which is what makes those UIDs usable with ``click --target``.
|
|
314
348
|
"""
|
|
315
|
-
with _handler_for(handler, instance, target, registry_path, endpoint) as handler:
|
|
349
|
+
with _handler_for(handler, instance, target, registry_path, endpoint, all_frames) as handler:
|
|
316
350
|
tree = _native_or_raise(handler, "take_snapshot", {})
|
|
317
351
|
return {"snapshot": tree}
|
|
318
352
|
|
|
@@ -325,6 +359,7 @@ def click(
|
|
|
325
359
|
registry_path: str | None = None,
|
|
326
360
|
endpoint: str | None = None,
|
|
327
361
|
handler: CDPHandler | None = None,
|
|
362
|
+
all_frames: bool = False,
|
|
328
363
|
) -> dict[str, Any]:
|
|
329
364
|
"""Native UID click (frozen ``click``), over the #40 interaction path.
|
|
330
365
|
|
|
@@ -334,7 +369,7 @@ def click(
|
|
|
334
369
|
check unable to fire: it was always "current", so a UID from a different
|
|
335
370
|
tree resolved against it by ordinal and named whatever now sat there.
|
|
336
371
|
"""
|
|
337
|
-
with _handler_for(handler, instance, target, registry_path, endpoint) as handler:
|
|
372
|
+
with _handler_for(handler, instance, target, registry_path, endpoint, all_frames) as handler:
|
|
338
373
|
_refuse_input_to_hidden_tab(handler)
|
|
339
374
|
text = _native_or_raise(handler, "click", {"uid": uid})
|
|
340
375
|
return {"uid": uid, "result": text}
|
|
@@ -349,12 +384,13 @@ def fill(
|
|
|
349
384
|
registry_path: str | None = None,
|
|
350
385
|
endpoint: str | None = None,
|
|
351
386
|
handler: CDPHandler | None = None,
|
|
387
|
+
all_frames: bool = False,
|
|
352
388
|
) -> dict[str, Any]:
|
|
353
389
|
"""Native UID fill (frozen ``fill``), over the #40 interaction path.
|
|
354
390
|
|
|
355
391
|
Takes no snapshot, for the reason :func:`click` gives.
|
|
356
392
|
"""
|
|
357
|
-
with _handler_for(handler, instance, target, registry_path, endpoint) as handler:
|
|
393
|
+
with _handler_for(handler, instance, target, registry_path, endpoint, all_frames) as handler:
|
|
358
394
|
_refuse_input_to_hidden_tab(handler)
|
|
359
395
|
result = _native_or_raise(handler, "fill", {"uid": uid, "value": text})
|
|
360
396
|
return {"uid": uid, "text": text, "result": result}
|
|
@@ -491,9 +527,10 @@ def frames_list(
|
|
|
491
527
|
registry_path: str | None = None,
|
|
492
528
|
endpoint: str | None = None,
|
|
493
529
|
handler: CDPHandler | None = None,
|
|
530
|
+
all_frames: bool = False,
|
|
494
531
|
) -> dict[str, Any]:
|
|
495
532
|
"""List the page's frames (frozen ``list_frames``)."""
|
|
496
|
-
with _handler_for(handler, instance, None, registry_path, endpoint) as handler:
|
|
533
|
+
with _handler_for(handler, instance, None, registry_path, endpoint, all_frames) as handler:
|
|
497
534
|
text = _tool_or_raise(handler, "list_frames", {})
|
|
498
535
|
return {"frames": text}
|
|
499
536
|
|
|
@@ -505,9 +542,10 @@ def frames_select(
|
|
|
505
542
|
registry_path: str | None = None,
|
|
506
543
|
endpoint: str | None = None,
|
|
507
544
|
handler: CDPHandler | None = None,
|
|
545
|
+
all_frames: bool = False,
|
|
508
546
|
) -> dict[str, Any]:
|
|
509
547
|
"""Select a frame by URL pattern (frozen ``select_frame``)."""
|
|
510
|
-
with _handler_for(handler, instance, None, registry_path, endpoint) as handler:
|
|
548
|
+
with _handler_for(handler, instance, None, registry_path, endpoint, all_frames) as handler:
|
|
511
549
|
text = _tool_or_raise(handler, "select_frame", {"url_pattern": pattern})
|
|
512
550
|
return {"selected": text}
|
|
513
551
|
|
|
@@ -518,9 +556,10 @@ def frames_reset(
|
|
|
518
556
|
registry_path: str | None = None,
|
|
519
557
|
endpoint: str | None = None,
|
|
520
558
|
handler: CDPHandler | None = None,
|
|
559
|
+
all_frames: bool = False,
|
|
521
560
|
) -> dict[str, Any]:
|
|
522
561
|
"""Clear frame selection back to the top-level page (frozen ``reset_frame``)."""
|
|
523
|
-
with _handler_for(handler, instance, None, registry_path, endpoint) as handler:
|
|
562
|
+
with _handler_for(handler, instance, None, registry_path, endpoint, all_frames) as handler:
|
|
524
563
|
text = _tool_or_raise(handler, "reset_frame", {})
|
|
525
564
|
return {"result": text}
|
|
526
565
|
|
|
@@ -537,6 +576,7 @@ def storage_get(
|
|
|
537
576
|
registry_path: str | None = None,
|
|
538
577
|
endpoint: str | None = None,
|
|
539
578
|
handler: CDPHandler | None = None,
|
|
579
|
+
all_frames: bool = False,
|
|
540
580
|
) -> dict[str, Any]:
|
|
541
581
|
"""Read a frame's storage (frozen ``get_frame_storage``).
|
|
542
582
|
|
|
@@ -550,7 +590,7 @@ def storage_get(
|
|
|
550
590
|
:meth:`CDPHandler.borrowed_frame_selection`.
|
|
551
591
|
"""
|
|
552
592
|
with (
|
|
553
|
-
_handler_for(handler, instance, None, registry_path, endpoint) as handler,
|
|
593
|
+
_handler_for(handler, instance, None, registry_path, endpoint, all_frames) as handler,
|
|
554
594
|
contextlib.ExitStack() as scope,
|
|
555
595
|
):
|
|
556
596
|
if key:
|