commit 47431d017ae195482acb2628bdd75a9cc6b153a8
parent 2e6f5482aaa670023abcadd9c74301de81239a4c
Author: Koji Ishii <kojii@chromium.org>
Date: Fri, 31 Oct 2025 08:55:44 +0000
Bug 1996788 [wpt PR 55691] - [iframe] Use the initial ICB when computing the natural size, a=testonly
Automatic update from web-platform-tests
[iframe] Use the initial ICB when computing the natural size
This patch changes the ICB of responsive iframes to be always
the same one as the initial layout, in order to mitigate the
risk of layout loop.
Bug: 418397278
Change-Id: I9c9fab4344ba6117f6add5ee585cb2178a0f1264
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7077277
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1536459}
--
wpt-commits: 3734af98677a881d90e56c9f9fbe8719d31c18cb
wpt-pr: 55691
Diffstat:
2 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/tests/css/css-sizing/responsive-iframe/resources/iframe-contents-icb.html b/testing/web-platform/tests/css/css-sizing/responsive-iframe/resources/iframe-contents-icb.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<style>
+:root, body {
+ margin: 0;
+ height: 100%;
+}
+
+#target {
+ height: 300px;
+ background-color: lightBlue;
+ border: orange 10px solid;
+ box-sizing: border-box;
+}
+</style>
+<meta name="responsive-embedded-sizing">
+<div id="target"></div>
+<script>
+window.addEventListener('message', e => {
+ const target = document.getElementById('target');
+ if (e.data.name === 'height100p') {
+ target.style.height = '100%';
+ window.requestResize();
+ window.parent.postMessage({
+ name: 'height100pDone',
+ }, '*');
+ }
+});
+</script>
diff --git a/testing/web-platform/tests/css/css-sizing/responsive-iframe/responsive-iframe-icb.tentative.html b/testing/web-platform/tests/css/css-sizing/responsive-iframe/responsive-iframe-icb.tentative.html
@@ -0,0 +1,35 @@
+<!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;
+}
+</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>