Skip to content

Latest commit

 

History

History
53 lines (35 loc) · 2.13 KB

File metadata and controls

53 lines (35 loc) · 2.13 KB

The goal is to be CSS-spec compliant.

After doing changes, always run tests.

When writing code, please first write a test (test driven development), and then try to fix/implement a feature.

When fixing a bug, or adding features, make sure to add tests for these.

When doing changes, please also see if offscreen rendering outputs correct result. cargo run --bin offscreen_render -- ui_demo.html /tmp/render.svg When visual output doesn't match expectations but tests somehow pass, analyze why tests didn't catch the regression/bug.

Layout Testing

Layout tests use Chromium baseline comparison (tests/layout_comparison_tests.rs). This compares SVG output from Graviton against Chromium-rendered baselines.

Important guidelines for layout tests:

  1. Do NOT use text content in layout tests - Font rendering is not reliable across platforms. Instead, use display: inline elements with explicit dimensions to simulate inline content behavior.

  2. Test fixtures go in test_fixtures/ directory:

    • *.html - HTML test cases
    • *.svg - Chromium baseline SVGs (generated by scripts/generate_baselines.js)
  3. To add a new layout test:

    • Create test_fixtures/your_test.html
    • Run cd scripts && npm run generate to generate Chromium baseline
    • Add test function in tests/layout_comparison_tests.rs
  4. Text-specific tests (tests/text_layout_tests.rs) are for testing text preprocessing (word splitting, measurement, ascent) - not layout positioning. Layout positioning of text is validated through the unified inline layout algorithm which is tested via baseline comparison with inline elements.


DevTools Protocol

Graviton provides a CDP-compatible devtools agent for programmatic page inspection.

cargo run --bin devtools_agent -- page.html [width] [height]

Reads JSON commands from stdin, writes responses to stdout. Uses standard Chrome DevTools Protocol format.

Supported domains: DOM, CSS, Page, Input, Runtime, Overlay

See: docs/devtools_protocol.md for full reference.