Skip to main content

Crate rightkit_browser

Crate rightkit_browser 

Source
Expand description

Shared Chrome DevTools Protocol browser runtime for Right Suite products.

  • BrowserSession owns one Chrome process and any number of pages. Launch uses Chrome for Testing (chrome_for_testing_path); the system browser only with LaunchOptions::system_chrome or LaunchOptions::system_chrome_only. Shutdown and drop close gracefully (CDP Browser.close / SIGTERM to the process group, bounded waits, SIGKILL last).
  • ProfileSpec selects a temporary, named persistent, or caller-owned directory profile.
  • Pointer and keyboard actions use real Input.dispatch*Event commands, so event.isTrusted, :hover, focus, and default actions behave as for a user.
  • NetworkPolicy blocks loopback/link-local/private/reserved/file: targets (redirects, subresources, and every proxied connection included) before they reach the network; denials are typed (BrowserError::Blocked).
  • AdmissionHook then gates every effect before it happens.
  • BrowserEvent reports start/stop/crash/denied with session id, reason, and time.
  • BrowserPage::set_request_interceptor lets the caller continue, rewrite, fulfil or fail every request after the network policy; BrowserPage::accessibility_tree, BrowserPage::exceptions, BrowserPage::set_page_scale and BrowserPage::set_download_behavior expose the matching CDP domains.
  • Real-session mode (consent-gated): default_browser, UserConsentReceipt, ProfileSpec::ImportedFrom and BrowserSession::attach_user_browser reuse the user’s own sign-ins in a private copy, confined to the consented domains. See ImportSpec.
  • cookies::parse_netscape reads a Netscape cookies.txt (bounded; values redacted in Debug and errors) and BrowserPage::import_cookies sets the result in the profile. With feature cookie-export, CookieExport goes the other way: it keeps the cookies of declared domains and publishes them as a private Netscape file through rightkit-fs; an empty or invalid export never replaces the previous file.
  • With feature profile-vault, ProfileVault and LaunchOptions::encrypted_profile keep a persistent profile as one authenticated-encrypted file at rest: decrypted to a private working directory for the session, re-sealed and wiped at stop, recovered after a crash, and refused with a typed VaultError when the credential-store key is unavailable.
  • capture loads one real URL and returns a typed CaptureReport: load result, PNG, metrics, console and (feature axe) axe-core output, each hashed and bound to the session, process, profile, page, frame, loader and context that produced it, with the terminal cleanup outcome (StopReport) of success, failure, timeout and cancellation alike.
  • BrowserPage::observe returns refs that are checked for staleness before use; BrowserPage::act runs one action on a ref (epoch, document, tag, role and name checked first) and returns the diff, and stops a run that repeats the same no-effect action (BrowserError::ActionLoop).
  • design_mode holds the element-picker primitives: an isolated-world binding bridge, a one-shot native-gesture submit gate, device-pixel capture geometry and the picker script builder.

Re-exports§

pub use cookies::parse_netscape;
pub use cookies::CookieFieldError;
pub use cookies::CookieParseError;
pub use cookies::NetscapeCookie;
pub use cookies::MAX_COOKIES;
pub use cookies::MAX_COOKIES_FILE_BYTES;

Modules§

cookies
Netscape cookies.txt parsing and the CDP mapping that imports the cookies into the current browser profile (BrowserPage::import_cookies).
design_mode
Design-mode element-picker primitives: a trusted binding bridge with one-shot submit authentication, device-pixel capture geometry, and the picker script builder.

Structs§

