summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/delay-load-event-detached.html
blob: 5c68de29e90a5c84ece9a9a95a77aec6b5301ac3 (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
27
28
29
30
<!DOCTYPE html>
<meta charset="utf-8">
<title>Detached image blocks load</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var img_loaded = false;

var img = new Image();
img.onload = function() {
  img_loaded = true;
};
img.src = "/images/blue.png?pipe=trickle(d2)";

test(function() {
  assert_false(img_loaded);
}, "setting img.src is async");

async_test(function(t) {
  document.addEventListener("DOMContentLoaded", t.step_func_done(function() {
    assert_false(img_loaded);
  }));
}, "DOMContentLoaded doesn't wait for images");

async_test(function(t) {
  window.addEventListener("load", t.step_func_done(function() {
    assert_true(img_loaded);
  }));
}, "load waits for images");
</script>