Product
axe-core
Product Version
4.6.2
Latest Version
Issue Description
Expectation
When calling axe.run with an iframe's contentDocument I expect it to perform the checks on just the iframe's document.
Actual
Throws an error:
Uncaught RangeError: Maximum call stack size exceeded
at clone (axe.js:6044:14)
at clone (axe.js:6059:26)
at clone (axe.js:6059:26)
at clone (axe.js:6059:26)
at clone (axe.js:6059:26)
at clone (axe.js:6059:26)
at clone (axe.js:6059:26)
at clone (axe.js:6059:26)
at clone (axe.js:6059:26)
at clone (axe.js:6059:26)
How to Reproduce
- Create a HTML file with the following content:
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axe-core/4.6.2/axe.js"></script>
<script>
function runAxe() {
const iframe = document.getElementById("iframe")
axe.run(iframe).then(result => console.log("Running on the element succeeds"))
axe.run(iframe.contentDocument).then(result => console.log("You won't see this"))
}
</script>
</head>
<body>
<iframe id="iframe"></iframe>
<button onclick="runAxe()">Run</button>
</body>
</html>
- Server it locally with a basic HTTP server (e.g.
python -m http.server)
- Visit the file in a browser and click the "Run" button
- See the stack trace in the console
Additional context
The clone function avoids cloning HTML elements by checking if it is an instance of window.Node, however because the iframe's context is different Node instances from inside the iframe are not instances of window.Node, they are instances of iframe.contentWindow.Node.
The solution to this might just be to say "you can't do that, if you want to test an iframe just pass the iframe's element and make sure the iframe option is true", but I figured it might be possible to find an easy fix if the clone function can detect Node instances from iframes.
Product
axe-core
Product Version
4.6.2
Latest Version
Issue Description
Expectation
When calling
axe.runwith an iframe'scontentDocumentI expect it to perform the checks on just the iframe's document.Actual
Throws an error:
How to Reproduce
python -m http.server)Additional context
The
clonefunction avoids cloning HTML elements by checking if it is an instance ofwindow.Node, however because the iframe's context is differentNodeinstances from inside the iframe are not instances ofwindow.Node, they are instances ofiframe.contentWindow.Node.The solution to this might just be to say "you can't do that, if you want to test an iframe just pass the iframe's element and make sure the iframe option is true", but I figured it might be possible to find an easy fix if the
clonefunction can detectNodeinstances from iframes.