responsive-iframe-icb.tentative.html (1324B)
1 <!doctype HTML> 2 <title>Test that IFRAME content uses the initial ICB to measure the natural size.</title> 3 <link rel="author" href="mailto:kojii@chromium.org"> 4 <link rel="help" href="https://drafts.csswg.org/css-sizing/"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <style> 8 iframe { 9 border: 1px solid black; 10 contain-intrinsic-size: from-element none; 11 } 12 </style> 13 <iframe id="target" frameborder=0 src="resources/iframe-contents-icb.html"></iframe> 14 <script> 15 async_test(t => { 16 const target = document.getElementById('target'); 17 window.addEventListener('load', t.step_func(e => { 18 // On load, the IFRAME is resized to the content size. 19 assert_equals(target.offsetHeight, 300 + 2); 20 21 // Change the `height` of the IFRAME content to `100%`. 22 target.contentWindow.postMessage({ name: 'height100p' }, '*'); 23 })); 24 window.addEventListener('message', t.step_func(e => { 25 if (e.data.name === 'height100pDone') { 26 // The `height: 100%` for the `requestResize()` should compute 27 // using the original ICB size. 28 requestAnimationFrame(t.step_func(() => { 29 assert_equals(target.offsetHeight, 150 + 2); 30 t.done(); 31 })); 32 } 33 })); 34 }, "IFRAME content should use the initial ICB to measure the natural size"); 35 </script>