diff --git a/src/tests/frontend/specs/inner_height.js b/src/tests/frontend/specs/inner_height.js index 8bd0a2317..d1a6b118b 100644 --- a/src/tests/frontend/specs/inner_height.js +++ b/src/tests/frontend/specs/inner_height.js @@ -7,10 +7,11 @@ describe('height regression after ace.js refactoring', function () { // everything fits inside the viewport it('clientHeight should equal scrollHeight with few lines', async function () { - const aceOuter = helper.padChrome$('iframe')[0].contentDocument; - const clientHeight = aceOuter.documentElement.clientHeight; - const scrollHeight = aceOuter.documentElement.scrollHeight; - expect(clientHeight).to.be(scrollHeight); + await helper.clearPad(); + const outerHtml = helper.padChrome$('iframe')[0].contentDocument.documentElement; + // Give some time for the heights to settle. + await new Promise((resolve) => setTimeout(resolve, 100)); + expect(outerHtml.clientHeight).to.be(outerHtml.scrollHeight); }); it('client height should be less than scrollHeight with many lines', async function () { @@ -23,9 +24,8 @@ describe('height regression after ace.js refactoring', function () { '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'); - const aceOuter = helper.padChrome$('iframe')[0].contentDocument; - const clientHeight = aceOuter.documentElement.clientHeight; - const scrollHeight = aceOuter.documentElement.scrollHeight; - expect(clientHeight).to.be.lessThan(scrollHeight); + const outerHtml = helper.padChrome$('iframe')[0].contentDocument.documentElement; + // Need to poll because the heights take some time to settle. + await helper.waitForPromise(() => outerHtml.clientHeight < outerHtml.scrollHeight); }); });