Skip to content

Commit

Permalink
Fix test flakiness caused by not waiting for an iframe to load.
Browse files Browse the repository at this point in the history
If these tests don't wait for onload before proceeding it is possible for
the iframe to load after the postMessage call and onmessage assignment
have been done, but before the task to deliver the message event has been
executed, causing the message to never be delivered.
  • Loading branch information
mkruisselbrink authored and Ms2ger committed Dec 9, 2016
1 parent 0e462a0 commit 8e114c6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
14 changes: 8 additions & 6 deletions webmessaging/with-ports/019.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
<iframe src="../without-ports/019-1.html"></iframe>
<div id=log></div>
<script>
async_test(function() {
window[0].postMessage('', location.protocol.toUpperCase() + '//' + location.host.toUpperCase() + '/', []);
window[0].onmessage = this.step_func(function(e) {
assert_equals(e.origin, location.protocol + '//' + location.host);
assert_array_equals(e.ports, []);
this.done();
async_test(function(test) {
onload = test.step_func(function() {
window[0].postMessage('', location.protocol.toUpperCase() + '//' + location.host.toUpperCase() + '/', []);
window[0].onmessage = test.step_func(function(e) {
assert_equals(e.origin, location.protocol + '//' + location.host);
assert_array_equals(e.ports, []);
test.done();
});
});
});
</script>
Expand Down
14 changes: 8 additions & 6 deletions webmessaging/without-ports/019.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
<iframe src="../without-ports/019-1.html"></iframe>
<div id=log></div>
<script>
async_test(function() {
window[0].postMessage('', location.protocol.toUpperCase() + '//' + location.host.toUpperCase() + '/');
window[0].onmessage = this.step_func(function(e) {
assert_equals(e.origin, location.protocol + '//' + location.host);
assert_array_equals(e.ports, []);
this.done();
async_test(function(test) {
onload = test.step_func(function() {
window[0].postMessage('', location.protocol.toUpperCase() + '//' + location.host.toUpperCase() + '/');
window[0].onmessage = test.step_func(function(e) {
assert_equals(e.origin, location.protocol + '//' + location.host);
assert_array_equals(e.ports, []);
test.done();
});
});
});
</script>
Expand Down

0 comments on commit 8e114c6

Please sign in to comment.