Accessibility Testing


Accessibility is tested in several different places. This page documents some of the most widely-used systems.

DumpAccessibilityTree

The preferred system for testing end-to-end accessibility functionality is DumpAccessibilityTree.

It's loosely patterned after DumpRenderTree and Blink/WebKit layout tests, so if you've ever written a layout test, you already understand the idea behind an accessibility test!

To run the DumpAccessibilityTree tests, build content_browsertests and then run it with --gtest_filter="DumpAccessibilityTree*", like this:

> ninja -C out/Debug content_browsertests
> out/Debug/content_browsertests --gtest_filter="DumpAccessibilityTree*"

Specific tests within DumpAccessibilityTree can be run by supplying the test name as:

> out/Debug/content_browsertests --gtest_filter="DumpAccessibilityTree.<TestNameHere>/*"

Each test is parameterized to run multiple times.  Most platforms dump in the "blink" format (the internal data), and again in a "native" (platform-specific) format.  The test name indicates which test pass was run, e.g., `DumpAccessibilityTreeTest.TestName/blink`. To run all available platform tests, supply the asterix after the name of the individual test case (as seen above).

DumpAccessibilityTree tests allow you to test for different output on different platforms. On each machine you run the tests on, it will output the cross-platform tree, and if you're on a platform with native accessibility support, the accessibility tree for that platform. It isn't that hard to write a DumpAccessibilityTree test for a platform other than your primary platform using the trybots.

The code for DumpAccessibilityTree is found in this main source file, plus many helper classes in the same directory:

content/browser/accessibility/dump_accessibility_tree_browsertest.cc

Each individual test has an html file and one expectation file per platform, e.g.:

 content/test/data/accessibility/footer.html
 content/test/data/accessibility/footer-expected-mac.txt
 content/test/data/accessibility/footer-expected-win.txt
 content/test/data/accessibility/footer-expected-win.txt
 content/test/data/accessibility/footer-expected-win.txt
 content/test/data/accessibility/footer-expected-win.txt

For each test, DumpAccessibilityTree loads the html file into a browser window, recursively explores the whole accessibility tree, then dumps the result in a text format (subject to some filters that you can customize, so you don't dump every attribute), and compares the result to the expectation file.

For more information on the format of the files, see:

 content/test/data/accessibility/readme.txt

Blink Layout Tests

Blink layout tests are another important way accessibility is tested. There are a number of accessibility tests in this directory:

 third_party/blink/web_tests/accessibility/

These tests are critically important for testing Blink implementation of accessibility at a low-level, including parsing html and sending notifications.

Here's a sample command line for running the tests:

> ninja -C out/Debug blink_tests
> python third_party/blink/tools/run-web-tests.py --no-show-results --no-retry-failures --results-directory=results accessibility/

To run just one test:

> out/Release/content_shell --run-layout-test third_party/blink/web_tests/accessibility/test_name.html

To run just one test, on Mac OS X:

> out/Release/Content\ Shell.app/Contents/MacOS/Content\ Shell --run-layout-test third_party/blink/web_tests/accessibility/test_name.html

Subpages (1): Axe-Core Testing
Comments