diff options
Diffstat (limited to 'testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-the-image-data/current-request-microtask.html')
-rw-r--r-- | testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-the-image-data/current-request-microtask.html | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-the-image-data/current-request-microtask.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-the-image-data/current-request-microtask.html new file mode 100644 index 0000000000..125b37eadb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-the-image-data/current-request-microtask.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<title>An img's current request should be updated in a microtask after selecting an image source</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> + +<script> +async_test(function(t) { + const picture = document.createElement("picture"); + + const nonMatchingSource = document.createElement("source"); + nonMatchingSource.media = "not all"; + nonMatchingSource.srcset = "data:,a"; + picture.append(nonMatchingSource); + + const matchingSource = document.createElement("source"); + matchingSource.media = "all"; + matchingSource.srcset = "data:,b"; + picture.append(matchingSource); + + const img = document.createElement("img"); + img.src = "data:,c"; + + assert_equals(img.currentSrc, "", "after assigning to img.src but before the corresponding microtask is run"); + + queueMicrotask(t.step_func(function() { + assert_equals(img.currentSrc, "data:,c", "after assigning to img.src and after corresponding microtask is run"); + + picture.append(img); + assert_equals(img.currentSrc, "data:,c", "after appending img to picture but before the corresponding microtask is run"); + + queueMicrotask(t.step_func(function() { + assert_equals(img.currentSrc, "data:,b", "after appending img to picture and after the corresponding microtask is run"); + t.done(); + })); + })); +}, "currentSrc is updated only after the microtask that updates the current request is run"); +</script> |