All checks were successful
ci / fast (linux) (push) Successful in 6m46s
Install BMAD workflow framework with agent commands and templates. Create product brief, PRD, project context, and architecture decision document covering networking/persistence strategy, JS engine evolution path, threading model, web_api scaling, system integration, and tab/process model. Add generated project documentation (architecture overview, component inventory, development guide, source tree analysis). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5.8 KiB
5.8 KiB
Development Guide — rust_browser
Generated: 2026-03-05 | Scan Level: Deep
Prerequisites
- Rust toolchain — Stable channel (pinned via
rust-toolchain.toml)- Components:
rustfmt,clippy
- Components:
justcommand runnercargo install just- Python 3 — Required for WPT/Test262 scripts only
Getting Started
Clone and Build
git clone <repo-url> rust_browser
cd rust_browser
cargo build -p app_browser
Run the Browser
# Show CLI help
cargo run -p app_browser -- --help
# Open a URL in windowed mode
cargo run -p app_browser -- https://example.com
# Open with dark mode
cargo run -p app_browser -- --dark https://example.com
# Render to layout dump (no window)
cargo run -p app_browser -- --render tests/goldens/fixtures/001-empty.html
# Render to PNG
cargo run -p app_browser -- --render tests/goldens/fixtures/001-empty.html --png
Development Commands
All primary commands are in the justfile:
| Command | Purpose | Duration |
|---|---|---|
just ci |
Full CI pipeline (fmt + lint + test + policy + metrics) | ~1 min |
just test |
Run all tests (workspace + WPT + JS262 manifests) | ~30s |
just lint |
Run clippy with warnings denied | ~15s |
just fmt |
Check formatting (no changes) | ~5s |
just fix |
Auto-fix formatting | ~5s |
just policy |
Run safety checks (unsafe, deps, file sizes) | ~5s |
just metrics |
Report project metrics | ~5s |
just san |
Run sanitizers (Linux nightly only) | ~5min |
CI Workflow
Always run just ci after every code change. It takes about 1 minute.
# Capture output for review
just ci 2>&1 | tee /tmp/ci-output.txt
Testing
Test Layers
-
Unit tests — Inline
#[cfg(test)] mod testsin crate source filescargo test -p <crate_name> -
Integration tests —
tests/*.rs(each registered as[[test]]in rootCargo.toml)cargo test -p rust_browser --test goldens cargo test -p rust_browser --test js_tests -
Golden tests — Layout tree and display list regression tests
cargo test -p rust_browser --test goldens # Regenerate expected outputs: cargo test -p rust_browser --test regen_goldens -- --ignored --nocapture -
JS262 conformance — Test262-inspired JavaScript conformance suite
# Run vendored tier-1 suite cargo test -p rust_browser --test js262_harness js262_suite_matches_manifest_expectations -- --nocapture # Promote passing known_fail tests just js262-status promote --id <test-id> -
WPT harness — Web Platform Tests
cargo test -p rust_browser --test wpt_harness wpt_suite_matches_manifest_expectations -- --nocapture -
Full Test262 suite (requires upstream clone)
just clone-test262 # Clone tc39/test262 just test262-scan # Generate manifest just test262-full # Run full suite just triage-test262-full # Promote newly passing tests
Adding New Integration Tests
- Create
tests/my_test.rs - Add to root
Cargo.toml:[[test]] name = "my_test" path = "tests/my_test.rs"
Test Principles
- Every bug fix requires a regression test
- Unit tests go inline in the source module (test private APIs)
- Integration tests go in
tests/(test public cross-crate behavior) - Golden tests for any rendering behavior change
Project Structure Rules
Layer Dependencies
Layer 3: app_browser → can depend on anything below
Layer 2: browser_runtime → can depend on Layer 1 and 0
Layer 1: engine crates → can depend on Layer 1 and 0 (no upward deps)
Layer 0: shared → no internal dependencies
Enforced by scripts/check_deps.sh — runs in CI.
Unsafe Code Policy
- Forbidden by default —
unsafe_code = "forbid"in workspace lints - Allowed only in:
crates/platform/andcrates/graphics/ - Enforced by
scripts/check_unsafe.sh— runs in CI
New Dependencies
- Require rationale in PR description
- Must pass
deny.tomllicense/advisory checks
Common Development Tasks
Adding a New CSS Property
- Add parsing in
crates/css/(tokenizer + parser) - Add selector/cascade support in
crates/selectors/if needed - Add computed style type in
crates/style/(ComputedStyles) - Implement layout behavior in
crates/layout/ - Add display list generation in
crates/display_list/if visual - Update
docs/CSS2.1_Implementation_Checklist.md - Add golden tests for the new property
- Run
just ci
Adding a New JavaScript Feature
- Add tokenization in
crates/js_parser/(if new syntax) - Add AST node in
crates/js_parser/ - Implement execution in
crates/js_vm/ - Add unit tests inline
- Add Test262 conformance tests to the manifest
- Update
docs/js_feature_matrix.md - Run
just ci
Adding a New HTML Element
- Add parsing support in
crates/html/ - Add DOM representation in
crates/dom/if needed - Add default styling in
crates/style/(UA stylesheet) - Implement layout behavior in
crates/layout/ - Update
docs/HTML5_Implementation_Checklist.md - Add golden tests
- Run
just ci
Investigating Rendering Issues
Use the investigation workflow:
# Creates a report at investigations/<site>/report.md
Existing investigations: acid2, google, moldybits, slashdot, youtube
Code Style
- Formatting:
rustfmt(checked byjust fmt) - Linting:
clippywith all warnings denied - Naming: Standard Rust conventions (snake_case functions, PascalCase types)
- Error handling:
anyhowfor application errors,thiserrorfor library errors - Logging:
tracingcrate for structured logging
Project Metrics
Run just metrics to see:
- Lines of code per crate
- Test count
- Dependency count
- File sizes