feat: add WebFrameMain.visibilityState (#28706)
* feat: add WebFrameMain.visibilityState * docs: mention other page visibility APIs * test: delay visibilityState check after hiding * test: add waitForTrue to avoid flaky visibilityState test * refactor: waitForTrue -> waitUntil
This commit is contained in:
parent
93311c8686
commit
43d27cc4d1
5 changed files with 98 additions and 0 deletions
|
@ -6,6 +6,7 @@ import { BrowserWindow, WebFrameMain, webFrameMain, ipcMain } from 'electron/mai
|
|||
import { closeAllWindows } from './window-helpers';
|
||||
import { emittedOnce, emittedNTimes } from './events-helpers';
|
||||
import { AddressInfo } from 'net';
|
||||
import { waitUntil } from './spec-helpers';
|
||||
|
||||
describe('webFrameMain module', () => {
|
||||
const fixtures = path.resolve(__dirname, '..', 'spec-main', 'fixtures');
|
||||
|
@ -135,6 +136,20 @@ describe('webFrameMain module', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('WebFrame.visibilityState', () => {
|
||||
it('should match window state', async () => {
|
||||
const w = new BrowserWindow({ show: true });
|
||||
await w.loadURL('about:blank');
|
||||
const webFrame = w.webContents.mainFrame;
|
||||
|
||||
expect(webFrame.visibilityState).to.equal('visible');
|
||||
w.hide();
|
||||
await expect(
|
||||
waitUntil(() => webFrame.visibilityState === 'hidden')
|
||||
).to.eventually.be.fulfilled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('WebFrame.executeJavaScript', () => {
|
||||
it('can inject code into any subframe', async () => {
|
||||
const w = new BrowserWindow({ show: false, webPreferences: { contextIsolation: true } });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue