A layout test is simply a web page. The layout test machinery renders the web page, and then dumps the internal representation, the render tree, with details of the layout. This lets engineers working on the project know if they do anything that changes the layout. Once we get a test rendering properly, we check it in as part of the layout test suite.
The following are some guidelines to follow when writing new layout tests:
- The test should be the smallest possible code fragment that tests the feature.
- The test should fit on one page (unless of course it's testing scrolling).
- The test should clearly describe what feature it is testing.
- The test should clearly describe the expected result. It should be possible through visual inspection alone to determine that the test has failed.
An example of a layout test that follows these guidelines is fast/events/event-creation.html.
The CSS working group has an excellent document on test writing guidelines for CSS tests.