Changes between Initial Version and Version 1 of Writing Layout Tests for DumpRenderTree

Nov 12, 2006 8:45:42 AM (16 years ago)

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


  • Writing Layout Tests for DumpRenderTree

    v1 v1  
     2= Writing good test cases =
     4''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()`.''
     6''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:''
     8if (window.layoutTestController)
     9    layoutTestController.dumpAsText()
     12= DumpRenderTree JavaScript Environment =
     14DumpRenderTree exposes a number of additional JavaScript objects in the testing environment.
     16These can be used to perform additional debugging-related tasks.
     18== `window.layoutTestController` ==
     20=== `dumpAsText()` ===
     22Call 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`.
     24=== `waitUntilDone()` and `notifyDone()` ===
     26By 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.
     28== `window.eventSender` ==
     30=== `mouseMoveTo(x, y)` ===
     32Used to change the current mouse position.
     34=== `leapForward(ms)` ===
     36Jumps the current event time forward by a specified number of miliseconds.
     38=== `mouseDown()` ===
     40Sends a mouseDown event to the WebView at the current mouse position.
     42=== `mouseUp()` ===
     44Sends a mouseUp event to the WebView at the current mouse position.
     46=== `mouseClick()` ===
     48Call `mouseClick` only if you need to simulate a click in a platform widget. Otherwise, use `mouseDown` and `mouseUp`.
     50== `window.textInputController` ==
     52''Needs to be filled in.''
     54=== `insertText` ===
     56=== `doCommand` ===
     58=== `setMarkedText` ===
     60=== `substringFromRange` ===
     62=== `attributedSubstringFromRange` ===
     64=== `firstRectForCharacterRange` ===
     66=== `characterIndexForPoint` ===
     68=== `makeAttributedString` ===
     70== `window.appleScriptController` ==
     72=== `doJavaScript()` ===
     74''Needs to be filled in.''
     76== `window.navigationController` ==
     78'''The navigation controller is currently broken.''' ''Need to add a bug number.''
     80=== `evalAfterBackForwardNavigation(script [, destination])` ===
     82To 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`.
     84= Writing tests which require network access =
     86`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.