browser-tools 0.7.1__tar.gz → 0.8.0__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.7.1 → browser_tools-0.8.0}/PKG-INFO +1 -1
- {browser_tools-0.7.1 → browser_tools-0.8.0}/pyproject.toml +1 -1
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/GUIDE.txt +26 -21
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/cdp_handler.py +179 -7
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/frame_manager.py +118 -23
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/frame_sessions.py +23 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/native_interaction.py +13 -8
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/native_snapshot.py +190 -56
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/live_chromium.py +26 -13
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/parity_engines.py +4 -8
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/test_parity_engine.py +2 -2
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/test_parity_native_interaction.py +2 -4
- browser_tools-0.8.0/tests/test_cross_frame_snapshot.py +408 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_frame_manager.py +3 -3
- browser_tools-0.8.0/tests/test_frame_routing.py +344 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_native_interaction.py +3 -3
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_native_snapshot.py +36 -12
- {browser_tools-0.7.1 → browser_tools-0.8.0}/.gitignore +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/LICENSE +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/NOTICE +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/README.md +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/__init__.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/attached_session.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/camoufox_runner.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/cdp_client.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/cdp_constants.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/cli.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/__init__.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/attach.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/cdp_client.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/connection.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/__init__.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/accessibility.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/animation.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/audits.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/autofill.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/background_service.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/bluetooth_emulation.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/browser.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/cache_storage.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/cast.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/console.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/css.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/debugger.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/device_access.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/device_orientation.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/dom.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/dom_debugger.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/dom_snapshot.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/dom_storage.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/emulation.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/event_breakpoints.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/extensions.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/fed_cm.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/fetch.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/file_system.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/headless_experimental.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/heap_profiler.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/indexed_db.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/input.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/inspector.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/io.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/layer_tree.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/log.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/media.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/memory.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/network.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/overlay.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/page.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/performance.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/performance_timeline.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/preload.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/profiler.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/pwa.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/runtime.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/schema.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/security.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/service_worker.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/smart_card_emulation.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/storage.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/system_info.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/target.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/tethering.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/tracing.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/web_audio.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/domains/web_authn.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/errors.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/fingerprint.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/instance_status.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/launcher.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/protocol.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/registry.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/supervisor.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/core/utils.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/curated.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/detect_interstitial.js +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/endpoint.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/events.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/extras.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/interstitial.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/lifecycle.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/list_verbs.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/mcp_response.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/one_shot.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/passthrough.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/process_utils.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/profiler.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/screencast.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/screenshot_utils.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/step_list.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/step_run.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/tool_registry.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/usage.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/src/browser_tools/user_settings.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/conftest.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/doubles.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/CORPUS.md +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/camoufox_session.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/conftest.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/fixtures/dynamic.html +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/fixtures/form.html +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/fixtures/iframe.html +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/fixtures/iframe_child.html +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/fixtures/plain.html +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/fixtures/shadow.html +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/node_broker.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/parity_comparison.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/parity_corpus.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/run_baseline.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/test_camoufox_live_launch.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/test_camoufox_session.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/test_e2e_camoufox.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/test_node_broker.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/test_parity_baseline.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/test_parity_corpus.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/test_parity_gate.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/test_parity_native.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/parity/test_parity_operator.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_async_discovery.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_attached_session.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_cdp_client.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_cli_grammar.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_cli_lifecycle.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_cli_surface.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_core_launcher.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_core_send_timeout.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_cross_origin_frames.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_curated_verbs.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_detached_tasks.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_diagnostics_name_real_verbs.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_endpoint.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_error_prefix.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_events.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_frame_session_discovery.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_guide.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_handler_transport.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_interaction_targeting.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_interstitial.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_list_verbs.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_native_backend.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_new_tools.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_one_shot.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_packaging.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_passthrough.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_profile_liveness.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_profile_path_hardening.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_profile_root_move.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_profile_verbs.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_profiler.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_retained_contracts.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_session_hygiene.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_shared_session.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_step_dispatch.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_step_list.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_step_run.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_stop_target.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_supervisor_document_liveness.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_supervisor_never_pauses.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_supervisor_profile_preservation.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/tests/test_supervisor_visibility.py +0 -0
- {browser_tools-0.7.1 → browser_tools-0.8.0}/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.8.0
|
|
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
|
|
@@ -175,31 +175,34 @@ CURATED VERBS
|
|
|
175
175
|
which is the behaviour above. `all` attaches to each cross-origin
|
|
176
176
|
iframe as well and splices its frames into the one tree.
|
|
177
177
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
storage get
|
|
184
|
-
|
|
185
|
-
snapshot
|
|
186
|
-
it
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
cross-origin iframes the page has, their URLs, and where they sit in
|
|
196
|
-
the tree.
|
|
178
|
+
What it gives you:
|
|
179
|
+
|
|
180
|
+
frames list lists cross-origin iframes in tree position,
|
|
181
|
+
marked [out-of-process]
|
|
182
|
+
frames select selects one, at any nesting depth
|
|
183
|
+
storage get reads the selected frame's own localStorage and
|
|
184
|
+
sessionStorage, from its own renderer
|
|
185
|
+
snapshot reads each frame's tree on the session that owns
|
|
186
|
+
it and prints one tree, so nodes inside a
|
|
187
|
+
cross-origin iframe get uids
|
|
188
|
+
click, fill reach those nodes, dispatching into the frame's
|
|
189
|
+
own renderer
|
|
190
|
+
|
|
191
|
+
A uid names the document it was minted in, so nodes in different
|
|
192
|
+
frames of one snapshot have different uid prefixes. That is how a
|
|
193
|
+
later `click` knows which process to send to. Pass --frames all to
|
|
194
|
+
the click too, or it will not know.
|
|
197
195
|
|
|
198
196
|
`frames list --frames all` marks a frame in another process
|
|
199
197
|
[out-of-process]. A frame past a bound is listed [unreachable] with its
|
|
200
198
|
URL rather than dropped, so a frame you cannot reach is still a row you
|
|
201
199
|
can see. The bounds are 32 frame sessions and 10 levels of nesting.
|
|
202
200
|
|
|
201
|
+
[unreachable] rows come after the tree, at a fixed indent. They are not
|
|
202
|
+
in tree position, because the tool never attached to the frame and so
|
|
203
|
+
does not know where it sits. Read them as a list of what was left out,
|
|
204
|
+
not as children of the frame above them.
|
|
205
|
+
|
|
203
206
|
Accepted by `frames list`, `frames select`, `frames reset`, `storage
|
|
204
207
|
get`, `snapshot`, `click`, `fill`, and `run`, where it covers every
|
|
205
208
|
step of the run. The last four accept it so that a run can carry one
|
|
@@ -211,8 +214,10 @@ CURATED VERBS
|
|
|
211
214
|
119.7 ms with --frames all. On a page with no cross-origin iframe the
|
|
212
215
|
flag costs one CDP round trip, about 8 ms.
|
|
213
216
|
|
|
214
|
-
|
|
215
|
-
|
|
217
|
+
`screenshot`, `screencast`, `wait-idle`, `detect`, `console-list` and
|
|
218
|
+
`network-list` do not take --frames at all; passing it is a usage error
|
|
219
|
+
(exit 2). None of them is frame-scoped, so there is nothing for the
|
|
220
|
+
flag to mean there.
|
|
216
221
|
|
|
217
222
|
storage get [--key K]
|
|
218
223
|
The selected frame's storage. --key is a frame URL pattern to select
|
|
@@ -1159,13 +1159,19 @@ class CDPHandler:
|
|
|
1159
1159
|
send = cdp.send
|
|
1160
1160
|
|
|
1161
1161
|
if name == "take_snapshot":
|
|
1162
|
-
|
|
1162
|
+
documents = self._cross_process_documents()
|
|
1163
|
+
if documents:
|
|
1164
|
+
merged, token = await self._stitch_across_sessions(documents)
|
|
1165
|
+
snapshot = self._native_reader.build(merged, doc_token=token)
|
|
1166
|
+
else:
|
|
1167
|
+
snapshot = await self._native_reader.snapshot_stitched(send)
|
|
1163
1168
|
return make_text(snapshot.format_tree())
|
|
1164
1169
|
|
|
1165
1170
|
if name in ("click", "fill"):
|
|
1166
1171
|
uid = str(arguments.get("uid", "")).strip()
|
|
1167
1172
|
if not uid:
|
|
1168
1173
|
return make_error(f"E008: '{name}' requires --uid UID from a prior 'snapshot'")
|
|
1174
|
+
send = self._send_for_uid(uid, send)
|
|
1169
1175
|
try:
|
|
1170
1176
|
if name == "click":
|
|
1171
1177
|
result = await self._native_interactor.click_async(send, uid)
|
|
@@ -1177,10 +1183,147 @@ class CDPHandler:
|
|
|
1177
1183
|
result = await self._native_interactor.fill_async(send, uid, value)
|
|
1178
1184
|
return make_text(f"Filled uid={result.uid} (value now {result.value_after!r}).")
|
|
1179
1185
|
except UidResolutionError as exc:
|
|
1180
|
-
return make_error(
|
|
1186
|
+
return make_error(await self._uid_failure(uid, exc))
|
|
1181
1187
|
|
|
1182
1188
|
return make_error(f"Unknown native tool: {name}")
|
|
1183
1189
|
|
|
1190
|
+
async def _uid_failure(self, uid: str, exc: UidResolutionError) -> str:
|
|
1191
|
+
"""Why the UID did not resolve, saying which of the reasons it was.
|
|
1192
|
+
|
|
1193
|
+
The resolver knows one reason and states it: the document is gone.
|
|
1194
|
+
There is a second, and it has the opposite remedy. A UID minted
|
|
1195
|
+
inside a cross-origin iframe names that iframe's document, and this
|
|
1196
|
+
invocation only sees documents it attached to - so without
|
|
1197
|
+
`--frames all` a perfectly live UID is refused with "the page
|
|
1198
|
+
navigated since", and taking another snapshot produces the same UID
|
|
1199
|
+
and the same refusal.
|
|
1200
|
+
|
|
1201
|
+
Asking the browser for its `iframe` targets is what tells the two
|
|
1202
|
+
apart. On the failure path only, and a browser that will not answer
|
|
1203
|
+
leaves the plain message rather than an error about the diagnosis.
|
|
1204
|
+
This is the same shape as the `frames select` diagnosis for #127.
|
|
1205
|
+
"""
|
|
1206
|
+
message = str(exc)
|
|
1207
|
+
if self._rt.frame_sessions is not None or "previous document" not in message:
|
|
1208
|
+
return message
|
|
1209
|
+
targets = await self._out_of_process_frames("")
|
|
1210
|
+
if not targets:
|
|
1211
|
+
return message
|
|
1212
|
+
listed = ", ".join(targets[:3])
|
|
1213
|
+
return (
|
|
1214
|
+
f"{message}\n"
|
|
1215
|
+
f"Or the uid names a node inside a cross-origin iframe, and this "
|
|
1216
|
+
f"command did not pass --frames all. The browser has "
|
|
1217
|
+
f"{len(targets)} such iframe(s): {listed}. A uid minted with "
|
|
1218
|
+
f"--frames all only resolves with --frames all."
|
|
1219
|
+
)
|
|
1220
|
+
|
|
1221
|
+
def _cross_process_documents(self) -> list[Any]:
|
|
1222
|
+
"""The page's documents, when any of them is in another process.
|
|
1223
|
+
|
|
1224
|
+
Empty when every frame answers on the page session, which is the
|
|
1225
|
+
common page and the whole of the default `--frames page`. The
|
|
1226
|
+
same-process stitch then runs unchanged: it is one session, one
|
|
1227
|
+
`Page.getFrameTree`, and no frame map needed.
|
|
1228
|
+
"""
|
|
1229
|
+
fm = self._frame_manager
|
|
1230
|
+
if fm is None or self._rt.frame_sessions is None:
|
|
1231
|
+
return []
|
|
1232
|
+
documents = fm.frame_documents()
|
|
1233
|
+
if not any(document.session_id for document in documents):
|
|
1234
|
+
return []
|
|
1235
|
+
return documents
|
|
1236
|
+
|
|
1237
|
+
async def _stitch_across_sessions(self, documents: list[Any]) -> tuple[dict[str, Any], str]:
|
|
1238
|
+
"""Read each frame's accessibility tree on the session that owns it.
|
|
1239
|
+
|
|
1240
|
+
`Accessibility.getFullAXTree` answers for the renderer it is sent to.
|
|
1241
|
+
A cross-origin iframe is a different renderer, so asking the page
|
|
1242
|
+
session for it returns nothing and the `Iframe` node stays empty -
|
|
1243
|
+
which is exactly what `snapshot` printed before this.
|
|
1244
|
+
|
|
1245
|
+
`DOM.getFrameOwner` goes to the *parent*, because the owner node is
|
|
1246
|
+
in the parent's document. Each frame is read with its own token, so
|
|
1247
|
+
the merged tree carries several documents and `build` mints each
|
|
1248
|
+
node's UID against the one it came from.
|
|
1249
|
+
|
|
1250
|
+
A frame that will not answer is skipped, not fatal: one broken child
|
|
1251
|
+
frame degrades the snapshot to the rest of the tree, the same way the
|
|
1252
|
+
same-process stitch already degrades.
|
|
1253
|
+
"""
|
|
1254
|
+
from .native_snapshot import (
|
|
1255
|
+
AX_ENABLE,
|
|
1256
|
+
AX_GET_FULL_TREE,
|
|
1257
|
+
DOM_GET_FRAME_OWNER,
|
|
1258
|
+
ChildFrameTree,
|
|
1259
|
+
stitch_ax_frames,
|
|
1260
|
+
)
|
|
1261
|
+
|
|
1262
|
+
top, rest = documents[0], documents[1:]
|
|
1263
|
+
top_send = self.client_for_session(top.session_id).send
|
|
1264
|
+
await top_send(AX_ENABLE)
|
|
1265
|
+
top_tree = await top_send(AX_GET_FULL_TREE)
|
|
1266
|
+
|
|
1267
|
+
children: list[ChildFrameTree] = []
|
|
1268
|
+
for document in rest:
|
|
1269
|
+
if document.parent_doc_token is None:
|
|
1270
|
+
continue
|
|
1271
|
+
try:
|
|
1272
|
+
owner_send = self.client_for_session(document.parent_session_id).send
|
|
1273
|
+
owner = await owner_send(
|
|
1274
|
+
DOM_GET_FRAME_OWNER, {"frameId": document.frame_id}
|
|
1275
|
+
)
|
|
1276
|
+
backend = owner.get("backendNodeId")
|
|
1277
|
+
if not isinstance(backend, int):
|
|
1278
|
+
continue
|
|
1279
|
+
child_send = self.client_for_session(document.session_id).send
|
|
1280
|
+
await child_send(AX_ENABLE)
|
|
1281
|
+
# No frameId: the child's own session answers for its own
|
|
1282
|
+
# frame, and passing one asks that renderer about a frame it
|
|
1283
|
+
# does not own.
|
|
1284
|
+
tree = await child_send(AX_GET_FULL_TREE)
|
|
1285
|
+
except Exception:
|
|
1286
|
+
logger.debug("frame %s did not answer for its tree", document.frame_id)
|
|
1287
|
+
continue
|
|
1288
|
+
children.append(
|
|
1289
|
+
ChildFrameTree(
|
|
1290
|
+
owner_backend_node_id=backend,
|
|
1291
|
+
owner_doc_token=document.parent_doc_token,
|
|
1292
|
+
doc_token=document.doc_token,
|
|
1293
|
+
result=tree,
|
|
1294
|
+
)
|
|
1295
|
+
)
|
|
1296
|
+
|
|
1297
|
+
return (
|
|
1298
|
+
stitch_ax_frames(top_tree, children, top_doc_token=top.doc_token),
|
|
1299
|
+
top.doc_token,
|
|
1300
|
+
)
|
|
1301
|
+
|
|
1302
|
+
def _send_for_uid(self, uid: str, default: Any) -> Any:
|
|
1303
|
+
"""The transport for the document a UID was minted in.
|
|
1304
|
+
|
|
1305
|
+
A backend DOM node id is unique within a renderer process, not within
|
|
1306
|
+
a browser, so `DOM.resolveNode` for a cross-origin frame's node has to
|
|
1307
|
+
be sent to that frame's own session. Sent to the page session it either
|
|
1308
|
+
fails or, worse, resolves a different node that happens to share the
|
|
1309
|
+
id - measured, a cross-origin child's ids overlapped the page's on 5
|
|
1310
|
+
of its 7 nodes.
|
|
1311
|
+
|
|
1312
|
+
A UID whose token names no frame in the map falls back to the default
|
|
1313
|
+
transport, so the staleness error comes from the resolver with its own
|
|
1314
|
+
wording rather than from a routing failure here.
|
|
1315
|
+
"""
|
|
1316
|
+
from .native_snapshot import parse_uid
|
|
1317
|
+
|
|
1318
|
+
fm = self._frame_manager
|
|
1319
|
+
if fm is None or self._rt.frame_sessions is None:
|
|
1320
|
+
return default
|
|
1321
|
+
token, _ = parse_uid(uid)
|
|
1322
|
+
for document in fm.frame_documents():
|
|
1323
|
+
if document.doc_token == token and document.session_id:
|
|
1324
|
+
return self.client_for_session(document.session_id).send
|
|
1325
|
+
return default
|
|
1326
|
+
|
|
1184
1327
|
async def _dispatch_tool(self, name: str, arguments: dict[str, Any]) -> dict[str, Any]:
|
|
1185
1328
|
"""Route a tool call to its registered handler.
|
|
1186
1329
|
|
|
@@ -1254,14 +1397,38 @@ class CDPHandler:
|
|
|
1254
1397
|
if frame is None:
|
|
1255
1398
|
return make_error(await self._no_frame_matched(url_pattern))
|
|
1256
1399
|
|
|
1257
|
-
|
|
1258
|
-
|
|
1400
|
+
context = fm.get_selected_context()
|
|
1401
|
+
if context is None:
|
|
1402
|
+
ctx_info = " (no execution context yet)"
|
|
1403
|
+
else:
|
|
1404
|
+
session_id, ctx_id = context
|
|
1405
|
+
where = "page session" if session_id is None else f"frame session {session_id}"
|
|
1406
|
+
ctx_info = f", executionContextId={ctx_id} on the {where}"
|
|
1259
1407
|
return make_text(
|
|
1260
1408
|
f"Selected frame: {frame.frame_id}\n"
|
|
1261
1409
|
f"URL: {frame.url}\n"
|
|
1262
1410
|
f"Origin: {frame.security_origin}{ctx_info}"
|
|
1263
1411
|
)
|
|
1264
1412
|
|
|
1413
|
+
def client_for_session(self, frame_session_id: str | None) -> Any:
|
|
1414
|
+
"""The client to send a frame-scoped command on.
|
|
1415
|
+
|
|
1416
|
+
A command against a frame in another renderer has to go to that
|
|
1417
|
+
renderer's Frame Session. Sending it on the page session with the
|
|
1418
|
+
child's `contextId` fails, because a context id is unique within one
|
|
1419
|
+
renderer and means nothing outside it.
|
|
1420
|
+
|
|
1421
|
+
``None`` is the page session, which is every frame's answer until an
|
|
1422
|
+
Out-of-Process Frame is attached. A second `AttachedSessionClient`
|
|
1423
|
+
over the same connection is the whole adapter: it registers nothing
|
|
1424
|
+
and owns nothing, it only carries the session id onto each send.
|
|
1425
|
+
"""
|
|
1426
|
+
if frame_session_id is None or self._cdp_client is None:
|
|
1427
|
+
return self._cdp_client
|
|
1428
|
+
from .attached_session import AttachedSessionClient
|
|
1429
|
+
|
|
1430
|
+
return AttachedSessionClient(self._cdp_client.raw, frame_session_id)
|
|
1431
|
+
|
|
1265
1432
|
async def _out_of_process_frames(self, url_pattern: str) -> list[str]:
|
|
1266
1433
|
"""URLs of `iframe` targets matching the pattern, newest first.
|
|
1267
1434
|
|
|
@@ -1355,7 +1522,12 @@ class CDPHandler:
|
|
|
1355
1522
|
storage_types = arguments.get(
|
|
1356
1523
|
"storage_types", ["cookies", "localStorage", "sessionStorage"]
|
|
1357
1524
|
)
|
|
1358
|
-
|
|
1525
|
+
context = fm.get_selected_context()
|
|
1526
|
+
# The evaluate goes to the frame's own renderer. `cdp` stays the page
|
|
1527
|
+
# session for `Network.getCookies`, which is browser-scoped and takes
|
|
1528
|
+
# a URL rather than a context.
|
|
1529
|
+
ctx_id = context[1] if context else None
|
|
1530
|
+
frame_cdp = self.client_for_session(context[0]) if context else cdp
|
|
1359
1531
|
result_parts: list[str] = []
|
|
1360
1532
|
|
|
1361
1533
|
if "cookies" in storage_types:
|
|
@@ -1376,7 +1548,7 @@ class CDPHandler:
|
|
|
1376
1548
|
if ctx_id and "localStorage" in storage_types:
|
|
1377
1549
|
try:
|
|
1378
1550
|
ls_result = await _safe_cdp_send(
|
|
1379
|
-
|
|
1551
|
+
frame_cdp,
|
|
1380
1552
|
"Runtime.evaluate",
|
|
1381
1553
|
{
|
|
1382
1554
|
"expression": "JSON.stringify(Object.fromEntries(Object.entries(localStorage).slice(0, 20)))",
|
|
@@ -1395,7 +1567,7 @@ class CDPHandler:
|
|
|
1395
1567
|
if ctx_id and "sessionStorage" in storage_types:
|
|
1396
1568
|
try:
|
|
1397
1569
|
ss_result = await _safe_cdp_send(
|
|
1398
|
-
|
|
1570
|
+
frame_cdp,
|
|
1399
1571
|
"Runtime.evaluate",
|
|
1400
1572
|
{
|
|
1401
1573
|
"expression": "JSON.stringify(Object.fromEntries(Object.entries(sessionStorage).slice(0, 20)))",
|
|
@@ -24,6 +24,10 @@ class FrameInfo:
|
|
|
24
24
|
name: str
|
|
25
25
|
parent_frame_id: str | None = None
|
|
26
26
|
execution_context_id: int | None = None
|
|
27
|
+
#: The load currently in this frame. With the frame id it forms the
|
|
28
|
+
#: document token every UID minted in this frame carries, which is how a
|
|
29
|
+
#: `click` in one process finds the frame it belongs to.
|
|
30
|
+
loader_id: str = ""
|
|
27
31
|
children: list[FrameInfo] = field(default_factory=list)
|
|
28
32
|
#: The Frame Session that answers for this frame (RFC-04). ``None`` is the
|
|
29
33
|
#: page session, which is what every frame was before OOPIFs.
|
|
@@ -52,6 +56,20 @@ class FrameInfo:
|
|
|
52
56
|
return result
|
|
53
57
|
|
|
54
58
|
|
|
59
|
+
@dataclass(frozen=True)
|
|
60
|
+
class FrameDocument:
|
|
61
|
+
"""One live document: which frame holds it, and who answers for it."""
|
|
62
|
+
|
|
63
|
+
frame_id: str
|
|
64
|
+
#: `<frame id, loader id>` hashed. What a UID minted here carries.
|
|
65
|
+
doc_token: str
|
|
66
|
+
#: The Frame Session answering for this frame, or None for the page.
|
|
67
|
+
session_id: str | None
|
|
68
|
+
parent_frame_id: str | None
|
|
69
|
+
parent_doc_token: str | None
|
|
70
|
+
parent_session_id: str | None
|
|
71
|
+
|
|
72
|
+
|
|
55
73
|
@dataclass
|
|
56
74
|
class FrameEvent:
|
|
57
75
|
"""A buffered frame lifecycle event."""
|
|
@@ -94,7 +112,13 @@ class FrameManager:
|
|
|
94
112
|
self._selected_frame_id: str | None = None
|
|
95
113
|
self._selected_url_pattern: str | None = None
|
|
96
114
|
self._event_buffer: list[FrameEvent] = []
|
|
97
|
-
|
|
115
|
+
#: ``(frame session, context id) -> frame id``. Keyed by the pair
|
|
116
|
+
#: because an execution context id is renderer-local: two frames in
|
|
117
|
+
#: two Frame Sessions can both own context 1, and a map keyed by the
|
|
118
|
+
#: id alone let the second one overwrite the first, then let a
|
|
119
|
+
#: destroy for either clear the wrong frame (RFC-04, Routing). The
|
|
120
|
+
#: page session is ``None``, matching ``FrameInfo.frame_session_id``.
|
|
121
|
+
self._execution_contexts: dict[tuple[str | None, int], str] = {}
|
|
98
122
|
|
|
99
123
|
@property
|
|
100
124
|
def selected_frame_id(self) -> str | None:
|
|
@@ -147,6 +171,7 @@ class FrameManager:
|
|
|
147
171
|
name=frame_data.get("name", ""),
|
|
148
172
|
parent_frame_id=parent_id,
|
|
149
173
|
frame_session_id=session_id,
|
|
174
|
+
loader_id=str(frame_data.get("loaderId", "")),
|
|
150
175
|
)
|
|
151
176
|
self._frames[frame_id] = info
|
|
152
177
|
|
|
@@ -259,16 +284,54 @@ class FrameManager:
|
|
|
259
284
|
self._selected_frame_id = None
|
|
260
285
|
return None
|
|
261
286
|
|
|
262
|
-
def
|
|
263
|
-
"""
|
|
287
|
+
def frame_documents(self) -> list[FrameDocument]:
|
|
288
|
+
"""Every reachable frame as a document, in `frames list` order.
|
|
264
289
|
|
|
265
|
-
|
|
266
|
-
|
|
290
|
+
One source for the two things a cross-frame read needs. A `click`
|
|
291
|
+
asks which frame a UID's document token names and which session
|
|
292
|
+
answers for it; a stitched `snapshot` asks the same, plus the
|
|
293
|
+
parent, because a frame's `Iframe` node lives in the parent's
|
|
294
|
+
document and is read on the parent's session.
|
|
295
|
+
|
|
296
|
+
Pre-order, so a frame always follows the frame that owns it. The
|
|
297
|
+
stitch depends on that: a nested frame's owner has to be in the
|
|
298
|
+
merged tree before the lookup for it can succeed.
|
|
299
|
+
"""
|
|
300
|
+
from .native_snapshot import doc_token
|
|
301
|
+
|
|
302
|
+
documents: list[FrameDocument] = []
|
|
303
|
+
for frame in self._reachable_frames():
|
|
304
|
+
parent = self._frames.get(frame.parent_frame_id or "")
|
|
305
|
+
documents.append(
|
|
306
|
+
FrameDocument(
|
|
307
|
+
frame_id=frame.frame_id,
|
|
308
|
+
doc_token=doc_token(frame.frame_id, frame.loader_id),
|
|
309
|
+
session_id=frame.frame_session_id,
|
|
310
|
+
parent_frame_id=parent.frame_id if parent else None,
|
|
311
|
+
parent_doc_token=(
|
|
312
|
+
doc_token(parent.frame_id, parent.loader_id) if parent else None
|
|
313
|
+
),
|
|
314
|
+
parent_session_id=parent.frame_session_id if parent else None,
|
|
315
|
+
)
|
|
316
|
+
)
|
|
317
|
+
return documents
|
|
318
|
+
|
|
319
|
+
def get_selected_context(self) -> tuple[str | None, int] | None:
|
|
320
|
+
"""Where to evaluate against the selected frame, or None.
|
|
321
|
+
|
|
322
|
+
The pair ``(frame session, execution context id)``, because the id
|
|
323
|
+
alone is no longer an address: it is unique within one renderer, and
|
|
324
|
+
an Out-of-Process Frame has its own. Returning the id by itself from
|
|
325
|
+
a world with several renderers is the `backendNodeId` mistake again
|
|
326
|
+
(RFC-04, Routing).
|
|
327
|
+
|
|
328
|
+
``None`` for the frame session means the page session, which is what
|
|
329
|
+
every frame was before Frame Sessions existed.
|
|
267
330
|
"""
|
|
268
331
|
frame = self.get_selected_frame()
|
|
269
|
-
if frame is None:
|
|
332
|
+
if frame is None or frame.execution_context_id is None:
|
|
270
333
|
return None
|
|
271
|
-
return frame.execution_context_id
|
|
334
|
+
return frame.frame_session_id, frame.execution_context_id
|
|
272
335
|
|
|
273
336
|
def _reachable_frames(self) -> list[FrameInfo]:
|
|
274
337
|
"""The frames `frames list` shows, in the order it shows them.
|
|
@@ -575,16 +638,26 @@ class FrameManager:
|
|
|
575
638
|
self._reresolve_selection()
|
|
576
639
|
self._event_buffer.append(FrameEvent(event_type="navigated", frame_id=frame_id, url=url))
|
|
577
640
|
|
|
578
|
-
def handle_execution_contexts_cleared(
|
|
579
|
-
|
|
641
|
+
def handle_execution_contexts_cleared(
|
|
642
|
+
self, params: dict[str, Any] | None = None, session_id: str | None = None
|
|
643
|
+
) -> None:
|
|
644
|
+
"""Handle Runtime.executionContextsCleared, for one session only.
|
|
580
645
|
|
|
581
|
-
Every context
|
|
582
|
-
|
|
583
|
-
evaluates against and gets an error for, or
|
|
646
|
+
Every context that session had is gone. Keeping them would leave
|
|
647
|
+
each of its frames holding a destroyed context id, which a
|
|
648
|
+
frame-scoped read then evaluates against and gets an error for, or
|
|
649
|
+
worse, silently skips.
|
|
650
|
+
|
|
651
|
+
One session only, because the event says nothing about the others.
|
|
652
|
+
Cleared globally, a cross-origin iframe navigating would wipe the
|
|
653
|
+
main frame's context and break a read that had nothing to do with
|
|
654
|
+
it (RFC-04, Routing).
|
|
584
655
|
"""
|
|
585
|
-
self._execution_contexts
|
|
656
|
+
for key in [k for k in self._execution_contexts if k[0] == session_id]:
|
|
657
|
+
del self._execution_contexts[key]
|
|
586
658
|
for frame in self._frames.values():
|
|
587
|
-
frame.
|
|
659
|
+
if frame.frame_session_id == session_id:
|
|
660
|
+
frame.execution_context_id = None
|
|
588
661
|
|
|
589
662
|
def _forget_descendants(self, frame_id: str) -> None:
|
|
590
663
|
"""Drop every frame below ``frame_id``, which a navigation destroyed.
|
|
@@ -633,6 +706,7 @@ class FrameManager:
|
|
|
633
706
|
frame.url = frame_data.get("url", frame.url)
|
|
634
707
|
frame.security_origin = frame_data.get("securityOrigin", frame.security_origin)
|
|
635
708
|
frame.name = frame_data.get("name", frame.name)
|
|
709
|
+
frame.loader_id = str(frame_data.get("loaderId", frame.loader_id))
|
|
636
710
|
frame.children = []
|
|
637
711
|
else:
|
|
638
712
|
# Frame navigated before we saw it attached, so create it. Linking
|
|
@@ -646,6 +720,7 @@ class FrameManager:
|
|
|
646
720
|
security_origin=frame_data.get("securityOrigin", ""),
|
|
647
721
|
name=frame_data.get("name", ""),
|
|
648
722
|
parent_frame_id=frame_data.get("parentId"),
|
|
723
|
+
loader_id=str(frame_data.get("loaderId", "")),
|
|
649
724
|
)
|
|
650
725
|
parent = self._frames.get(created.parent_frame_id or "")
|
|
651
726
|
if parent is not None:
|
|
@@ -672,13 +747,18 @@ class FrameManager:
|
|
|
672
747
|
)
|
|
673
748
|
)
|
|
674
749
|
|
|
675
|
-
def handle_execution_context_created(
|
|
750
|
+
def handle_execution_context_created(
|
|
751
|
+
self, params: dict[str, Any], session_id: str | None = None
|
|
752
|
+
) -> None:
|
|
676
753
|
"""Handle Runtime.executionContextCreated event.
|
|
677
754
|
|
|
678
755
|
Maps execution contexts to their owning frames.
|
|
679
756
|
|
|
680
757
|
Args:
|
|
681
758
|
params: CDP event parameters.
|
|
759
|
+
session_id: The Frame Session the event arrived on, or None for
|
|
760
|
+
the page session. Part of the key, not a label: see
|
|
761
|
+
:attr:`_execution_contexts`.
|
|
682
762
|
"""
|
|
683
763
|
context = params.get("context", {})
|
|
684
764
|
context_id = context.get("id")
|
|
@@ -686,24 +766,39 @@ class FrameManager:
|
|
|
686
766
|
frame_id = aux_data.get("frameId")
|
|
687
767
|
|
|
688
768
|
if context_id is not None and frame_id:
|
|
689
|
-
self._execution_contexts[context_id] = frame_id
|
|
769
|
+
self._execution_contexts[(session_id, context_id)] = frame_id
|
|
690
770
|
frame = self._frames.get(frame_id)
|
|
691
771
|
if frame and aux_data.get("isDefault", False):
|
|
692
772
|
frame.execution_context_id = context_id
|
|
693
773
|
|
|
694
|
-
def handle_execution_context_destroyed(
|
|
774
|
+
def handle_execution_context_destroyed(
|
|
775
|
+
self, params: dict[str, Any], session_id: str | None = None
|
|
776
|
+
) -> None:
|
|
695
777
|
"""Handle Runtime.executionContextDestroyed event.
|
|
696
778
|
|
|
779
|
+
Scoped to the session it arrived on. Unscoped, a child renderer
|
|
780
|
+
destroying its context 1 cleared whichever frame happened to hold
|
|
781
|
+
the id, which on a page with an Out-of-Process Frame is usually the
|
|
782
|
+
main frame.
|
|
783
|
+
|
|
697
784
|
Args:
|
|
698
785
|
params: CDP event parameters.
|
|
786
|
+
session_id: The Frame Session the event arrived on, or None for
|
|
787
|
+
the page session.
|
|
699
788
|
"""
|
|
700
789
|
context_id = params.get("executionContextId")
|
|
701
|
-
if context_id is
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
790
|
+
if context_id is None:
|
|
791
|
+
return
|
|
792
|
+
frame_id = self._execution_contexts.pop((session_id, context_id), None)
|
|
793
|
+
if not frame_id:
|
|
794
|
+
return
|
|
795
|
+
frame = self._frames.get(frame_id)
|
|
796
|
+
if (
|
|
797
|
+
frame
|
|
798
|
+
and frame.execution_context_id == context_id
|
|
799
|
+
and frame.frame_session_id == session_id
|
|
800
|
+
):
|
|
801
|
+
frame.execution_context_id = None
|
|
707
802
|
|
|
708
803
|
# -----------------------------------------------------------------------
|
|
709
804
|
# Event Buffer
|
|
@@ -41,6 +41,7 @@ here after finding each one broken in the draft:
|
|
|
41
41
|
from __future__ import annotations
|
|
42
42
|
|
|
43
43
|
import asyncio
|
|
44
|
+
import functools
|
|
44
45
|
import logging
|
|
45
46
|
from dataclasses import dataclass, field
|
|
46
47
|
from typing import TYPE_CHECKING, Any
|
|
@@ -157,6 +158,27 @@ class FrameSessions:
|
|
|
157
158
|
self._client.on("Target.attachedToTarget", self._on_attached, session_id)
|
|
158
159
|
self._client.on("Target.detachedFromTarget", self._on_detached, session_id)
|
|
159
160
|
|
|
161
|
+
def _subscribe_runtime(self, session_id: str) -> None:
|
|
162
|
+
"""File this session's execution contexts against its frames.
|
|
163
|
+
|
|
164
|
+
Subscribe before the enable, never after. `Runtime.enable` replays
|
|
165
|
+
the contexts that already exist, and a handler registered afterwards
|
|
166
|
+
throws that replay away - the same mistake `_connect_cdp` records
|
|
167
|
+
for the page session, where it left every frame with no context and
|
|
168
|
+
made `storage get` return cookies only.
|
|
169
|
+
|
|
170
|
+
Bound to this session id, because a context id means nothing without
|
|
171
|
+
it. `functools.partial` rather than a lambda: a lambda closing over
|
|
172
|
+
the loop variable would file every session's contexts under the last
|
|
173
|
+
session id.
|
|
174
|
+
"""
|
|
175
|
+
for event, handler in (
|
|
176
|
+
("Runtime.executionContextCreated", self._frames.handle_execution_context_created),
|
|
177
|
+
("Runtime.executionContextDestroyed", self._frames.handle_execution_context_destroyed),
|
|
178
|
+
("Runtime.executionContextsCleared", self._frames.handle_execution_contexts_cleared),
|
|
179
|
+
):
|
|
180
|
+
self._client.on(event, functools.partial(handler, session_id=session_id), session_id)
|
|
181
|
+
|
|
160
182
|
async def _set_auto_attach(self, session_id: str) -> None:
|
|
161
183
|
"""Turn auto-attach on, and wait until its attaches have arrived.
|
|
162
184
|
|
|
@@ -289,6 +311,7 @@ class FrameSessions:
|
|
|
289
311
|
# yet. Hold it rather than attaching it anywhere else.
|
|
290
312
|
session.pending_tree = tree
|
|
291
313
|
|
|
314
|
+
self._subscribe_runtime(session.session_id)
|
|
292
315
|
await self._client.send(method="Runtime.enable", session_id=session.session_id)
|
|
293
316
|
if self._is_stale(session, generation):
|
|
294
317
|
return
|
|
@@ -81,7 +81,7 @@ from collections.abc import Awaitable, Callable, Generator
|
|
|
81
81
|
from dataclasses import dataclass, field
|
|
82
82
|
from typing import TYPE_CHECKING, Any, Literal
|
|
83
83
|
|
|
84
|
-
from .native_snapshot import parse_uid,
|
|
84
|
+
from .native_snapshot import parse_uid, read_live_doc_tokens, read_live_doc_tokens_sync
|
|
85
85
|
|
|
86
86
|
if TYPE_CHECKING:
|
|
87
87
|
from .native_snapshot import NativeSnapshotReader
|
|
@@ -329,15 +329,20 @@ class NativeInteractor:
|
|
|
329
329
|
reader: NativeSnapshotReader
|
|
330
330
|
_last_methods: tuple[str, ...] = field(default=(), repr=False)
|
|
331
331
|
|
|
332
|
-
def _backend_for(self, uid: str,
|
|
333
|
-
"""Check ``uid`` against the live
|
|
332
|
+
def _backend_for(self, uid: str, live_tokens: set[str]) -> int:
|
|
333
|
+
"""Check ``uid`` against the live documents and return its backend node.
|
|
334
|
+
|
|
335
|
+
Against all of them, not against the main frame's. A UID minted
|
|
336
|
+
inside an iframe carries that iframe's document token, and a page
|
|
337
|
+
holds as many live documents as it has frames. Checking one token
|
|
338
|
+
refused a node that was on the screen.
|
|
334
339
|
|
|
335
340
|
Raises:
|
|
336
|
-
UidResolutionError: The UID belongs to
|
|
341
|
+
UidResolutionError: The UID belongs to no live document, or
|
|
337
342
|
names no DOM node.
|
|
338
343
|
"""
|
|
339
344
|
doc_token, backend = parse_uid(uid)
|
|
340
|
-
if doc_token
|
|
345
|
+
if doc_token not in live_tokens:
|
|
341
346
|
raise UidResolutionError(
|
|
342
347
|
uid,
|
|
343
348
|
"minted against a previous document (the page navigated since); "
|
|
@@ -348,12 +353,12 @@ class NativeInteractor:
|
|
|
348
353
|
return backend
|
|
349
354
|
|
|
350
355
|
def resolve(self, send: SyncSend, uid: str) -> int:
|
|
351
|
-
"""Backend DOM node ``uid`` names, checked against the live
|
|
352
|
-
return self._backend_for(uid,
|
|
356
|
+
"""Backend DOM node ``uid`` names, checked against the live documents."""
|
|
357
|
+
return self._backend_for(uid, read_live_doc_tokens_sync(send))
|
|
353
358
|
|
|
354
359
|
async def resolve_async(self, send: AsyncSend, uid: str) -> int:
|
|
355
360
|
"""Awaitable :meth:`resolve`."""
|
|
356
|
-
return self._backend_for(uid, await
|
|
361
|
+
return self._backend_for(uid, await read_live_doc_tokens(send))
|
|
357
362
|
|
|
358
363
|
# -- synchronous drivers (parity harness, tests) ----------------------- #
|
|
359
364
|
|