Reference Test Extensibility

Testing frameworks tend to outlive the applications they test, making extensibility a critical attribute of their design. Extensibility is particularly important for reference testing because it must continue to adapt to the ever-changing open web. Although reference tests like the one in Table 19-1 were all you needed in 1996, today’s web pages exhibit far more complex behaviors, and the tests to mimic those behaviors have evolved as well. Reference tests continue to adapt to meet the challenges presented by the Web in order to maintain a comprehensive test suite for the rendering engine.

Asynchronous Tests

The Web is no longer a static playground. Pages modify their DOMs, adding and removing elements and style rules, and the browser must adapt on the fly. To test this behavior, “reftest-wait” tests were developed. In this class of tests, the rendered canvas is not sent to the compareCanvas function when the onload event fires. Instead, the test author uses JavaScript to indicate to the reference test framework when to snapshot the file for comparison. This allows us to craft tests that can make use of the standard onload handler ourselves, as many web pages do (Table 19-3).

Table 19-3. Asynchronous reference test

Test

Reference

<!DOCTYPE HTML> <html class="reftest-wait"> <head> <style> body::before { content:"Before"; border:inherit; } .cl::after { display:block; content:"After"; } </style> <script> function fixupDOM() { document.body.setAttribute("style", ...

Get Beautiful Testing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.