ActResult
The result of one BrowserPage::act.
AdmissionRequest
One typed request to perform an effect. Typed text is never included, only its length, so admission logs stay content-free.
AxNode
One node of Accessibility.getFullAXTree.
AxSummary
One non-ignored node of an accessibility tree that has a role, as carried by an observation.
AxeObservation
The axe-core result.
AxeSpec
An accessibility check to run with the vendored axe-core.
BlockedRequest
Copy of the old string-only blocked record, kept per page.
BrowserEvent
One structured, content-free lifecycle event for the caller’s journal. Never carries typed text, page content, or full URLs.
BrowserPage
BrowserRequest
One network request about to leave the browser, as seen by the allow callback.
BrowserSession
One Chrome process with any number of pages.
CaptureArtifact
One file the capture wrote.
CaptureBinding
The caller’s own identity for the work being captured, carried verbatim into the report. Each digest is a non-empty string of at most 200 characters with no control characters; the format (for example sha256:<hex>) is the caller’s.
CaptureCancellation
Sticky, cloneable cancellation signal for capture.
CaptureIdentity
What produced the capture: the browser instance and the exact document observed, bound to the caller’s digests.
CaptureReport
Everything one capture produced.
CaptureRequest
One capture of one URL.
CleanupReport
Terminal cleanup, as achieved.
ConsentRevocation
Live revocation switch shared with a running session. Calling Self::revoke makes the session’s next action fail, without waiting for the app to persist the receipt.
ConsoleLine
ConsoleObservation
Console output and uncaught exceptions from page creation to the end of observation.
ConsoleRecord
ContinueOverrides
Overrides for a continued request. Anything left None is unchanged.
ExceptionFrame
One frame of an exception’s stack.
FixtureAttestation
FixtureBundle
FixtureCancellation
Sticky, cloneable cancellation signal for a fixture run.
FixtureCleanupEvidence
FixtureFile
FixtureIntent
FixtureOutcome
FixtureRunFailure
FixtureServer
An exclusively owned server for one verified, immutable fixture bundle.
FixtureSession
Opaque execution authority for one immutable source bundle and one closed action list.
ImportReport
Result of one import. Per-domain cookie counts need the cookie database opened, which this module does not do, so domain_counts is None.
ImportSpec
Consent-gated copy of a browser profile’s sign-ins into a named RightKit profile (see crate::ProfileSpec::ImportedFrom).
InterceptedRequest
One Fetch.requestPaused event, decoded.
LaunchOptions
LoadObservation
The navigation result.
ManagedRoot
The RightKit-managed Chrome for Testing folder and its fixed layout: one current install, one current.previous rollback copy, and current.staging while an install runs. No per-version folders and no new id: every app resolves the same path.
MetricsObservation
Navigation and paint timings; values the browser did not report are JSON null.
NetworkPolicy
Typed SSRF/host policy. See the module docs for defaults.
NodeChange
An element that was there before the action and is still there, but looks different.
NodeState
What an observed element looked like. Names of password-like fields are already masked.
Observation
ObservationDiff
What one action changed. Elements are matched by selector; an element with no selector (it cannot be targeted by ref) is not part of the diff.
ObservedNode
PageException
One Runtime.exceptionThrown event: an uncaught exception or unhandled rejection.
PageSetup
What to install on a page before its first navigation; see BrowserSession::new_page_with.
PinnedConnection
One connection the proxy made, with the address it pinned.
PolicyDenial
Typed network-policy denial returned as crate::BrowserError::Blocked.
Rect
ScreenshotArtifact
PNG screenshot of the viewport.
ScreenshotClip
A capture region in CSS pixels of the page. x and y are at least zero; width and height are positive.
ScreenshotOptions
Screenshot options for BrowserPage::screenshot_with. The default is the viewport as PNG.
SourceProfile
One profile of a Chromium-family browser.
StopReport
What stopping a session actually achieved, step by step (see BrowserSession::shutdown_report).
UserConsentReceipt
What the user agreed to: which browser, which profile, which domains. The app persists it (it is Serialize/Deserialize), shows it, and revokes it. A revoked or expired receipt refuses every later import, attach and action.
VisibleExit
How the visible browser exited once the person closed it.
VisibleLaunch
What to open in the visible browser.

Enums§

