Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/ff-rdp-cli/src/cli/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,9 @@ pub struct SnapshotArgs {
/// Mutually exclusive with --depth. Must be ≥ 1.
#[arg(long, value_name = "N", conflicts_with = "depth")]
pub max_depth: Option<u32>,
/// Maximum total characters of text content to include (default: 50000)
/// Maximum size, in bytes of serialized JSON, of the whole output tree
/// (tags, attributes, and structure — not just leaf text content;
/// default: 50000). `meta.truncated` reports whether anything was cut.
#[arg(long, default_value_t = 50000)]
pub max_chars: u32,
}
Expand Down
8 changes: 2 additions & 6 deletions crates/ff-rdp-cli/src/commands/a11y.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ pub fn run(
}

let hint_ctx = HintContext::new(HintSource::A11y);
OutputPipeline::from_cli(cli)?
.finalize_with_hints(&envelope, Some(&hint_ctx))
.map_err(AppError::from)
OutputPipeline::from_cli(cli)?.finalize_with_hints(&envelope, Some(&hint_ctx))
}

/// Render an accessibility tree node (and its children) as an indented text tree.
Expand Down Expand Up @@ -439,9 +437,7 @@ pub fn run_critical(cli: &Cli, root_selector: Option<&str>) -> Result<(), AppErr
output::envelope_with_truncation(&json!(limited), shown, total, truncated, &meta);

let hint_ctx = HintContext::new(HintSource::A11y);
OutputPipeline::from_cli(cli)?
.finalize_with_hints(&envelope, Some(&hint_ctx))
.map_err(AppError::from)
OutputPipeline::from_cli(cli)?.finalize_with_hints(&envelope, Some(&hint_ctx))
}

/// JS audit: returns a JSON array of violation records. Each record has
Expand Down
4 changes: 1 addition & 3 deletions crates/ff-rdp-cli/src/commands/a11y_contrast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ pub fn run(cli: &Cli, selector: Option<&str>, fail_only: bool) -> Result<(), App
}

let hint_ctx = HintContext::new(HintSource::A11yContrast).with_fail_only(fail_only);
OutputPipeline::from_cli(cli)?
.finalize_with_hints(&envelope, Some(&hint_ctx))
.map_err(AppError::from)
OutputPipeline::from_cli(cli)?.finalize_with_hints(&envelope, Some(&hint_ctx))
}

/// Keep only checks that fail WCAG AA when `fail_only` is set, otherwise return
Expand Down
4 changes: 1 addition & 3 deletions crates/ff-rdp-cli/src/commands/a11y_summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ pub fn run(cli: &Cli) -> Result<(), AppError> {
}

let hint_ctx = HintContext::new(HintSource::A11ySummary);
OutputPipeline::from_cli(cli)?
.finalize_with_hints(&envelope, Some(&hint_ctx))
.map_err(AppError::from)
OutputPipeline::from_cli(cli)?.finalize_with_hints(&envelope, Some(&hint_ctx))
}

fn render_summary_text(results: &Value) {
Expand Down
4 changes: 1 addition & 3 deletions crates/ff-rdp-cli/src/commands/cascade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,7 @@ pub fn run(

let envelope = output::envelope(&Value::Array(results), total, &meta);
let hint_ctx = HintContext::new(HintSource::Styles).with_selector(selector);
OutputPipeline::from_cli(cli)?
.finalize_with_hints(&envelope, Some(&hint_ctx))
.map_err(AppError::from)
OutputPipeline::from_cli(cli)?.finalize_with_hints(&envelope, Some(&hint_ctx))
}

/// Map RDP errors to user-friendly messages for the cascade command.
Expand Down
4 changes: 1 addition & 3 deletions crates/ff-rdp-cli/src/commands/click.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,7 @@ pub fn run(
let envelope = output::envelope(&result, 1, &meta);

let hint_ctx = HintContext::new(HintSource::Click).with_selector(selector);
OutputPipeline::from_cli(cli)?
.finalize_with_hints(&envelope, Some(&hint_ctx))
.map_err(AppError::from)
OutputPipeline::from_cli(cli)?.finalize_with_hints(&envelope, Some(&hint_ctx))
}

/// Cheap, single-shot existence probe: does `selector` match anything in the
Expand Down
4 changes: 1 addition & 3 deletions crates/ff-rdp-cli/src/commands/computed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ pub fn run(cli: &Cli, selector: &str, props: &[String], include_all: bool) -> Re
let envelope = output::envelope(&results, total, &meta);

let hint_ctx = HintContext::new(HintSource::Computed).with_selector(selector);
OutputPipeline::from_cli(cli)?
.finalize_with_hints(&envelope, Some(&hint_ctx))
.map_err(AppError::from)
OutputPipeline::from_cli(cli)?.finalize_with_hints(&envelope, Some(&hint_ctx))
}

