A11Y-12594: debug logs for teardown race + iframe investigation by sunny-se · Pull Request #288 · browserstack/a11y-engine-axe-core · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/core/base/context.js
6 changes: 6 additions & 0 deletions lib/core/public/run-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ import log from '../log';
* @param {Function} reject Called when execution failed, receives (err : Error)
*/
export default function runRules(context, options, resolve, reject) {
// [a11y-core]: debug logging for run lifecycle
(Function("return this")()).console.debug('[DEBUG-ISSUE] axe.runRules start', {
t: Math.round(performance.now()),
running: axe._running,
inFrame: window.top !== window
});
try {
context = new Context(context);
axe._tree = context.flatTree;
Expand Down
13 changes: 13 additions & 0 deletions lib/core/public/teardown.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ import { resetGlobals } from './run/globals-setup';
* Clean up axe-core tree and caches. `axe.run` will call this function at the end of the run so there's no need to call it yourself afterwards.
*/
function teardown() {
// [a11y-core]: debug logging for teardown race investigation
if (axe._running) {
(Function("return this")()).console.warn('[DEBUG-ISSUE] axe.teardown() WHILE RUN IN FLIGHT', {
t: Math.round(performance.now()),
inFrame: window.top !== window
}, new Error().stack);
} else {
(Function("return this")()).console.debug('[DEBUG-ISSUE] axe.teardown()', {
t: Math.round(performance.now()),
running: axe._running,
inFrame: window.top !== window
});
}
// Reset MUST to happen before the cache is cleared
resetGlobals();
axe._memoizedFns.forEach(fn => fn.clear());
Expand Down
10 changes: 9 additions & 1 deletion lib/core/utils/collect-results-from-frames.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ export default function collectResultsFromFrames(
return res({ results, frameElement });
}

sendCommandToFrame(frameElement, params, callback, rej);
// [a11y-core]: debug logging for frame rejection path
sendCommandToFrame(frameElement, params, callback, (err) => {
(Function("return this")()).console.error('[DEBUG-ISSUE] frame error — rejecting full run', {
frame: frameElement && (frameElement.id || frameElement.src),
error: err && err.message,
t: Math.round(performance.now())
});
rej(err);
});
});
});

Expand Down
7 changes: 7 additions & 0 deletions lib/core/utils/get-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,14 @@ function getThreeLeastCommonFeatures(elm, selectorData) {
function generateSelector(elm, options, doc) {
/*eslint no-loop-func:0*/
// TODO: es-modules_selectorData
// [a11y-core]: debug logging for teardown race investigation
if (!axe._selectorData) {
(Function("return this")()).console.error('[DEBUG-ISSUE] _selectorData missing', {
t: Math.round(performance.now()),
running: axe._running,
inFrame: window.top !== window,
url: location.href
}, new Error().stack);
throw new Error('Expect axe._selectorData to be set up');
}
const { toRoot = false } = options;
Expand Down
11 changes: 11 additions & 0 deletions lib/core/utils/send-command-to-frame.js
Loading