list-of-available-images-does-not-coalesce-in-flight-requests.sub.tentative.html (2446B)
1 <!doctype html> 2 <html> 3 <title>List of available images does not coalesce in-flight requests</title> 4 <link rel="author" title="Dom Farolino" href="mailto:dom@chromium.org"> 5 <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-list-of-available-images"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 9 <script> 10 const uuid = "{{uuid()}}"; 11 const path = location.origin + '/html/semantics/embedded-content/the-img-element/resources/image-and-stash.py'; 12 13 promise_test(async t => { 14 let first_image_promise = new Promise((resolve, reject) => { 15 const img = new Image(); 16 img.onload = resolve; 17 img.onerror = e => { reject(new Error("The img should not fail to load")) }; 18 img.src = path + `?increment=${uuid}&pipe=trickle(d1)`; 19 }); 20 21 // As of right now, the spec's #updating-the-image-data step 6 [1] does not 22 // place images into the "list of available images" until they are completely 23 // downloaded and the `load` event is fired. The spec also explicitly states 24 // that coalescing in-flight image requests is not what the list of available 25 // images is for. This test asserts this behavior, though since no browsers 26 // follow this behavior (they all allow coalescing in-flight requests for the 27 // same image resource) we've started discussion about this in 28 // https://github.com/whatwg/html/issues/7005. If that issue resolves in 29 // letting in-flight requests into the list of available images, then we 30 // should changes the expectations of this test. 31 // 32 // [1]: https://html.spec.whatwg.org/multipage/images.html#updating-the-image-data 33 let second_image_promise = new Promise((resolve, reject) => { 34 const img = new Image(); 35 img.onload = resolve; 36 img.onerror = e => { reject("The img should not fail to load") }; 37 img.src = path + `?increment=${uuid}&pipe=trickle(d1)`; 38 }); 39 40 await Promise.all([first_image_promise, second_image_promise]); 41 const response = await fetch(path + `?read=${uuid}`); 42 const request_count = await response.text(); 43 44 assert_equals(request_count, "2", "The server should have seen exactly two " + 45 "requests, since the second image request " + 46 "above did not coalesce with the first " + 47 "in-flight one"); 48 }, 'list of available images does not coalesce in-flight requests'); 49 </script>