#[cfg(test)]
Expand Down
4 changes: 1 addition & 3 deletions crates/ff-rdp-cli/src/commands/consent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ pub fn run(cli: &Cli) -> Result<(), AppError> {
);
let envelope = output::envelope(&result, 1, &meta);

OutputPipeline::from_cli(cli)?
.finalize(&envelope)
.map_err(AppError::from)
OutputPipeline::from_cli(cli)?.finalize(&envelope)
}

/// One entry in the CMP recognition table: a name plus the URL substrings
Expand Down
4 changes: 1 addition & 3 deletions crates/ff-rdp-cli/src/commands/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ pub fn run(cli: &Cli, level: Option<&str>, pattern: Option<&str>) -> Result<(),
}

let hint_ctx = HintContext::new(HintSource::Console).with_has_errors(error_count > 0);
OutputPipeline::from_cli(cli)?
.finalize_with_hints(&envelope, Some(&hint_ctx))
.map_err(AppError::from)
OutputPipeline::from_cli(cli)?.finalize_with_hints(&envelope, Some(&hint_ctx))
}

/// Prime the WebConsole actor's message cache so a following
Expand Down
4 changes: 1 addition & 3 deletions crates/ff-rdp-cli/src/commands/cookies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ pub fn run(cli: &Cli, name: Option<&str>, include_document_cookie: bool) -> Resu
attach_storage_degraded_warning(&mut envelope, storage_actor_empty, document_cookie_merged);

let hint_ctx = HintContext::new(HintSource::Cookies);
OutputPipeline::from_cli(cli)?
.finalize_with_hints(&envelope, Some(&hint_ctx))
.map_err(AppError::from)
OutputPipeline::from_cli(cli)?.finalize_with_hints(&envelope, Some(&hint_ctx))
}

/// Attach a `warnings[]` degradation marker to the output `envelope` when the
Expand Down
4 changes: 1 addition & 3 deletions crates/ff-rdp-cli/src/commands/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ pub fn run(cli: &Cli) -> Result<(), AppError> {
crate::connection_meta::merge_into(&mut meta, host, port, firefox_version);
let envelope = output::envelope(&results, probes.len(), &meta);

OutputPipeline::from_cli(cli)?
.finalize(&envelope)
.map_err(AppError::from)?;
OutputPipeline::from_cli(cli)?.finalize(&envelope)?;

if any_failed {
Err(AppError::Exit(1))
Expand Down
16 changes: 4 additions & 12 deletions crates/ff-rdp-cli/src/commands/dom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,16 +273,12 @@ pub fn run(
let first = limited.into_iter().next().unwrap_or(Value::Null);
let total = usize::from(!matches!(first, Value::Null));
let envelope = output::envelope(&first, total, &meta);
return OutputPipeline::from_cli(cli)?
.finalize_with_hints(&envelope, Some(&hint_ctx))
.map_err(AppError::from);
return OutputPipeline::from_cli(cli)?.finalize_with_hints(&envelope, Some(&hint_ctx));
}

let envelope =
output::envelope_with_truncation(&json!(limited), shown, total, truncated, &meta);
OutputPipeline::from_cli(cli)?
.finalize_with_hints(&envelope, Some(&hint_ctx))
.map_err(AppError::from)
OutputPipeline::from_cli(cli)?.finalize_with_hints(&envelope, Some(&hint_ctx))
}

/// Extract `__resolver` fields from ARIA-tree results and return them as
Expand Down Expand Up @@ -429,9 +425,7 @@ pub fn run_count(cli: &Cli, selector: &str) -> Result<(), AppError> {
let envelope = output::envelope(&results, usize::try_from(count).unwrap_or(0), &meta);

let hint_ctx = HintContext::new(HintSource::Dom).with_selector(selector);
OutputPipeline::from_cli(cli)?
.finalize_with_hints(&envelope, Some(&hint_ctx))
.map_err(AppError::from)
OutputPipeline::from_cli(cli)?.finalize_with_hints(&envelope, Some(&hint_ctx))
}

/// Wrapper used in tests (ref start defaults to 1, matching --no-daemon behaviour).
Expand Down Expand Up @@ -598,9 +592,7 @@ pub fn run_stats(cli: &Cli) -> Result<(), AppError> {
let envelope = output::envelope(&stats, 1, &meta);

let hint_ctx = HintContext::new(HintSource::DomStats);
OutputPipeline::from_cli(cli)?
.finalize_with_hints(&envelope, Some(&hint_ctx))
.map_err(AppError::from)
OutputPipeline::from_cli(cli)?.finalize_with_hints(&envelope, Some(&hint_ctx))
}

#[cfg(test)]
Expand Down
4 changes: 1 addition & 3 deletions crates/ff-rdp-cli/src/commands/dom_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ pub fn run(cli: &Cli, selector: Option<&str>, depth: u32, max_chars: u32) -> Res
let envelope = output::envelope(&results, 1, &meta);

let hint_ctx = HintContext::new(HintSource::DomTree);
OutputPipeline::from_cli(cli)?
.finalize_with_hints(&envelope, Some(&hint_ctx))
.map_err(AppError::from)
OutputPipeline::from_cli(cli)?.finalize_with_hints(&envelope, Some(&hint_ctx))
}

