Skip to content

Commit

Permalink
Fix html/semantics/embedded-content/media-elements/location-of-the-me…
Browse files Browse the repository at this point in the history
…dia-resource/currentSrc.html (#41782)

The flakiness was caused by the 0s timer sometimes firing before the media task had a chance to run til completion.
Avoid this non-determinism by waiting for loadstart event before scheduling the 0s timer.
  • Loading branch information
rniwa authored Sep 2, 2023
1 parent f70a496 commit 9a06a7e
Showing 1 changed file with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
var e = document.createElement(tagName);
e.src = src;
assert_equals(e.currentSrc, '');
t.step_timeout(function() {
if (src == '') {
assert_equals(e.currentSrc, '');
} else {
assert_equals(e.currentSrc, e.src);
}
t.done();
}, 0);
e.addEventListener('loadstart', function () {
t.step_timeout(function () {
if (src == '') {
assert_equals(e.currentSrc, '');
} else {
assert_equals(e.currentSrc, e.src);
}
t.done();
}, 0);
})
}, tagName + '.currentSrc after setting src attribute "' + src + '"');

async_test(function(t) {
Expand All @@ -30,14 +32,16 @@
s.src = src;
e.appendChild(s);
assert_equals(e.currentSrc, '');
t.step_timeout(function() {
if (src == '') {
assert_equals(e.currentSrc, '');
} else {
assert_equals(e.currentSrc, s.src);
}
t.done();
}, 0);
e.addEventListener('loadstart', function() {
t.step_timeout(function () {
if (src == '') {
assert_equals(e.currentSrc, '');
} else {
assert_equals(e.currentSrc, s.src);
}
t.done();
}, 0);
});
}, tagName + '.currentSrc after adding source element with src attribute "' + src + '"');
});
});
Expand Down

0 comments on commit 9a06a7e

Please sign in to comment.