diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-the-image-data | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-the-image-data')
2 files changed, 63 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> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-the-image-data/fail-to-resolve.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-the-image-data/fail-to-resolve.html new file mode 100644 index 0000000000..959ceaa979 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/update-the-image-data/fail-to-resolve.html @@ -0,0 +1,25 @@ +<!doctype html> +<title>img update the image data: fail to resolve URL</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> + +<img src="//["> +<img srcset="//["> +<img srcset="//[" src="/images/red.png"> +<img srcset="//[, /images/red.png"> + +<script> +setup({explicit_done: true}); + +var expected = '//['; + +onload = function() { + [].forEach.call(document.images, function(img) { + test(function() { + assert_equals(img.currentSrc, expected); + }, img.outerHTML); + }); + done(); +}; +</script> |