Testing Frames with axe-core Script
Rule ID: frame-tested
Ruleset: axe-core 4.10
User Impact: Critical
Guidelines: Deque Best Practice
How to Fix the Problem
To ensure axe-core can analyze content within each frame on your page, follow these steps:
-
Load axe-core in every frame or iframe document
Add the axe-core script tag inside the<head>
of each framed page, ideally before other scripts: -
Enable in-frame testing in your top-level script
When you invokeaxe.run
, set theiframes
andpageLevel
options totrue
. This tells axe to enter nested browsing contexts and aggregate results: -
(Optional) Use an
after
callback for page-level processing
If you need custom aggregation or post-processing of combined frame results, configure anafter
function in your axe settings:
By including the axe-core script inside every frame and enabling these options, axe-core will automatically enter and audit each nested document for accessibility violations.
Why it Matters
Web applications often embed critical functionality—like videos, maps, or interactive widgets—inside frames or iframes. If the axe-core script isn’t loaded in those contexts, automated accessibility testing tools cannot enter or analyze that content. As a result, issues such as missing alt text, improper ARIA roles, or inaccessible form controls within frames go undetected. This can create significant barriers for users relying on screen readers or keyboard navigation, leading to a fragmented and frustrating user experience. Ensuring comprehensive testing across all nested frames helps maintain consistent accessibility across your entire site.
Rule Description
This rule verifies that each <iframe>
and <frame>
element includes the axe-core script, enabling in-frame accessibility checks. Frames missing the script are flagged as “review items,” indicating they must be updated so that axe-core can run its suite of tests within each frame.
The Algorithm (in simple terms)
-
Locate frames: With the
iframes: true
setting, axe-core finds all<iframe>
and<frame>
elements on the page. -
Inject or detect script: For each frame, axe-core checks whether the axe-core script is present. If not present, it attempts to inject it (when permissible).
-
Run tests in frames: If the script is loaded, axe-core executes its accessibility checks inside that frame’s document.
-
Aggregate results: When
pageLevel: true
is enabled, results from all frames are combined into a single report for easier review. -
Flag missing script: Frames without the script produce a “review” result, prompting developers to add axe-core to those contexts.