Bug 1076583 - Test the current request timing more precisely. r=smaug

This test matches the spec to the letter, but chrome fails the last
assertion (they seem to have some delay in setting the current request
or something).

Differential Revision: https://phabricator.services.mozilla.com/D218421
This commit is contained in:
Emilio Cobos Álvarez 2024-08-05 12:23:45 +00:00
parent cce3bd162f
commit 9276a2c7e0

View File

@ -0,0 +1,27 @@
<!doctype html>
<title>Current request microtask handling with multiple tasks.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
async_test(function(t) {
let img;
function testSrcOnMicrotask(expectedCurrentSrc, done) {
window.queueMicrotask(t.step_func(() => {
assert_equals(img.currentSrc, expectedCurrentSrc, `currentSrc should be ${expectedCurrentSrc}`);
if (done) {
t.done();
}
}));
}
testSrcOnMicrotask("");
img = new Image();
let png = "/images/green.png?" + Math.random();
testSrcOnMicrotask("");
// Both .src assignment and appendChild are relevant mutations. So the first task should be "canceled" (return early).
img.src = png;
testSrcOnMicrotask("");
document.body.appendChild(img);
testSrcOnMicrotask(new URL(png, document.documentURI).href, /* done = */ true);
});
</script>