-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(frame-tested): run without respondable (#2942)
* fix(frame-tested): run without respondable * revert playground and files * add after tests * work with shadow dom * fixes * show undefined for all tests
- Loading branch information
Showing
7 changed files
with
299 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const joinStr = ' > '; | ||
|
||
function frameTestedAfter(results) { | ||
const iframes = {}; | ||
|
||
return results.filter(result => { | ||
const frameResult = | ||
result.node.ancestry[result.node.ancestry.length - 1] !== 'html'; | ||
|
||
if (frameResult) { | ||
const ancestry = result.node.ancestry.flat(Infinity).join(joinStr); | ||
iframes[ancestry] = result; | ||
return true; | ||
} | ||
|
||
// remove the `html` from the path to get the iframe path | ||
const ancestry = result.node.ancestry | ||
.slice(0, result.node.ancestry.length - 1) | ||
.flat(Infinity) | ||
.join(joinStr); | ||
|
||
// pass for each iframe that has an html result | ||
if (iframes[ancestry]) { | ||
iframes[ancestry].result = true; | ||
} | ||
|
||
return false; | ||
}); | ||
} | ||
|
||
export default frameTestedAfter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,6 @@ | ||
import { respondable } from '../../core/utils'; | ||
|
||
function frameTestedEvaluate(node, options) { | ||
const resolve = this.async(); | ||
const { isViolation, timeout } = Object.assign( | ||
{ isViolation: false, timeout: 500 }, | ||
options | ||
); | ||
|
||
// give the frame .5s to respond to 'axe.ping', else log failed response | ||
let timer = setTimeout(() => { | ||
// This double timeout is important for allowing iframes to respond | ||
// DO NOT REMOVE | ||
timer = setTimeout(() => { | ||
timer = null; | ||
resolve(isViolation ? false : undefined); | ||
}, 0); | ||
}, timeout); | ||
|
||
respondable(node.contentWindow, 'axe.ping', null, undefined, () => { | ||
if (timer !== null) { | ||
clearTimeout(timer); | ||
resolve(true); | ||
} | ||
}); | ||
// assume iframe is not tested | ||
return options.isViolation ? false : undefined; | ||
} | ||
|
||
export default frameTestedEvaluate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.