summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/decode/image-decode-with-quick-attach.html
blob: be680da619e8dd75f57d454268a528eba7d0d6c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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>