Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!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>
<style>
iframe {
border: 1px solid black;
contain-intrinsic-size: from-element none;
}
</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(e => {
if (e.data.name === 'height100pDone') {
// The `height: 100%` for the `requestResize()` should compute
// using the original ICB size.
requestAnimationFrame(t.step_func(() => {
assert_equals(target.offsetHeight, 150 + 2);
t.done();
}));
}
}));
}, "IFRAME content should use the initial ICB to measure the natural size");
</script>