1 Layout Engine Visual Tests (reftest)
2 ====================================
4 Layout Engine Visual Tests (reftest)
5 L. David Baron <dbaron@dbaron.org>, Mozilla Corporation
8 This code is designed to run tests of Mozilla's layout engine. These
9 tests consist of an HTML (or other format) file along with a reference
10 in the same format. The tests are run based on a manifest file, and for
11 each test, PASS or FAIL is reported, and UNEXPECTED is reported if the
12 result (PASS or FAIL) was not the expected result noted in the manifest.
14 Images of the display of both tests are captured, and most test types
15 involve comparing these images (e.g., test types == or !=) to determine
16 whether the test passed. The captures of the tests are taken in a
17 viewport that is 800 pixels wide and 1000 pixels tall, so any content
18 outside that area will be ignored (except for any scrollbars that are
19 displayed). Ideally, however, tests should be written so that they fit
20 within 600x600, since we may in the future want to switch to 600x600 to
21 match http://lists.w3.org/Archives/Public/www-style/2012Sep/0562.html .
26 Writing HTML tests where the reference rendering is also in HTML is
27 harder than simply writing bits of HTML that can be regression-tested by
28 comparing the rendering of an older build to that of a newer build
29 (perhaps using stored reference images from the older build). However,
30 comparing across time has major disadvantages:
32 * Comparisons across time either require two runs for every test, or
33 they require stored reference images appropriate for the platform and
34 configuration (often limiting testing to a very specific
37 * Comparisons across time may fail due to expected changes, for
38 example, changes in the default style sheet for HTML, changes in the
39 appearance of form controls, or changes in default preferences like
40 default font size or default colors.
42 Using tests for which the pass criteria were explicitly chosen allows
43 running tests at any time to see whether they still pass.
48 The test manifest format is a plain text file. A line starting with a
49 ``"#"`` is a comment. Lines may be commented using whitespace followed by
50 a ``"#"`` and the comment. Each non-blank line (after removal of comments)
51 must be one of the following:
53 Inclusion of another manifest
54 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56 ``<skip-type>* include <relative_path>``
58 ``<skip-type>`` is one of the skip or skip-if items (see their definitions
59 in ``<failure-type>`` below). If any of the skip types evaluate to true (i.e.
60 they are a plain ``skip`` or they are a ``skip-if`` with a condition that
61 evaluates to true), then the include statement is skipped. Otherwise,
62 reftests in the specified manifest are included in the set of reftests
68 ``[ <failure-type> | <preference> ]* [<http>] <type> <url> <url_ref>``
72 a. ``<failure-type>`` (optional) is one of the following:
75 The test passes if the images of the two renderings DO NOT meet the
76 conditions specified in the ``<type>``.
78 ``fails-if(condition)``
79 If the condition is met, the test passes if the images of the two
80 renderings DO NOT meet the conditions of ``<type>``. If the condition
81 is not met, the test passes if the conditions of ``<type>`` are met.
84 The test fails or times out if the reftest window is not focused.
87 The results of the test are random and therefore not to be considered in the output.
89 ``random-if(condition)``
90 The results of the test are random if a given condition is met.
93 This test may fail silently, and if that happens it should count as if
94 the test passed. This is useful for cases where silent failure is the
95 intended behavior (for example, in an out of memory situation in
96 JavaScript, we stop running the script silently and immediately, in
97 hopes of reclaiming enough memory to keep the browser functioning).
99 ``silentfail-if(condition)``
100 This test may fail silently if the condition is met.
103 This test should not be run. This is useful when a test fails in a
104 catastrophic way, such as crashing or hanging the browser. Using
105 ``skip`` is preferred to simply commenting out the test because we
106 want to report the test failure at the end of the test run.
108 ``skip-if(condition)``
109 If the condition is met, the test is not run. This is useful if, for
110 example, the test crashes only on a particular platform (i.e. it
111 allows us to get test coverage on the other platforms).
114 The test may take a long time to run, so run it if slow tests are
115 either enabled or not disabled (test manifest interpreters may choose
116 whether or not to run such tests by default).
118 ``slow-if(condition)``
119 If the condition is met, the test is treated as if ``slow`` had been
120 specified. This is useful for tests which are slow only on particular
121 platforms (e.g. a test which exercised out-of-memory behavior might be
122 fast on a 32-bit system but inordinately slow on a 64-bit system).
124 ``fuzzy(minDiff-maxDiff,minPixelCount-maxPixelCount)``
125 This allows a test to pass if the pixel value differences are between
126 ``minDiff`` and ``maxDiff``, inclusive, and the total number of
127 different pixels is between ``minPixelCount`` and ``maxPixelCount``,
128 inclusive. It can also be used with ``!=`` to ensure that the
129 difference is outside the specified interval. Note that with ``!=``
130 tests the minimum bounds of the ranges must be zero.
132 Fuzzy tends to be used for two different sorts of cases. The main
133 case is tests that are expected to be equal, but actually fail in a
134 minor way (e.g., an antialiasing difference), and we want to ensure
135 that the test doesn't regress further so we don't want to mark the
136 test as failing. For these cases, test annotations should be the
137 tightest bounds possible: if the behavior is entirely deterministic
138 this means a range like ``fuzzy(1-1,8-8)``, and if at all possible,
139 the ranges should not include 0. In cases where the test only
140 sometimes fails, this unfortunately requires using 0 in both ranges,
141 which means that we won't get reports of an unexpected pass if the
142 problem is fixed (allowing us to remove the ``fuzzy()`` annotation
143 and expect the test to pass from then on).
145 The second case where fuzzy is used is tests that are supposed
146 to allow some amount of variability (i.e., tests where the
147 specification allows variability such that we can't assert
148 that all pixels are the same). Such tests should generally be
149 avoided (for example, by covering up the pixels that can vary
150 with another element), but when they are needed, the ranges in
151 the ``fuzzy()`` annotation should generally include 0.
153 ``fuzzy-if(condition,minDiff-maxDiff,minPixelCount-maxPixelCount)``
154 If the condition is met, the test is treated as if ``fuzzy`` had been
155 specified. This is useful if there are differences on particular
156 platforms. See ``fuzzy()`` above.
158 ``require-or(cond1&&cond2&&...,fallback)``
159 Require some particular setup be performed or environmental
160 condition(s) made true (eg setting debug mode) before the test
161 is run. If any condition is unknown, unimplemented, or fails,
162 revert to the fallback failure-type.
163 Example: ``require-or(debugMode,skip)``
166 Loading the test and reference is known to assert exactly
168 NOTE: An asserts() notation with a non-zero count or maxCount
169 suppresses use of a cached canvas for the test with the
170 annotation. However, if later occurrences of the same test
171 are not annotated, they will use the cached canvas
172 (potentially from the load that asserted). This allows
173 repeated use of the same test or reference to be annotated
174 correctly (which may be particularly useful when the uses are
175 in different subdirectories that can be tested independently),
176 but does not force them to be, nor does it force suppression
177 of caching for a common reference when it is the test that
180 ``asserts-if(condition,count)``
181 Same as above, but only if condition is true.
183 ``asserts(minCount-maxCount)``
184 Loading the test and reference is known to assert between
185 minCount and maxCount times, inclusive.
186 NOTE: See above regarding canvas caching.
188 ``asserts-if(condition,minCount-maxCount)``
189 Same as above, but only if condition is true.
192 Disables the autofuzzing behaviour hard-coded in the reftest harness
193 for specific platform configurations. The autofuzzing is intended to
194 compensate for inherent nondeterminism that results in intermittently
195 fuzzy results (with small amounts of fuzz) across many/all tests on
196 a given platform. Specifying 'noautofuzz' on the test will disable
197 the autofuzzing for that test and require an exact match.
199 Conditions are JavaScript expressions *without spaces* in them.
200 They are evaluated in a sandbox in which a limited set of
201 variables are defined. See the BuildConditionSandbox function in
202 ``layout/tools/reftest.js`` for details.
204 Examples of using conditions: ::
207 fails-if(winWidget) == test reference
208 asserts-if(cocoaWidget,2) load crashtest
211 b. ``<preference>`` (optional) is a string of the form
213 ``pref(<name>,<value>)``
215 ``test-pref(<name>,<value>)``
217 ``ref-pref(<name>,<value>)``
219 where ``<name>`` is the name of a preference setting, as seen in
220 about:config, and ``<value>`` is the value to which this preference
221 should be set. ``<value>`` may be a boolean (true/false), an integer,
222 or a quoted string *without spaces*, according to the type of the
225 The preference will be set to the specified value prior to
226 rendering the test and/or reference canvases (pref() applies to
227 both, test-pref() only to the test, and ref-pref() only to the
228 reference), and will be restored afterwards so that following
229 tests are not affected. Note that this feature is only useful for
230 "live" preferences that take effect immediately, without requiring
233 c. ``<http>``, if present, is one of the strings (sans quotes) "HTTP" or
234 "HTTP(..)" or "HTTP(../..)" or "HTTP(../../..)", etc. , indicating that
235 the test should be run over an HTTP server because it requires certain
236 HTTP headers or a particular HTTP status. (Don't use this if your test
237 doesn't require this functionality, because it unnecessarily slows down
240 With "HTTP", HTTP tests have the restriction that any resource an HTTP
241 test accesses must be accessed using a relative URL, and the test and
242 the resource must be within the directory containing the reftest
243 manifest that describes the test (or within a descendant directory).
244 The variants "HTTP(..)", etc., can be used to relax this restriction by
245 allowing resources in the parent directory, etc.
247 To modify the HTTP status or headers of a resource named FOO, create a
248 sibling file named FOO^headers^ with the following contents:
255 A line of the form "HTTP ###[ <description>]", where ### indicates
256 the desired HTTP status and <description> indicates a desired HTTP
257 status description, if any. If this line is omitted, the default is
261 A line in standard HTTP header line format, i.e.
262 "Field-Name: field-value". You may not repeat the use of a Field-Name
263 and must coalesce such headers together, and each header must be
264 specified on a single line, but otherwise the format exactly matches
265 that from HTTP itself.
267 HTTP tests may also incorporate SJS files. SJS files provide similar
268 functionality to CGI scripts, in that the response they produce can be
269 dependent on properties of the incoming request. Currently these
270 properties are restricted to method type and headers, but eventually
271 it should be possible to examine data in the body of the request as
272 well when computing the generated response. An SJS file is a JavaScript
273 file with a .sjs extension which defines a global `handleRequest`
274 function (called every time that file is loaded during reftests) in this
277 function handleRequest(request, response)
279 response.setStatusLine(request.httpVersion, 200, "OK");
281 // You *probably* want this, or else you'll get bitten if you run
282 // reftest multiple times with the same profile.
283 response.setHeader("Cache-Control", "no-cache");
285 response.write("any ASCII data you want");
287 var outputStream = response.bodyOutputStream;
288 // ...anything else you want to do, synchronously...
291 For more details on exactly which functions and properties are available
292 on request/response in handleRequest, see the nsIHttpRe(quest|sponse)
293 definitions in ``netwerk/test/httpserver/nsIHttpServer.idl``.
295 HTTP tests can also make use of example.org URIs in order to test cross
296 site behaviour. "example.org/filename" will access filename in the same
297 directly as the current reftest. (Not currently implemented for android.)
299 d. ``<type>`` is one of the following:
302 The test passes if the images of the two renderings are the SAME.
305 The test passes if the images of the two renderings are DIFFERENT.
308 The test passes unconditionally if the page loads. url_ref must be
309 omitted, and the test cannot be marked as fails or random. (Used to
310 test for crashes, hangs, assertions, and leaks.)
313 The loaded page records the test's pass or failure status in a
314 JavaScript data structure accessible through the following API.
316 ``getTestCases()`` returns an array of test result objects
317 representing the results of the tests performed by the page.
319 Each test result object has two methods:
321 ``testPassed()`` returns true if the test result object passed,
322 otherwise it returns false.
324 ``testDescription()`` returns a string describing the test
327 ``url_ref`` must be omitted. The test may be marked as fails or
328 random. (Used to test the JavaScript Engine.)
331 The test passes if the printouts (as PDF) of the two renderings
332 are the SAME by applying the following comparisons:
334 - The number of pages generated for both printouts must match.
335 - The text content of both printouts must match (rasterized text
336 does not match real text).
338 You can specify a print range by setting the reftest-print-range
339 attribute on the document element. Example: ::
341 <html reftest-print-range="2-3">
345 The following example would lead to a single page print: ::
347 <html reftest-print-range="2-2">
350 You can also print selected elements only: ::
352 <html reftest-print-range="selection">
355 Make sure to include code in your test that actually selects something.
357 Future additions to the set of comparisons might include:
359 - Matching the paper size
360 - Validating printed headers and footers
361 - Testing (fuzzy) position of elements
362 - Testing specific print related CSS properties
364 The main difference between ``print`` and ``==/!=`` reftests is that
365 ``print`` makes us compare the structure of print results (by parsing
366 the output PDF) rather than taking screenshots and comparing pixel
367 values. This allows us to test for common printing related issues
368 like text being rasterized when it shouldn't. This difference in
369 behavior is also why this is its own reftest operator, rather than
370 a flavor of ``==/!=``. It would be somewhat misleading to list these
371 print reftests as ``==/!=``, because they don't actually check for
374 See the chapter about Pagination Tests if you are looking for testing
375 layout in pagination mode.
377 e. ``<url>`` is either a relative file path or an absolute URL for the
380 f. ``<url_ref>`` is either a relative file path or an absolute URL for
383 The only difference between ``<url>`` and ``<url_ref>`` is that results of
384 the test are reported using ``<url>`` only.
386 Specification of a url prefix
387 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
389 ``url-prefix <string>``
391 ``<string>`` will be prepended to relative ``<url>`` and ``<url_ref>`` for
392 all following test items in the manifest.
394 ``<string>`` will not be prepended to the relative path when including
395 another manifest, e.g. ``include <relative_path>.``
397 ``<string>`` will not be prepended to any ``<url>`` or ``<url_ref>`` matching
398 the pattern ``/^\w+:/``. This will prevent the prefix from being applied to
399 any absolute url containing a protocol such as ``data:``, ``about:``, or
402 While the typical use of url-prefix is expected to be as the first line of
403 a manifest, it is legal to use it anywhere in a manifest. Subsequent uses
404 of url-prefix overwrite any existing values.
406 Specification of defaults
407 ~~~~~~~~~~~~~~~~~~~~~~~~~
409 ``defaults [<failure-type> | <preference> | <http>]``
411 where ``<failure-type>``, ``<preference>``, and ``<http>`` are defined above.
413 The default settings will be used for all following test items in the manifest.
414 Any test specific settings will override the defaults, just as later items
415 within a line override earlier ones.
417 A defaults line with no settings will reset the defaults to be empty.
419 As with url-prefix, defaults will often be used at the start of a manifest file
420 so that it applies to all test items, but it is legal for defaults to appear
421 anywhere in the manifest. A subsequent defaults will reset any previous default
422 settings and overwrite them with the new settings.
424 It is invalid to set non-skip defaults before an include line, just as it is
425 invalid to specify non-skip settings directly on the include line itself. If a
426 manifest needs to use both defaults and include, the include should appear
427 before the defaults. If it's important to specify the include later on in the
428 manifest, a blank defaults line directly preceding the include can be used to
431 This test manifest format could be used by other harnesses, such as ones
432 that do not depend on XUL, or even ones testing other layout engines.
437 (If you're not using a DEBUG build, first set browser.dom.window.dump.enabled,
438 devtools.console.stdout.chrome and devtools.console.stdout.content to true (in
439 about:config, in the profile you'll be using to run the tests).
440 Create the option as a new boolean if it doesn't exist already. If you skip
441 this step you won't get any output in the terminal.)
443 At some point in the future there will hopefully be a cleaner way to do
444 this. For now, go to your object directory, and run (perhaps using
445 ``MOZ_NO_REMOTE=1`` or the ``-profile <directory>`` option) ::
447 ./firefox -reftest /path/to/srcdir/mozilla/layout/reftests/reftest.list > reftest.out
449 and then search/grep reftest.out for "UNEXPECTED".
451 There are two scripts provided to convert the reftest.out to HTML.
452 clean-reftest-output.pl converts reftest.out into simple HTML, stripping
453 lines from the log that aren't relevant. reftest-to-html.pl converts
454 the output into html that makes it easier to visually check for
460 This framework is capable of testing many areas of the layout engine.
461 It is particularly well-suited to testing dynamic change handling (by
462 comparison to the static end-result as a reference) and incremental
463 layout (comparison of a script-interrupted layout to one that was not).
464 However, it is also possible to write tests for many other things that
465 can be described in terms of equivalence, for example:
467 * CSS cascading could be tested by comparing the result of a
468 complicated set of style rules that makes a word green to <span
469 style="color:green">word</span>.
471 * <canvas> compositing operators could be tested by comparing the
472 result of drawing using canvas to a block-level element with the
473 desired color as a CSS background-color.
475 * CSS counters could be tested by comparing the text output by counters
476 with a page containing the text written out
478 * complex margin collapsing could be tested by comparing the complex
479 case to a case where the margin is written out, or where the margin
480 space is created by an element with 'height' and transparent
483 When it is not possible to test by equivalence, it may be possible to
484 test by non-equivalence. For example, testing justification in cases
485 with more than two words, or more than three different words, is
486 difficult. However, it is simple to test that justified text is at
487 least displayed differently from left-, center-, or right-aligned text.
492 When writing tests for this framework, it is important for the test to
493 depend only on behaviors that are known to be correct and permanent.
494 For example, tests should not depend on default font sizes, default
495 margins of the body element, the default style sheet used for HTML, the
496 default appearance of form controls, or anything else that can be
499 In general, the best way to achieve this is to make the test and the
500 reference identical in as many aspects as possible. For example:
504 <div style="color:green"><table><tr><td><span>green
505 </span></td></tr></table></div>
507 Good reference markup: ::
509 <div><table><tr><td><span style="color:green">green
510 </span></td></tr></table></div>
512 BAD reference markup: ::
514 <!-- 3px matches the default cellspacing and cellpadding -->
515 <div style="color:green; padding: 3px">green
520 <!-- span doesn't change the positioning, so skip it -->
521 <div style="color:green"><table><tr><td>green
522 </td></tr></table></div>
524 Asynchronous Tests: class="reftest-wait"
525 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
527 Normally reftest takes a snapshot of the given markup's rendering right
528 after the load event fires for content. If your test needs to postpone
529 the moment the snapshot is taken, it should make sure a class
530 'reftest-wait' is on the root element by the moment the load event
531 fires. The easiest way to do this is to put it in the markup, e.g.: ::
533 <html class="reftest-wait">
535 When your test is ready, you should remove this class from the root
536 element, for example using this code: ::
538 document.documentElement.className = "";
541 Note that in layout tests it is often enough to trigger layout using ::
543 document.body.offsetWidth // HTML example
545 When possible, you should use this technique instead of making your
548 Invalidation Tests: MozReftestInvalidate Event
549 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
551 When a test (or reference) uses reftest-wait, reftest tracks invalidation
552 via MozAfterPaint and updates the test image in the same way that
553 a regular window would be repainted. Therefore it is possible to test
554 invalidation-related bugs by setting up initial content and then
555 dynamically modifying it before removing reftest-wait. However, it is
556 important to get the timing of these dynamic modifications right so that
557 the test doesn't accidentally pass because a full repaint of the window
558 was already pending. To help with this, reftest fires one MozReftestInvalidate
559 event at the document root element for a reftest-wait test when it is safe to
560 make changes that should test invalidation. The event bubbles up to the
561 document and window so you can set listeners there too. For example, ::
564 document.body.style.border = "";
565 document.documentElement.removeAttribute('class');
567 document.addEventListener("MozReftestInvalidate", doTest, false);
569 Painting Tests: class="reftest-no-paint"
570 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
572 If an element shouldn't be painted, set the class "reftest-no-paint" on it
573 when doing an invalidation test. Causing a repaint in your
574 MozReftestInvalidate handler (for example, by changing the body's background
575 colour) will accurately test whether the element is painted.
577 Display List Tests: class="reftest-[no-]display-list"
578 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
580 These classes work similarly to reftest-no-paint, but check if the element has
581 display items created or not. These classes are useful for checking the behaviour
582 of retained display lists, where the display list is incrementally updated by
583 changes, rather than thrown out and rebuilt from scratch.
585 Opaque Layer Tests: class="reftest-opaque-layer"
586 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
588 If an element should be assigned to a PaintedLayer that's opaque, set the class
589 "reftest-opaque-layer" on it. This checks whether the layer is opaque during
590 the last paint of the test, and it works whether your test is an invalidation
591 test or not. In order to pass the test, the element has to have a primary
592 frame, and that frame's display items must all be assigned to a single painted
593 layer and no other layers, so it can't be used on elements that create stacking
594 contexts (active or inactive).
596 Layerization Tests: reftest-assigned-layer="layer-name"
597 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
599 If two elements should be assigned to the same PaintedLayer, choose any string
600 value as the layer name and set the attribute reftest-assigned-layer="yourname"
601 on both elements. Reftest will check whether all elements with the same
602 reftest-assigned-layer value share the same layer. It will also test whether
603 elements with different reftest-assigned-layer values are assigned to different
605 The same restrictions as with class="reftest-opaque-layer" apply: All elements
606 must have a primary frame, and that frame's display items must all be assigned
607 to the same PaintedLayer and no other layers. If these requirements are not
608 met, the test will fail.
610 Snapshot The Whole Window: class="reftest-snapshot-all"
611 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
613 In a reftest-wait test, to disable testing of invalidation and force the final
614 snapshot to be taken of the whole window, set the "reftest-snapshot-all"
615 class on the root element.
617 Avoid triggering flushes: class="reftest-no-flush"
618 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
620 The reftest harness normally triggers flushes by calling
621 getBoundingClientRect on the root element. If the root element of the
622 test has class="reftest-no-flush", it doesn't do this.
624 This is useful for testing animations on the compositor thread, since
625 the flushing will cause a main thread style update.
627 Zoom Tests: reftest-zoom="<float>"
628 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
630 When the root element of a test has a "reftest-zoom" attribute, that zoom
631 factor is applied when rendering the test. The corresponds to the desktop "full
632 zoom" style zoom. The reftest document will be 800 device pixels wide by 1000
633 device pixels high. The reftest harness assumes that the CSS pixel dimensions
634 are 800/zoom and 1000/zoom. For best results therefore, choose zoom factors
635 that do not require rounding when we calculate the number of appunits per
636 device pixel; i.e. the zoom factor should divide 60, so 60/zoom is an integer.
638 Setting Scrollport Size: reftest-scrollport-w/h="<int>"
639 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
641 If either of the "reftest-scrollport-w" and "reftest-scrollport-h" attributes on
642 the root element are non-zero, sets the scroll-position-clamping scroll-port
643 size to the given size in CSS pixels. This does not affect the size of the
644 snapshot that is taken.
646 Setting Resolution: reftest-resolution="<float>"
647 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
649 If the root element of a test has a "reftest-resolution" attribute, the page
650 is rendered with the specified resolution (as if the user pinch-zoomed in
651 to that scale). Note that the difference between reftest-async-zoom and
652 reftest-resolution is that reftest-async-zoom only applies the scale in
653 the compositor, while reftest-resolution causes the page to be paint at that
654 resolution. This attribute can be used together with initial-scale in meta
655 viewport tag, in such cases initial-scale is applied first then
656 reftest-resolution changes the scale.
658 This attributes requires the pref apz.allow_zooming=true to have an effect.
660 Setting Async Scroll Mode: reftest-async-scroll attribute
661 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
663 If the "reftest-async-scroll" attribute is set on the root element, we try to
664 enable async scrolling and zooming for the document. This is unsupported in many
667 Setting Displayport Dimensions: reftest-displayport-x/y/w/h="<int>"
668 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
670 If any of the "reftest-displayport-x", "reftest-displayport-y",
671 "reftest-displayport-w" and "reftest-displayport-h" attributes on the root
672 element are nonzero, sets the displayport dimensions to the given bounds in
673 CSS pixels. This does not affect the size of the snapshot that is taken.
675 When the "reftest-async-scroll" attribute is set on the root element, *all*
676 elements in the document are checked for "reftest-displayport-x/y/w/h" and have
677 displayports set on them when those attributes are present.
679 Testing Async Scrolling: reftest-async-scroll-x/y="<int>"
680 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
682 When the "reftest-async-scroll" attribute is set on the root element, for any
683 element where either the "reftest-async-scroll-x" or "reftest-async-scroll-y
684 attributes are nonzero, at the end of the test take the snapshot with the given
685 offset (in CSS pixels) added to the async scroll offset.
687 Testing Async Zooming: reftest-async-zoom="<float>"
688 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
690 When the "reftest-async-zoom" attribute is present on the root element then at
691 the end of the test take the snapshot with the given async zoom on top of any
692 existing zoom. Content is not re-rendered at the new zoom level. This
693 corresponds to the mobile style "pinch zoom" style of zoom. This is unsupported
694 in many configurations, and any tests using this will probably want to have
695 pref(apz.allow_zooming,true) on them.
697 Pagination Tests: class="reftest-paged"
698 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
700 Now that the patch for bug 374050 has landed
701 (https://bugzilla.mozilla.org/show_bug.cgi?id=374050), it is possible to
702 create reftests that run in a paginated context.
704 The page size used is 5in wide and 3in tall (with the default half-inch
705 margins). This is to allow tests to have less text and to make the
706 entire test fit on the screen.
708 There is a layout/reftests/printing directory for pagination reftests; however,
709 there is nothing special about this directory. You can put pagination reftests
710 anywhere that is appropriate.
712 The suggested first lines for any pagination test is: ::
714 <!DOCTYPE html><html class="reftest-paged">
715 <style>html{font-size:12pt}</style>
717 The reftest-paged class on the root element triggers the reftest to
718 switch into page mode. Fixing the font size is suggested, although not
719 required, because the pages are a fixed size in inches. The switch to page mode
720 happens on load if the reftest-wait class is not present; otherwise it happens
721 immediately after firing the MozReftestInvalidate event.
723 The underlying layout support for this mode isn't really complete; it
724 doesn't use exactly the same codepath as real print preview/print. In
725 particular, scripting and frames are likely to cause problems; it is untested,
726 though. That said, it should be sufficient for testing layout issues related
729 Process Crash Tests: class="reftest-expect-process-crash"
730 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
732 If you are running a test that causes a process
733 under Electrolysis to crash as part of a reftest, this will cause process
734 crash minidump files to be left in the profile directory. The test
735 infrastructure that runs the reftests will notice these minidump files and
736 dump out information from them, and these additional error messages in the logs
737 can end up erroneously being associated with other errors from the reftest run.
738 They are also confusing, since the appearance of "PROCESS-CRASH" messages in
739 the test run output can seem like a real problem, when in fact it is the
742 To indicate to the reftest framework that a test is expecting a
743 process to crash, have the test include "reftest-expect-process-crash" as
744 one of the root element's classes by the time the test has finished. This will
745 cause any minidump files that are generated while running the test to be removed
746 and they won't cause any error messages in the test run output.
748 Skip Forcing A Content Process Layer-Tree Update: reftest-no-sync-layers attribute
749 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
751 Normally when an multi-process reftest test ends, we force the content process
752 to push a layer-tree update to the compositor before taking the snapshot.
753 Setting the "reftest-no-sync-layers" attribute on the root element skips this
754 step, enabling testing that layer-tree updates are being correctly generated.
755 However the test must manually wait for a MozAfterPaint event before ending.
760 The Reftest Analyzer has been created to make debugging reftests a bit easier.
761 If a reftest is failing, upload the log to the Reftest Analyzer to view the
762 differences between the expected result and the actual outcome of the reftest.
763 The Reftest Analyzer can be found at the following url:
765 https://hg.mozilla.org/mozilla-central/raw-file/tip/layout/tools/reftest/reftest-analyzer.xhtml