Refine headless support for userbar and accessibility checker #13224
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are some other race condition issues that cause Axe and the scroll restoration to not work on headless. This usually happens if the page contains other JS code that blocks the page
load
event, which means thedocument.readyState
isinteractive
and theDOMContentLoaded
event has been fired. An example of this can be found on the "Bolani" bread page, which has a YouTube embed that blocks the page load by a few seconds.Fix this by ensuring
axe.configure()
is run immediately during init and not on every run (as per #13164 (comment)), and by waiting for thewindow.load
event instead ofdocument.DOMContentLoaded
.In addition, some unrelated minor improvements:
getWagtailMessage
simplification per Implement scroll restoration for cross-domain preview iframes #13165 (comment)document.querySelector('wagtail-userbar').runAxe()
multiple times on demand. Without this, the template element disappears after the first render of the results, because we wipe the content of the dialog. Without the template elements,runAxe
bails out early.TODO: