Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop in dom.shadowElementsFromPoint #856

Closed
marcysutton opened this issue Apr 21, 2018 · 0 comments
Closed

Infinite loop in dom.shadowElementsFromPoint #856

marcysutton opened this issue Apr 21, 2018 · 0 comments
Labels
core Issues in the core code (lib/core) fix Bug fixes

Comments

@marcysutton
Copy link
Contributor

marcysutton commented Apr 21, 2018

The code that steps into shadow boundaries to test color contrast is throwing an infinite loop in Chrome 66. If you run the color-contrast check tests in Chrome 65, they work fine. In Chrome 66, they throw an error: Maximum call stack size exceeded
Here is the relevant code: https://github.com/dequelabs/axe-core/blob/develop/lib/commons/dom/shadow-elements-from-point.js

Perhaps something changed in Chrome since that code was shipped? I'll have to download an older version to know for sure (though I did also ask Rob Dodson if he knows anything). When the code was written, document.elementsFromPoint behaved like this (in a simplified way):

  • document.elementsFromPoint(x, y) returned nodes from the light dom only, e.g. ['#container', 'body', 'html']
  • root.elementsFromPoint(x, y) would return nodes from the current shadow root only, e.g. ['#target']
  • I combined the two arrays to get a complete stack of nodes to test further.

Now an infinite loop is throwing, something I would have caught in development. I've since tried preventing it by adding various breakers, but I'm still not quite getting it.

I did notice a difference with elementsFromPoint once I started doing more experiments:

  • document.elementsFromPoint(x, y) still returns nodes from the light DOM, e.g. ['#container', 'body', 'html']
  • root.elementsFromPoint(x, y) now returns shadow and light DOM nodes, e.g. ['#target', '#container', 'body', 'html']
  • We only need the second array now, not a concatenated version.

It would be good to confirm whether that behavior really did change. Would we have to support both versions?

Furthermore, how exactly is this infinite loop occurring? We still need to run document.elementsFromPoint to get the outer stack, step into any shadowRoots and recurse to get the whole stack of elements. I tried storing a top-level variable to filter out multiple calls to the same element or root node, but it still recursed to infinity. I have to put this task down now, but that's what I uncovered so far.

@marcysutton marcysutton added the fix Bug fixes label Apr 21, 2018
@WilcoFiers WilcoFiers added this to the Q2 2018 update milestone Apr 23, 2018
WilcoFiers pushed a commit that referenced this issue May 19, 2018
* fix(core): Explicitly name the axe module 'axe-core'

Avoid the "Mismatched anonymous define() modules" error when the axe script is injected in a page that uses requireJS

Closes #849

* fix: Prevent color rules from crashing Chrome 66+ #856 (#861)

* chore: Release axe-core 3.0.2

* chore: Enable Greenkeeper for managing dependencies (#847)

* chore: add Greenkeeper config file

* chore(package): update dependencies

* chore(package): update dependencies

* chore(package): update dependencies

* chore(package): update dependencies

* chore(package): update dependencies

* chore(package): update dependencies

* docs(readme): add Greenkeeper badge

* chore: update to use babel-core

* chore: update to latest uglify config properties

`bracketize` became `braces` and `expect` became `reserved`

* chore: add sri-history lifecycle hook to release (#844)

* chore: disable growl to prevent errors in testing

* chore: Rename Jest example to help greenkeeper (#871)

* chore: rename jest example to help greenkeeper

plus signs are invalid in filenames/directories

Closes #869

* chore: add config to jest_react example

Closes #865

* fix(core): Explicitly name the axe module 'axe-core'

Avoid the "Mismatched anonymous define() modules" error when the axe script is injected in a page that uses requireJS

Closes #849

* test(core): Validate that the axe module is named 'axe-core'

Added integration test to check the value of the first argument to define()

Closes #849
@WilcoFiers WilcoFiers added the core Issues in the core code (lib/core) label Oct 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues in the core code (lib/core) fix Bug fixes
Projects
None yet
Development

No branches or pull requests

2 participants