browser-tester
A deterministic browser-like testing crate implemented entirely in Rust.
- Japanese README: translations/ja/README.md
- Architecture: doc/architecture.md
- Capability matrix: doc/capability-matrix.md
- Mock guide: doc/mock-guide.md
- HTML spec conformance roadmap: doc/html-spec-conformance-roadmap.md
- Developed by Finite Field, K.K.
Purpose
- Run DOM and script tests deterministically in a single process.
- Test browser-like interactions without an external browser, WebDriver, or Node.js.
- Keep time, randomness, and test-only browser APIs under Rust-side control.
Quick Start
use Harness;
Core API
Constructors:
Harness::from_html(html)Harness::from_html_with_url(url, html)Harness::from_html_with_local_storage(html, &[("key", "value"), ...])Harness::from_html_with_url_and_local_storage(url, html, &[("key", "value"), ...])
Actions:
type_textset_select_valueset_input_filesset_checkedclickpress_entercopypastecutfocusblursubmitdispatchdispatch_keyboard
Assertions:
assert_textassert_valueassert_checkedassert_existsdump_dom
Time and scheduling:
now_msadvance_timeadvance_time_torun_due_timersrun_next_timerrun_next_due_timerflushpending_timersclear_timerclear_all_timers
Trace and diagnostics:
enable_tracetake_trace_logsset_trace_stderrset_trace_eventsset_trace_timersset_trace_log_limit
Test Mocks
Main mock families:
fetchconfirm/prompt/alertwindow.print()locationand history-backed mock pagesnavigator.clipboardlocalStorageseed state- download capture
input[type="file"]matchMedia
Full API details and examples are in doc/mock-guide.md.
Minimal fetch mock example:
use Harness;
Runtime Constraints
evalis intentionally not implemented.Date.now()andperformance.now()are backed by a fake clock.Math.random()is deterministic and can be reseeded withset_random_seed.- Real network I/O is not the target.
fetchshould be used with mocks. - Rendering, layout, style application, and the accessibility tree are intentionally partial.
- This crate provides a deterministic browser-like subset, not full browser compatibility.
Form submission policy:
Harness::submit(selector)follows a user-like submission path.- Script-side
form.requestSubmit([submitter])also follows the user-like path. - Script-side
form.submit()bypasses validation and does not dispatchsubmit.
Running Tests
Run the main test suite:
Run by test layer:
Run repository maintenance guardrails:
Regular integration tests are grouped under a single integration_suite target to reduce
Cargo's per-file test crate and link overhead:
Minimal public contract coverage for stable Harness APIs:
If you only want to confirm the contract target still builds:
Property and fuzz tests for parser and runtime:
# default: parser=256 cases, runtime=128 cases
# quick profile
BROWSER_TESTER_PROPTEST_CASES=64 \
BROWSER_TESTER_RUNTIME_PROPTEST_CASES=64 \
# deep profile
BROWSER_TESTER_PROPTEST_CASES=1024 \
BROWSER_TESTER_RUNTIME_PROPTEST_CASES=512 \
BROWSER_TESTER_PROPTEST_CASES: default parser-oriented case countBROWSER_TESTER_RUNTIME_PROPTEST_CASES: runtime action case count- shrunk failing seeds are stored in:
tests/proptest-regressions/parser_property_fuzz_test.txttests/proptest-regressions/runtime_property_fuzz_test.txt
Documentation
- Architecture and subsystem overview: doc/architecture.md
- Capability classification: doc/capability-matrix.md
- File-size guard and allowlist policy: doc/file-size-guard.md
- Public API checklist: doc/public-api-checklist.md
- Subsystem ownership map: doc/subsystem-map.md
- Test taxonomy and placement rules: doc/test-taxonomy.md
- Mock APIs and examples: doc/mock-guide.md
- HTML conformance roadmap: doc/html-spec-conformance-roadmap.md
- WPT audit inventory: doc/p3-wpt-audit-inventory.md