/// Render DOM tree as indented text to stdout.
Expand Down
4 changes: 1 addition & 3 deletions crates/ff-rdp-cli/src/commands/emulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,7 @@ pub fn run(cli: &Cli, args: &EmulateArgs) -> Result<(), AppError> {
);

let envelope = output::envelope(&results, 1, &meta);
OutputPipeline::from_cli(cli)?
.finalize(&envelope)
.map_err(AppError::from)
OutputPipeline::from_cli(cli)?.finalize(&envelope)
}

/// Send each user-specified field to the actor. Kept separate from
Expand Down
24 changes: 13 additions & 11 deletions crates/ff-rdp-cli/src/commands/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,19 +348,23 @@ pub fn run(
Err(e) => return Err(AppError::from(e)),
};

// If an exception occurred, print it to stderr and exit non-zero.
// If an exception occurred, route it through the standard JSON error
// envelope (iter-141 Theme E) rather than printing bare text to stderr.
// `eval` is a well-formed-but-invalid-*input* case in exactly the sense
// Theme E covers for `eval_or_bail`/`poll_js_condition` (invalid CSS
// selectors, "element not found" polling failures): the script the
// caller supplied threw, which is on them, not an ff-rdp bug — so this
// is `AppError::User`, not the `AppError::Exit(1)` that used to bypass
// `main`'s envelope emission entirely (`ff-rdp eval "throw new
// Error('x')"` printed `error: x` plus a pretty-JSON dump with no JSON
// envelope on stdout at all, while every other command failure emits
// one).
if let Some(ref exc) = eval_result.exception {
let msg = exc
.message
.as_deref()
.unwrap_or("evaluation threw an exception");
let detail = exc.value.to_json();
eprintln!("error: {}", sanitize_for_terminal(msg));
eprintln!(
"{}",
serde_json::to_string_pretty(&detail).unwrap_or_default()
);
return Err(AppError::Exit(1));
return Err(AppError::User(sanitize_for_terminal(msg).into_owned()));
}

// Compute the JSON representation before we potentially move the grip into
Expand Down Expand Up @@ -459,9 +463,7 @@ pub fn run(
} else {
pipeline
};
let pipeline_result = pipeline
.finalize_with_hints(&envelope, Some(&hint_ctx))
.map_err(AppError::from);
let pipeline_result = pipeline.finalize_with_hints(&envelope, Some(&hint_ctx));

// Release the server-side object actor after output is flushed.
//
Expand Down
8 changes: 2 additions & 6 deletions crates/ff-rdp-cli/src/commands/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ pub fn run(cli: &Cli, selectors: &[String], include_hidden: bool) -> Result<(),
let envelope = output::envelope(&empty, 0, &meta);
let first_sel = selectors.first().map_or("*", String::as_str);
let hint_ctx = HintContext::new(HintSource::Geometry).with_selector(first_sel);
return OutputPipeline::from_cli(cli)?
.finalize_with_hints(&envelope, Some(&hint_ctx))
.map_err(AppError::from);
return OutputPipeline::from_cli(cli)?.finalize_with_hints(&envelope, Some(&hint_ctx));
}

let elements_array = geometry["elements"].as_array().cloned().unwrap_or_default();
Expand Down Expand Up @@ -186,9 +184,7 @@ pub fn run(cli: &Cli, selectors: &[String], include_hidden: bool) -> Result<(),

let first_sel = selectors.first().map_or("*", String::as_str);
let hint_ctx = HintContext::new(HintSource::Geometry).with_selector(first_sel);
OutputPipeline::from_cli(cli)?
.finalize_with_hints(&envelope, Some(&hint_ctx))
.map_err(AppError::from)
OutputPipeline::from_cli(cli)?.finalize_with_hints(&envelope, Some(&hint_ctx))
}

/// Render geometry results as human-readable text to stdout.
Expand Down
Loading
Loading