= Benefits of dumpAsMarkup Tests = * Platform independent - dumpAsMarkup outputs plain text as the expected results and can be shared among all platforms. * Easier to read expected results - dumpAsMarkup's output is HTML with extra annotation. = Limitation = * Can't test rendering - Since dumpAsMarkup test does not produce .png files or render tree outputs, we can't use dumpAsMarkup to test the correctness of rendering. = How to Use = Including the following line makes your layout test a dumpAsMarkup test: {{{ }}} dump-as-markup.js then outputs the DOM tree on the page load on DRT. If your test requires the test to be continued after the page load (e.g. uses setTimeout), then call Markup.waitUntilDone() before the page loads and Markup.notifyDone() to output the results and finish the test. Markup's waitUntilDone and notifyDone automatically calls layoutTestController's counterparts. For example, if I have: {{{
This is a dumpAsMarkup test.
}}} I get: {{{ | | |
WebKit is awesome

But cluttered expected result sucks :(

}}} I get: {{{ This is a dumpAsMarkup test. | | href="http://webkit.org/" | "WebKit" | " is " | | "awesome" }}} Note "This is a dumpAsMarkup test." is added by Markup.description. The sentence will not be printed on DRT if we had it in a div like the earlier example because the document body is replaced by the output. == Dump Multiple Times == To dump the entire DOM or a subtree multiple times, call Markup.dump(, ). For example, if I have: {{{
WebKit is awesome

But cluttered expected result sucks :(

}}} I get: {{{ This test calls dump twice. before change:
<#text>WebKit <#text> is <#text>awesome
after change:
<#text>WebKit <#text> is <#text>awesome because of you!
}}} Notice that I call dump twice and the DOM is dumped exactly twice (onload didn't dump). You may still use Markup.waitUntilDone() and Markup.notifyDone() to avoid DRT finishing the test prematurely. '''Note''': as is implemented, the script adds pre element at the end of the document temporarily when you call dump and your script should not interfere with those pre tags.