haikuwebkit/LayoutTests/fast/events/resize-subframe-in-renderin...

56 lines
1.7 KiB
HTML
Raw Permalink Normal View History

Integrate resize event with HTML5 event loop https://bugs.webkit.org/show_bug.cgi?id=202964 Reviewed by Geoffrey Garen and Simon Fraser. Source/WebCore: Dispatch resize events in "run the resize steps" during the "update the rendering": https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering Existing code in WebCore which was dispatching or scheduling dispatching of resize events now simply sets a flag on document and schedules a rendering update. In Page::updateRendering, we fire resize events on any documents with this flag set. Test: fast/events/resize-subframe-in-rendering-update.html * css/CSSFontSelector.cpp: (WebCore::CSSFontSelector::beginLoadTimerFired): Fixed the flakiness in SVG animation tests observed after this patch was landed previously. The issue was that this code was calling FrameLoader's checkLoadComplete before checkCompleted. checkCompleted starts SVG animations in Document::implicitClose whereas checkLoadComplete can cause DumpRenderTree to end the test. As a result, depending on when this function was called relative to other work being done in the main thread, DumpRenderTree could prematurely end and dump the test result even though SVG animation would have immediately started in either scenario. Unfortunately I couldn't come up with a new deterministic test for this issue since the exact condition under which this problem comes up seems quite racy (which makes sense given this only manifested as flaky failures in existing tests). * dom/Document.cpp: (WebCore::Document::setNeedsDOMWindowResizeEvent): Added. (WebCore::Document::setNeedsVisualViewportResize): Added. (WebCore::Document::runResizeSteps): Added. https://drafts.csswg.org/cssom-view/#run-the-resize-steps * dom/Document.h: * page/FrameView.cpp: (WebCore::FrameView::sendResizeEventIfNeeded): Now sets m_needsDOMWindowResizeEvent on Document instead of enqueuing a resize event. * page/Page.cpp: (WebCore::Page::updateRendering): Call runResizeSteps on each document. (WebCore::Page::collectDocuments): Added. * page/Page.h: * page/VisualViewport.cpp: (WebCore::VisualViewport::enqueueResizeEvent): LayoutTests: Added a regression test and fixed an existing test to work with the new behavior. * fast/events/resize-subframe-in-rendering-update-expected.txt: Added. * fast/events/resize-subframe-in-rendering-update.html: Added. * fast/shadow-dom/trusted-event-scoped-flags.html: Canonical link: https://commits.webkit.org/217056@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251867 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-31 19:26:10 +00:00
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test.js"></script>
<script>
description('This tests that resize event is not dispatched as a part of updateLayout');
jsTestIsAsync = true;
function createIframe(parentDocument)
{
const iframe = document.createElement('iframe');
iframe.style.width = '100px';
iframe.style.height = '100px';
parentDocument.body.appendChild(iframe);
iframe.contentDocument.body.innerHTML = '<span>hello, world</span>';
return iframe;
}
function updateLayout(iframe)
{
iframe.contentDocument.querySelector("span").getBoundingClientRect();
}
const iframeA = createIframe(document);
const iframeAA = createIframe(iframeA.contentDocument);
const iframeB = createIframe(document);
const logs = [];
requestAnimationFrame(() => {
setTimeout(() => {
iframeAA.contentWindow.addEventListener('resize', () => logs.push('AA'));
iframeA.contentWindow.addEventListener('resize', () => logs.push('A'));
iframeB.contentWindow.addEventListener('resize', () => logs.push('B'));
evalAndLog('iframeB.style.width = "200px"; updateLayout(iframeB)');
evalAndLog('iframeA.style.width = "200px"; updateLayout(iframeA)');
evalAndLog('iframeAA.style.width = "200px"; updateLayout(iframeAA)');
shouldBe('logs.length', '0');
setTimeout(() => {
requestAnimationFrame(() => {
debug('After requestAnimationFrame');
shouldBe('logs.length', '3');
shouldBeEqualToString('logs.join(", ")', 'A, AA, B');
iframeA.remove();
iframeB.remove();
finishJSTest();
});
}, 0);
}, 0);
});
</script>
</body>
</html>