test: fixup visibility tests (#44802)
* test: ensure all webContents are closed * test: ensure all webContents are closed * test: fixup api-web-request-spec.ts
This commit is contained in:
parent
433a7b69e3
commit
85a0240b5c
3 changed files with 12 additions and 6 deletions
|
@ -8,7 +8,11 @@ import { defer } from './lib/spec-helpers';
|
||||||
import { closeAllWindows } from './lib/window-helpers';
|
import { closeAllWindows } from './lib/window-helpers';
|
||||||
|
|
||||||
describe('WebContentsView', () => {
|
describe('WebContentsView', () => {
|
||||||
afterEach(closeAllWindows);
|
afterEach(async () => {
|
||||||
|
await closeAllWindows();
|
||||||
|
const existingWCS = webContents.getAllWebContents();
|
||||||
|
existingWCS.forEach((contents) => contents.close());
|
||||||
|
});
|
||||||
|
|
||||||
it('can be instantiated with no arguments', () => {
|
it('can be instantiated with no arguments', () => {
|
||||||
// eslint-disable-next-line no-new
|
// eslint-disable-next-line no-new
|
||||||
|
|
|
@ -64,7 +64,6 @@ describe('webRequest module', () => {
|
||||||
protocol.registerStringProtocol('cors', (req, cb) => cb(''));
|
protocol.registerStringProtocol('cors', (req, cb) => cb(''));
|
||||||
defaultURL = (await listen(server)).url + '/';
|
defaultURL = (await listen(server)).url + '/';
|
||||||
http2URL = (await listen(h2server)).url + '/';
|
http2URL = (await listen(h2server)).url + '/';
|
||||||
console.log(http2URL);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(() => {
|
after(() => {
|
||||||
|
@ -660,7 +659,7 @@ describe('webRequest module', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Cleanup.
|
// Cleanup.
|
||||||
after(() => {
|
defer(() => {
|
||||||
contents.destroy();
|
contents.destroy();
|
||||||
server.close();
|
server.close();
|
||||||
ses.webRequest.onBeforeRequest(null);
|
ses.webRequest.onBeforeRequest(null);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { BaseWindow, BrowserWindow, BrowserWindowConstructorOptions, ipcMain, WebContents, WebContentsView } from 'electron/main';
|
import { BaseWindow, BrowserWindow, BrowserWindowConstructorOptions, ipcMain, webContents, WebContents, WebContentsView } from 'electron/main';
|
||||||
|
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
|
|
||||||
|
@ -15,8 +15,11 @@ import { closeWindow } from './lib/window-helpers';
|
||||||
ifdescribe(process.platform !== 'linux')('document.visibilityState', () => {
|
ifdescribe(process.platform !== 'linux')('document.visibilityState', () => {
|
||||||
let w: BaseWindow & {webContents: WebContents};
|
let w: BaseWindow & {webContents: WebContents};
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(async () => {
|
||||||
return closeWindow(w);
|
await closeWindow(w);
|
||||||
|
w = null as unknown as BrowserWindow;
|
||||||
|
const existingWCS = webContents.getAllWebContents();
|
||||||
|
existingWCS.forEach((contents) => contents.close());
|
||||||
});
|
});
|
||||||
|
|
||||||
const load = () => w.webContents.loadFile(path.resolve(__dirname, 'fixtures', 'chromium', 'visibilitystate.html'));
|
const load = () => w.webContents.loadFile(path.resolve(__dirname, 'fixtures', 'chromium', 'visibilitystate.html'));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue