| <!doctype HTML> |
| <title>Test that IFRAME content uses the initial ICB to measure the natural size.</title> |
| <link rel="author" href="mailto:kojii@chromium.org"> |
| <link rel="help" href="https://drafts.csswg.org/css-sizing/"> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="/common/rendering-utils.js"></script> |
| <style> |
| iframe { |
| border: 1px solid black; |
| frame-sizing: content-height; |
| } |
| </style> |
| <iframe id="target" frameborder=0 src="resources/iframe-contents-icb.html"></iframe> |
| <script> |
| async_test(t => { |
| const target = document.getElementById('target'); |
| window.addEventListener('load', t.step_func(e => { |
| // On load, the IFRAME is resized to the content size. |
| assert_equals(target.offsetHeight, 300 + 2); |
| |
| // Change the `height` of the IFRAME content to `100%`. |
| target.contentWindow.postMessage({ name: 'height100p' }, '*'); |
| })); |
| window.addEventListener('message', t.step_func(async (e) => { |
| if (e.data.name === 'height100pDone') { |
| // The `height: 100%` for the `requestResize()` should compute |
| // using the original ICB size. |
| await waitForAtLeastOneFrame(); |
| assert_equals(target.offsetHeight, 150 + 2); |
| t.done(); |
| } |
| })); |
| }, "IFRAME content should use the initial ICB to measure the natural size"); |
| </script> |