test: fixup flaky tests (#44380)

* test: fixup flaky test

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

* test: disable flaky protocol speed test on macOS

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

* test: fixup flaky test in api-browser-window-spec.ts

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>

* test: update waitUntil to handle async functions

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
This commit is contained in:
trop[bot] 2024-10-24 15:21:55 +02:00 committed by GitHub
commit e9988c2fc4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 45 additions and 38 deletions

View file

@ -15,7 +15,7 @@ import { setTimeout } from 'node:timers/promises';
import { emittedUntil, emittedNTimes } from './lib/events-helpers';
import { HexColors, hasCapturableScreen, ScreenCapture } from './lib/screen-helpers';
import { ifit, ifdescribe, defer, listen } from './lib/spec-helpers';
import { ifit, ifdescribe, defer, listen, waitUntil } from './lib/spec-helpers';
import { closeWindow, closeAllWindows } from './lib/window-helpers';
const fixtures = path.resolve(__dirname, 'fixtures');
@ -5978,8 +5978,10 @@ describe('BrowserWindow module', () => {
w.webContents.on('enter-html-full-screen', async () => {
enterCount++;
if (w.isFullScreen()) reject(new Error('w.isFullScreen should be false'));
const isFS = await w.webContents.executeJavaScript('!!document.fullscreenElement');
if (!isFS) reject(new Error('Document should have fullscreen element'));
await waitUntil(async () => {
const isFS = await w.webContents.executeJavaScript('!!document.fullscreenElement');
return isFS === true;
});
checkDone();
});