Skip to content

Commit

Permalink
fix: ignores axe.ping responses that do not contain axe=true
Browse files Browse the repository at this point in the history
  • Loading branch information
AutoSponge committed Oct 31, 2019
1 parent 96ab457 commit 26cb1fb
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/core/utils/collect-results-from-frames.js
Expand Up @@ -37,7 +37,12 @@ axe.utils.sendCommandToFrame = function(node, parameters, resolve, reject) {
}, 500);

// send 'axe.ping' to the frame
axe.utils.respondable(win, 'axe.ping', null, undefined, function() {
axe.utils.respondable(win, 'axe.ping', null, undefined, function(
pingResponse
) {
if (!pingResponse || !pingResponse.axe === true) {
return;
}
clearTimeout(timeout);

// Give axe 60s (or user-supplied value) to respond to 'axe.start'
Expand Down
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>frame-tested echoes postMessage test</title>
<meta charset="utf8" />
<link
rel="stylesheet"
type="text/css"
href="/node_modules/mocha/mocha.css"
/>
<script src="/node_modules/mocha/mocha.js"></script>
<script src="/node_modules/chai/chai.js"></script>
<script src="/axe.js"></script>
<script>
mocha.setup({
timeout: 10000,
ui: 'bdd'
});
var assert = chai.assert;
</script>
</head>
<body>
<iframe id="frame" src="frames/with-echo.html"></iframe>
<div id="mocha"></div>
<script src="/test/testutils.js"></script>
<script src="frame-tested-echoes-postmessage.js"></script>
<script src="/test/integration/adapter.js"></script>
</body>
</html>
@@ -0,0 +1,28 @@
describe('frame-tested-echoes-postmessage test', function() {
'use strict';

var results;
before(function(done) {
axe.testUtils.awaitNestedLoad(function() {
axe.run(
{
runOnly: { type: 'rule', values: ['frame-tested'] },
checks: {
'frame-tested': { options: { isViolation: true } }
}
},
function(err, r) {
assert.isNull(err);
results = r;
done();
}
);
});
});

describe('result', function() {
it('should not error', function() {
assert.lengthOf(results.violations, 0);
});
});
});
19 changes: 19 additions & 0 deletions test/integration/full/frame-tested/frames/with-echo.html
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>Frame without axe-core</title>
<meta charset="utf8" />
</head>
<body>
<h1>Frame without axe-core</h1>
<script>
window.addEventListener(
'message',
event => {
window.top.postMessage(event.data);
},
false
);
</script>
</body>
</html>

0 comments on commit 26cb1fb

Please sign in to comment.