blob: bbd12272eac0ca89c993d908e7e840b6143ef8ae [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test.js"></script>
<script>
description('This tests that resize event is not dispatched on visualViewport 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.visualViewport.addEventListener('resize', () => logs.push('AA'));
iframeA.contentWindow.visualViewport.addEventListener('resize', () => logs.push('A'));
iframeB.contentWindow.visualViewport.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>