summaryrefslogtreecommitdiffstats
path: root/layout/generic/test/file_reframe_for_lazy_load_image.html
blob: 912fbdf3c64753cf6019a8cb5cc58b90ab4195d9 (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
31
32
33
34
35
36
37
38
<!doctype html>
<meta charset="utf-8">
<title>
  Test for bug 1612649: We don't reframe for lazy load image state changes.
</title>
<div id="spacer" style="height: calc(100vh + 100px);"></div>
<img id="image" loading="lazy" width="20" height="20" alt="this is an image"
     src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAAG0lEQVR42mP8z0A%2BYKJA76jmUc2jmkc1U0EzACKcASfOgGoMAAAAAElFTkSuQmCC">
<script>
const is = opener.is.bind(opener);
const add_task = opener.add_task;
const original_finish = opener.SimpleTest.finish;
const SimpleTest = opener.SimpleTest;
SimpleTest.finish = function finish() {
  self.close();
  original_finish();
}

const utils = SpecialPowers.DOMWindowUtils;

add_task(async () => {
  await SimpleTest.promiseFocus();

  const previousConstructCount = utils.framesConstructed;

  const loadPromise =
      new Promise(resolve => image.addEventListener("load", resolve));

  image.scrollIntoView();

  await loadPromise;

  image.getBoundingClientRect();

  is(previousConstructCount, utils.framesConstructed,
     "We should not have reframed");
});
</script>