wiki:Writing Layout Tests for DumpRenderTree

Version 1 (modified by, 16 years ago) (diff)

Copied from Google cache of with minimal modifications and reformatting. People who contributed to this page include Eric Seidel and Geoff Garen.

Writing good test cases

Should have some tips here about how to make a test which is easy to know when it succeeds, things like a 100x100 green block, just printing SUCCESS or FAILURE, and using dumpAsText().

Should remind folks to write tests that work both in Safari and in DRT. The trick is to test for the existence of a special object like layoutTestController before using it. An example:

if (window.layoutTestController)

DumpRenderTree JavaScript Environment

DumpRenderTree exposes a number of additional JavaScript objects in the testing environment.

These can be used to perform additional debugging-related tasks.



Call this method to make your test output plain text instead of a render tree. This is useful if your test prints messages rather than testing fancy layout. For an example of how to print to a console in a test, check out LayoutTests/fast/dom/ Element/attribute-uppercase.html.

waitUntilDone() and notifyDone()

By default, DumpRenderTree dumps each test file immediately after the document has loaded and the load event handlers have executed. If your test needs to do further processing after loading -- for example, waiting for a timer to fire -- call layoutTestController.waitUntilDone() to tell DumpRenderTree to delay its dump, and then call notifyDone when your results are ready.


mouseMoveTo(x, y)

Used to change the current mouse position.


Jumps the current event time forward by a specified number of miliseconds.


Sends a mouseDown event to the WebView at the current mouse position.


Sends a mouseUp event to the WebView at the current mouse position.


Call mouseClick only if you need to simulate a click in a platform widget. Otherwise, use mouseDown and mouseUp.


Needs to be filled in.











Needs to be filled in.


The navigation controller is currently broken. Need to add a bug number.

evalAfterBackForwardNavigation(script [, destination])

To test a bug having to do with the loader or the back/forward cache, call this method to run a script after executing a back/forward navigation. The first argument is the script to run, and the second argument is the page to load during the navigation. The second argument is optional. It defaults to about:blank.

Writing tests which require network access

run-webkit-tests (the script which runs DumpRenderTree) also launches a local Apache daemon (httpd) to allow real local-only network based testing (for incremental loads, XMLHttpRequest, etc.) ap needs to document how best to use this.