Skip to content
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
5 changes: 3 additions & 2 deletions test/integration/full/isolated-env/isolated-env.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ <h2>Ok</h2>
</main>
<footer></footer>

<script src="/test/testutils.js"></script>
<script src="isolated-env.js"></script>

<iframe
id="isolated-frame"
title="foo"
Expand All @@ -130,8 +133,6 @@ <h2>Ok</h2>
<p>Paragraph with a <a href="#">link</a>.</p>
</div>
<div id="mocha"></div>
<script src="/test/testutils.js"></script>
<script src="isolated-env.js"></script>
<script src="/test/integration/adapter.js"></script>
</body>
</html>
19 changes: 14 additions & 5 deletions test/integration/full/isolated-env/isolated-env.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/* global chai */
var messages = [];
window.addEventListener('message', function (msg) {
messages.push(msg.data);
});

describe('isolated-env test', function () {
'use strict';
Expand Down Expand Up @@ -40,11 +44,16 @@ describe('isolated-env test', function () {
});

var isloadedPromise = new Promise(function (resolve, reject) {
window.addEventListener('message', function (msg) {
if (msg.data === 'axe-loaded') {
resolve();
}
});
if (messages.includes('axe-loaded')) {
resolve();
} else {
window.addEventListener('message', function (msg) {
Copy link
Member

@Garbee Garbee Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor thing and since this in our tests I don't think it'll matter too much. But should we not remove this listener after it has resolved? That way there are no extraneous listeners during test execution. And we can do this through a signal to cancel listening instead of doing a named function then removeEventListener. Bit cleaner these days.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, this page runs in isolation so can't affect other pages and is closed once it's run so nothing will remain in memory or anything

if (msg.data === 'axe-loaded') {
resolve();
}
});
}

setTimeout(function () {
reject(new Error('axe-loaded message not called'));
}, 5000);
Expand Down