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

fix(finishRun): handle null for failed iframe results #3096

Merged
merged 1 commit into from
Jul 26, 2021
Merged
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
7 changes: 6 additions & 1 deletion lib/core/public/finish-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ export default function finishRun(partialResults, options = {}) {
function setFrameSpec(partialResults) {
const frameStack = [];
for (const partialResult of partialResults) {
partialResult.frameSpec = frameStack.shift() ?? null;
const frameSpec = frameStack.shift();
if (!partialResult) {
continue;
}

partialResult.frameSpec = frameSpec ?? null;
const frameSpecs = getMergedFrameSpecs(partialResult);
frameStack.unshift(...frameSpecs);
}
Expand Down
29 changes: 29 additions & 0 deletions test/core/public/finish-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,35 @@ describe('axe.finishRun', function() {
})
.catch(done);
});

it('should handle null results and set target correctly', function(done) {
var windows = [window];
fixture.innerHTML = '<h1></h1>';
createIframe('<h2></h2>')
.then(function(frameWin) {
windows.push(frameWin);
return createIframe('<h3></h3>');
})
.then(function(nestedWin) {
windows.push(nestedWin);
var promisedResults = windows.map(function(win) {
return win.axe.runPartial({ runOnly: 'empty-heading' });
});
return Promise.all(promisedResults);
})
.then(function(partialResults) {
partialResults[1] = null;
return partialResults;
})
.then(axe.finishRun)
.then(function(results) {
var nodes = results.violations[0].nodes;
assert.deepEqual(nodes[0].target, ['h1']);
assert.deepEqual(nodes[1].target, ['iframe:nth-child(3)', 'h3']);
done();
})
.catch(done);
});
});

describe('calling audit.after', function() {
Expand Down