tests: Fix races in `inner_height.js`

pull/4989/head
Richard Hansen 2021-04-01 21:22:15 -04:00 committed by webzwo0i
parent 4ad80d4072
commit 58dac4c0fc
1 changed files with 8 additions and 8 deletions

View File

@ -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);
});
});