Bug 1476483 [wpt PR 12044] - ImageLoading: Don't reschedule a microtask on attach if one is pending., a=testonly

Automatic update from web-platform-testsImageLoading: Don't reschedule a microtask on attach if one is pending.

This patch ensures that we don't reschedule an image loading microtask
if there is one pending already. This is important to ensure that image
decode microtasks see the image data (ie the image loading microtask
runs first) if there are no other changes only insertion into a
document.

The existing tests that were added for this still pass (from crrev.com/cdd156337ada7)
  http/tests/misc/image-blocked-src-change.html
  http/tests/misc/image-blocked-src-no-change.html
  http/tests/xmlhttprequest/xmlhttprequest-image-not-loaded-svg.svg
  http/tests/xmlhttprequest/xmlhttprequest-image-not-loaded.html

The new test fails without the change and passes with.

R=chrishtr@chromium.org

Bug: 864306
Change-Id: I1d3d2ed4c12b53fab931e55a85c4f5cd18fe1cc4
Reviewed-on: https://chromium-review.googlesource.com/1141121
Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
Commit-Queue: vmpstr <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577006}

--

wpt-commits: 6aabe74f9e6a4b9471f112e15b56b9e1a39004e5
wpt-pr: 12044
This commit is contained in:
Vladimir Levin 2018-07-25 18:34:11 +00:00 committed by James Graham
parent 25917c5ff9
commit 4c82cf6218
2 changed files with 38 additions and 0 deletions

View File

@ -346631,6 +346631,14 @@
}
]
],
"html/semantics/embedded-content/the-img-element/decode/image-decode-with-quick-attach.html": [
[
"/html/semantics/embedded-content/the-img-element/decode/image-decode-with-quick-attach.html",
{
"timeout": "long"
}
]
],
"html/semantics/embedded-content/the-img-element/decode/image-decode.html": [
[
"/html/semantics/embedded-content/the-img-element/decode/image-decode.html",
@ -586110,6 +586118,10 @@
"9405efb65176096957438cbdcc59109b488d80e6",
"testharness"
],
"html/semantics/embedded-content/the-img-element/decode/image-decode-with-quick-attach.html": [
"cd7e495a854d848712b46cddec40e3ebffe9d3ba",
"testharness"
],
"html/semantics/embedded-content/the-img-element/decode/image-decode.html": [
"5368b62bf6c950e8d57b16b36148e5695ce16fd8",
"testharness"

View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>HTMLImageElement.prototype.decode(), attach to DOM before promise resolves.</title>
<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
<link rel=help href="https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-decode">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body></body>
<script>
"use strict";
promise_test(function() {
const img = new Image();
img.src = "/images/green.png";
const promise = img.decode().then(function(arg) {
assert_equals(arg, undefined);
});
// Don't wait for the promise to resolve before attaching the image.
// The promise should still resolve successfully.
document.body.appendChild(img);
return promise;
}, document.title);
</script>