= 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 testRunner's counterparts. For example, if I have: {{{
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. Also note that the auto dump on the page load is disabled but you can still call Markup.waitUntilDone() and Markup.notifyDone() to avoid DRT finishing the test prematurely. == Dump Multiple Times == To dump the entire DOM or a subtree multiple times, call Markup.dump(But cluttered expected result sucks :(
}}} I get: {{{ This test calls dump twice. before change: | | href="http://webkit.org/" | "WebKit" | " is " | | "awesome" after change: | | href="http://webkit.org/" | "WebKit" | " is " | | "awesome because of you!" }}}