Commit d9951694 authored by Manuel Bucher's avatar Manuel Bucher
Browse files

Bug 1753730 - Test that the cached image from the early hint preload is used...

Bug 1753730 - Test that the cached image from the early hint preload is used r=necko-reviewers,ckerschb,dragana,kershaw

* Test that the preloaded image is actually used and that no preload requests
  are made if the resource shouldn't be preloaded

Differential Revision: https://phabricator.services.mozilla.com/D139740
parent b01d2892
Loading
Loading
Loading
Loading
+4 −24
Original line number Diff line number Diff line
<head>
</head>
<!DOCTYPE html>
<html>
<body>
<script class="testbody" type="text/javascript">

function checkNumberOfLoads(shouldBe) {
  var numDownloads = 0;
  window.performance.getEntriesByName("http://example.com/browser/netwerk/test/browser/square.png").forEach(entry => {
    if (entry.transferSize > 0) {
      numDownloads++;
    }
  });
  window.parent.ok(numDownloads == shouldBe, "The number of downloads of square.png is not correct");
};

var img = document.createElement("img");
img.src = "http://example.com/browser/netwerk/test/browser/square.png";
img.addEventListener("load",() => {
  checkNumberOfLoads(1);
  window.parent.iframeTestCompleted();
});

document.body.appendChild(img);

</script>
<img src="http://example.com/browser/netwerk/test/browser/square.png" width="100px">
</body>
</html>
+6 −0
Original line number Diff line number Diff line
<!DOCTYPE html>
<html>
<body>
<img src="http://example.com/browser/netwerk/test/browser/early_hint_pixel.sjs?1ac2a5e1-90c7-4171-b0f0-676f7d899af3" width="100px">
</body>
</html>
+2 −0
Original line number Diff line number Diff line
Cache-Control: no-cache
Content-Security-Policy: img-src 'none'
+2 −0
Original line number Diff line number Diff line
HTTP 103 Too Early
Link: <http://example.com/browser/netwerk/test/browser/early_hint_pixel.sjs?1ac2a5e1-90c7-4171-b0f0-676f7d899af3>; rel=preload; as=image
+6 −0
Original line number Diff line number Diff line
<!DOCTYPE html>
<html>
<body>
<iframe src="/browser/netwerk/test/browser/early_hint_main_html.sjs?early_hint_pixel.sjs=5ecccd01-dd3f-4bbd-bd3e-0491d7dd78a1" width="100px">
</body>
</html>
Loading