Skip to content

Commit

Permalink
(tech-debt): wait for iframes to be ready in tests (#3060)
Browse files Browse the repository at this point in the history
* add missing iframe loading waits

* add testutils where needed
  • Loading branch information
clottman authored Jul 2, 2021
1 parent 42738b5 commit 988d536
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 31 deletions.
1 change: 1 addition & 0 deletions test/integration/full/aria-hidden-body/fail.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<h2>Some title.</h2>
<a href="http://www.deque.com">Deque</a>
<div id="mocha"></div>
<script src="/test/testutils.js"></script>
<script src="fail.js"></script>
<script src="/test/integration/adapter.js"></script>
</body>
Expand Down
18 changes: 10 additions & 8 deletions test/integration/full/aria-hidden-body/fail.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ describe('aria-hidden on body test ' + window.location.pathname, function() {
'use strict';
var results;
before(function(done) {
axe.run(
{ runOnly: { type: 'rule', values: ['aria-hidden-body'] } },
function(err, r) {
assert.isNull(err);
results = r;
done();
}
);
axe.testUtils.awaitNestedLoad(function() {
axe.run(
{ runOnly: { type: 'rule', values: ['aria-hidden-body'] } },
function(err, r) {
assert.isNull(err);
results = r;
done();
}
);
});
});

describe('violations', function() {
Expand Down
1 change: 1 addition & 0 deletions test/integration/full/aria-hidden-body/pass.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<h2>Some title.</h2>
<a href="http://www.deque.com">Deque</a>
<div id="mocha"></div>
<script src="/test/testutils.js"></script>
<script src="pass.js"></script>
<script src="/test/integration/adapter.js"></script>
<iframe src="frames/frame-hidden-body.html"></iframe>
Expand Down
18 changes: 10 additions & 8 deletions test/integration/full/aria-hidden-body/pass.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ describe('aria-hidden on body test ' + window.location.pathname, function() {
'use strict';
var results;
before(function(done) {
axe.run(
{ runOnly: { type: 'rule', values: ['aria-hidden-body'] } },
function(err, r) {
assert.isNull(err);
results = r;
done();
}
);
axe.testUtils.awaitNestedLoad(function() {
axe.run(
{ runOnly: { type: 'rule', values: ['aria-hidden-body'] } },
function(err, r) {
assert.isNull(err);
results = r;
done();
}
);
});
});

describe('violations', function() {
Expand Down
1 change: 1 addition & 0 deletions test/integration/full/bypass/aria-header.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<div role="heading">This header will make the test pass.</div>
<a href="http://www.deque.com">stuff</a>
<div id="mocha"></div>
<script src="/test/testutils.js"></script>
<script src="pass-tests.js"></script>
<script src="/test/integration/adapter.js"></script>
</body>
Expand Down
1 change: 1 addition & 0 deletions test/integration/full/bypass/fail.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<body>
<a href="http://www.deque.com">stuff</a>
<div id="mocha"></div>
<script src="/test/testutils.js"></script>
<script src="fail.js"></script>
<script src="/test/integration/adapter.js"></script>
</body>
Expand Down
18 changes: 10 additions & 8 deletions test/integration/full/bypass/fail.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ describe('bypass fail test', function() {
var mocha = document.getElementById('mocha'),
html = mocha.innerHTML;
mocha.innerHTML = '';
axe.run({ runOnly: { type: 'rule', values: ['bypass'] } }, function(
err,
r
) {
assert.isNull(err);
axe.testUtils.awaitNestedLoad(function() {
axe.run({ runOnly: { type: 'rule', values: ['bypass'] } }, function(
err,
r
) {
assert.isNull(err);

results = r;
mocha.innerHTML = html;
done();
results = r;
mocha.innerHTML = html;
done();
});
});
});

Expand Down
1 change: 1 addition & 0 deletions test/integration/full/bypass/header1.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<h2>This header will make the test pass.</h2>
<a href="http://www.deque.com">stuff</a>
<div id="mocha"></div>
<script src="/test/testutils.js"></script>
<script src="pass-tests.js"></script>
<script src="/test/integration/adapter.js"></script>
</body>
Expand Down
1 change: 1 addition & 0 deletions test/integration/full/bypass/header2.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<h1>This header will make the test pass.</h1>
<a href="http://www.deque.com">stuff</a>
<div id="mocha"></div>
<script src="/test/testutils.js"></script>
<script src="pass-tests.js"></script>
<script src="/test/integration/adapter.js"></script>
</body>
Expand Down
16 changes: 9 additions & 7 deletions test/integration/full/bypass/pass-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ describe('bypass aria header test ' + window.location.pathname, function() {
'use strict';
var results;
before(function(done) {
axe.run({ runOnly: { type: 'rule', values: ['bypass'] } }, function(
err,
r
) {
assert.isNull(err);
results = r;
done();
axe.testUtils.awaitNestedLoad(function() {
axe.run({ runOnly: { type: 'rule', values: ['bypass'] } }, function(
err,
r
) {
assert.isNull(err);
results = r;
done();
});
});
});

Expand Down
1 change: 1 addition & 0 deletions test/integration/full/bypass/region.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<div role="main">This header will make the test pass.</div>
<a href="http://www.deque.com">stuff</a>
<div id="mocha"></div>
<script src="/test/testutils.js"></script>
<script src="pass-tests.js"></script>
<script src="/test/integration/adapter.js"></script>
</body>
Expand Down
1 change: 1 addition & 0 deletions test/integration/full/bypass/skip-link.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<div>Test.</div>
<a href="http://www.deque.com">stuff</a>
<div id="mocha"></div>
<script src="/test/testutils.js"></script>
<script src="pass-tests.js"></script>
<script src="/test/integration/adapter.js"></script>
</body>
Expand Down

0 comments on commit 988d536

Please sign in to comment.