dequelabs / dequelabs/axe-core
Memory Leak when iframe does not inject axe
- Dominant language
- JavaScript
- Stars
- 7.5k
- Forks
- 933
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 17
Description
When a page that has an iframe fails to inject axe into the iframe and axe performs an audit, the entire virtual tree is retrained after the run. `axe._tree` is `undefined` so axe isn't holding onto the reference itself.
What's happening is that the iframe messaging path holds onto the `iframe` node when we try to ping the iframe for axe. The `sendCommandToFrame` function [adds a callback for a positive response](https://github.com/dequelabs/axe-core/blob/develop/lib/core/utils/send-command-to-frame.js#L39-L42) which uses the iframe `node` in the callback function. However the callback function is never called, but the closure retains a reference to the `node`, which also then forces the virtual node associated with the iframe to be retained. Since that virtual node is retained, so is the entire ancestor virtual tree.
The fix would be to somehow remove the closure of the `node` or cleanup the listener function that gets added when the timeout occurs.
Contributor guide
Assessment
This issue has not been assessed yet.