Skip to content

Commit

Permalink
Remove ResizeObserver lifecycle DCHECK
Browse files Browse the repository at this point in the history
LocalFrameView::NotifyResizeObservers had a DCHECK that the lifecycle
was clean, but this can be violated if an earlier resize observer (from
a different frame) dirtied the tree. We can safely remove this DCHECK
and continue for the same reasons that we continue when a modification
occurs in the presence of two same-frame resize observers.

Bug: 1368458
Change-Id: I5d486d9194e311f1d71ae94e4f688eccbc744fd2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5160333
Auto-Submit: Philip Rogers <[email protected]>
Reviewed-by: Stefan Zager <[email protected]>
Commit-Queue: Philip Rogers <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1244944}
  • Loading branch information
progers authored and chromium-wpt-export-bot committed Jan 9, 2024
1 parent 38f6aaf commit 7f56415
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions resize-observer/multiple-observers-with-mutation-crash.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!doctype html>
<html class="test-wait">
<!--
This test is for crbug.com/1368458 which is a crash where we expected
up-to-date style&layout when delivering resize observations. We would crash
if a resize observer in one frame caused a modification in the presence of a
resize observer in another frame.
-->
<iframe id="iframe" style="border: none;" srcdoc="
<!doctype html>
<style>body { margin: 0; }</style>
<div id='inner_element'>hello</div>
<script>
const resizeObserver = new ResizeObserver((entries) => {
const size = entries[0].borderBoxSize[0].inlineSize;
const event = new CustomEvent('onIframeResizeObserved', {detail: size});
parent.document.dispatchEvent(event);
});
resizeObserver.observe(inner_element);
</script>
"></iframe>
<div id="outer_element" style="width: 200px;">world</div>

<script>
const onInnerElementInitialResize = (event) => {
// `inner_element` should result in an initial observation of width 300px.
window.document.removeEventListener(
'onIframeResizeObserved', onInnerElementInitialResize, false);

const resizeObserver = new ResizeObserver((entries) => {
// `outer_element` should result in an initial observation of width 200px.

// Modify styles so that inner_element is resized.
iframe.contentDocument.body.style.width = "200px";
});
resizeObserver.observe(outer_element);

const onInnerElementSecondResize = (event) => {
// `inner_element` should result in a second observation of width 100px.

// Finish the test.
document.documentElement.classList.remove('test-wait');
};
window.document.addEventListener(
'onIframeResizeObserved', onInnerElementSecondResize, false);
};
window.document.addEventListener(
'onIframeResizeObserved', onInnerElementInitialResize, false);
</script>

0 comments on commit 7f56415

Please sign in to comment.