Skip to main content

Crate ferridriver_script

Crate ferridriver_script 

Source
Expand description

ferridriver-script: sandboxed QuickJS scripting engine.

Exposes a ScriptEngine that runs user-provided JS against ferridriver’s Page/Browser/Context API with:

  • One-shot isolation via ScriptEngine::run (fresh VM per call) or REPL-style continuity via a persistent Session whose globalThis survives across Session::execute calls; SessionTable owns a set of them with a warm-VM cap, idle TTL, and browser-swap invalidation.
  • Bound args (never interpolated into source) to prevent prompt injection.
  • Wall-clock and memory quotas enforced by the QuickJS runtime.
  • Sandboxed globals: scoped fs, captured console, session vars.
  • Module loader rooted at a configured scripts/ directory with path sanitization (rejects .., absolute paths, symlinks escaping root).
  • A poisoning timeout/OOM discards the session VM so the next execution transparently gets a fresh one.

Scripting is independent of the BDD step registry — scripts drive the browser through the page / context / request bindings directly.

Re-exports§

pub use bindings::ArtifactsJs;
pub use bindings::BrowserContextJs;
pub use bindings::CollectedRegistry;
pub use bindings::HookArg;
pub use bindings::HttpClientJs;
pub use bindings::HttpResponseJs;
pub use bindings::JsArg;
pub use bindings::KeyboardJs;
pub use bindings::LocatorJs;
pub use bindings::MouseJs;
pub use bindings::PageJs;
pub use bindings::PluginBinding;
pub use bindings::PluginCommandsJs;
pub use bindings::ScenarioWorld;
pub use bindings::ScriptAttachment;
pub use bindings::StepOutcome;
pub use bindings::collect_registry;
pub use bindings::drain_attachments;
pub use bindings::install_plugins;
pub use bindings::invoke_hook;
pub use bindings::invoke_step;
pub use bindings::reset_world;
pub use bindings::set_scenario_world;
pub use bundle::CompiledBundle;
pub use bundle::CompiledPlugin;
pub use bundle::bundle_and_compile;
pub use bundle::bundle_source;
pub use bundle::compile_and_extract_plugins;
pub use bundle::eval_bundle;
pub use command_spec::CommandOutput;
pub use command_spec::CommandRun;
pub use command_spec::CommandSpec;
pub use command_spec::ResolvedCommand;
pub use command_spec::ResolvedExec;
pub use console::ConsoleCapture;
pub use discover::SOURCE_EXTENSIONS;
pub use discover::is_source_file;
pub use discover::walk_source_files;
pub use engine::ExtensionHost;
pub use engine::RunContext;
pub use engine::RunOptions;
pub use engine::ScriptCaps;
pub use engine::ScriptEngine;
pub use engine::ScriptEngineConfig;
pub use engine::Session;
pub use engine::SessionRun;
pub use error::ScriptError;
pub use error::ScriptErrorKind;
pub use fs::PathSandbox;
pub use result::ConsoleEntry;
pub use result::ConsoleLevel;
pub use result::Outcome;
pub use result::ScriptResult;
pub use result::ScriptSuccess;
pub use session_procs::SessionProcs;
pub use session_table::BrowserSession;
pub use session_table::SessionTable;
pub use vars::InMemoryVars;
pub use vars::VarsStore;

Modules§

bindings
QuickJS bindings for ferridriver core types.
bundle
Step-file front-end: rolldown bundle + tree-shake + TypeScript -> one ESM module -> compiled to QuickJS bytecode once.
command_spec
The allow.commands capability schema and ${var} resolution.
console
Captured console.* output with size limits.
discover
Canonical source-file discovery for extensions and BDD step files.
engine
ScriptEngine + Session: a sandboxed QuickJS runtime/context.
error
Script execution errors with source-level diagnostics.
fs
Scoped filesystem module exposed to scripts as fs.
modules
Module loader rooted at the script_root sandbox.
result
Structured result returned by ScriptEngine::run.
session_procs
Process execution for the commands capability.
session_table
Persistent per-session script VMs, as one owned aggregate, with a crisp two-tier lifetime:
vars
Session-level variable store exposed to scripts as the vars global.

Structs§

AsyncContext
An asynchronous single execution context with its own global variables and stack.