From 58dac4c0fc8aa84ddc5f453d506798fbc901427d Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Thu, 1 Apr 2021 21:22:15 -0400 Subject: [PATCH] tests: Fix races in `inner_height.js` --- src/tests/frontend/specs/inner_height.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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); }); });