ActionKind
AddressClass
Address class of a destination. Everything except Public is blocked by default.
AxeStatus
BlockReason
Why the network policy refused a request.
BrowserError
BrowserKind
A concrete browser product.
BrowserSource
Which browser an import reads from.
CaptureStatus
How the capture ended.
Decision
DownloadBehavior
What the page does with a download.
FixtureAction
FixtureConfinementBackend
FixtureError
FixtureKey
FixtureOutcomeStatus
InterceptDecision
The answer to one paused request.
InterceptFailure
Why a request is failed; maps to the CDP Network.ErrorReason the page sees.
InterceptStage
Which stage a paused request is at.
LifecycleKind
PolicyDecision
Answer of the per-request allow callback.
ProfileSpec
Where the browser keeps cookies, storage, and logins.
RefAction
The one action BrowserPage::act runs on a ref.
ScreenshotFormat
Image format of a screenshot.
Target
What an action addresses.

Constants§

CAPTURE_SCHEMA
Schema tag of every CaptureReport.
CHROME_FOR_TESTING_ENV
Environment variable naming an explicit Chrome for Testing executable.
CHROME_FOR_TESTING_INSTALL_HINT
How to get Chrome for Testing; part of BrowserError::ChromeForTestingNotFound.
CHROME_FOR_TESTING_ROOT_ENV
Override the RightKit-managed Chrome for Testing root (the folder that holds current).
CONSENT_SCHEMA
Schema version of UserConsentReceipt.
DEFAULT_ACTION_LOOP_LIMIT
How many times the same action may run on the same ref with no diff before the next one is refused.
FIXTURE_SCHEMA
MAX_CAPTURE_AXE_BYTES
Largest axe result kept, in bytes of JSON.
MAX_CAPTURE_CONSOLE_RECORDS
Most console records kept.
MAX_CAPTURE_DEADLINE
Longest accepted deadline.
MAX_CAPTURE_SCREENSHOT_BYTES
Largest screenshot accepted, in bytes.
MAX_CAPTURE_VIEWPORT_EDGE
Largest viewport edge, in CSS pixels.
MAX_EXCEPTIONS
Structured exceptions kept per page (oldest dropped first).
MAX_EXTRA_HEADERS
Most extra HTTP headers one BrowserPage::set_extra_headers call accepts.
MAX_HEADER_VALUE_BYTES
Longest accepted extra-header value, in bytes.
MAX_USER_AGENT_BYTES
Longest accepted user-agent string, in bytes.
OBSERVE_AX_DEPTH
Depth bound for the accessibility summary in an Observation.

Functions§

actions_digest
browser_executable
The installed browser executable for a Chromium-family kind.
capture
Capture request. See the module docs for what is returned on each ending.
chrome_for_testing_candidates
Known Chrome for Testing install locations, in resolution order: the RightKit-managed current (then current.previous, then legacy per-version folders; RIGHTKIT_CHROME_FOR_TESTING_ROOT overrides the root), app installs, then Puppeteer’s cache (PUPPETEER_CACHE_DIR), then Playwright’s (PLAYWRIGHT_BROWSERS_PATH), newest version first within each cache.
chrome_for_testing_path
Resolve Chrome for Testing: explicit, then RIGHTKIT_CHROME_FOR_TESTING, then chrome_for_testing_candidates. Errors with install instructions; never returns regular Chrome.
classify_ip
default_browser
The user’s default web browser on Windows, macOS and Linux, or BrowserKind::Unknown when it cannot be determined.
find_chrome
System Chrome, Chromium, then Edge. CHROME env overrides. Launch uses this only with LaunchOptions::system_chrome or LaunchOptions::system_chrome_only; prefer chrome_for_testing_path for isolated automation.
list_profiles
Profiles of an installed Chromium-family browser, for the consent screen.
purge_imported_profile
Delete an imported RightKit profile (revoking consent should call this). Refuses a directory RightKit did not import into, and a profile a live session holds.
run_visible_until_exit
Start the browser showing launch.url and block until its process exits. No remote debugging flag is passed, so the browser exposes no control endpoint. Blocking: call it from a dedicated thread or spawn_blocking.
user_data_dir
The browser’s own user-data directory (read only by this module), when it exists.

Type Aliases§

AdmissionHook
AllowCallback
EventSink
NetworkRequest
Former name, kept for existing callers.
RequestInterceptor
Caller-supplied hook, consulted for every request the page makes (redirect hops included).
Resolver
Result