chore: restore deprecate as an internal module (#40124)

* Revert "refactor: don't expose deprecate as an internal module (#35311)"

This reverts commit 8424779906.

* check crashed event warnings
This commit is contained in:
Milan Burda 2023-10-09 01:55:16 +02:00 committed by GitHub
parent 8b8fbd0408
commit 737e3de3fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 106 additions and 27 deletions

View file

@ -3,7 +3,7 @@ import { AddressInfo } from 'node:net';
import * as path from 'node:path';
import * as fs from 'node:fs';
import * as http from 'node:http';
import { BrowserWindow, ipcMain, webContents, session, app, BrowserView, WebContents } from 'electron/main';
import { BrowserWindow, ipcMain, webContents, session, app, BrowserView, WebContents, deprecate } from 'electron/main';
import { closeAllWindows } from './lib/window-helpers';
import { ifdescribe, defer, waitUntil, listen, ifit } from './lib/spec-helpers';
import { once } from 'node:events';
@ -2331,6 +2331,8 @@ describe('webContents module', () => {
});
describe('crashed event', () => {
afterEach(() => deprecate.setHandler(null));
it('does not crash main process when destroying WebContents in it', async () => {
const contents = (webContents as typeof ElectronInternal.WebContents).create({ nodeIntegration: true });
const crashEvent = once(contents, 'render-process-gone');
@ -2339,6 +2341,21 @@ describe('webContents module', () => {
await crashEvent;
contents.destroy();
});
it('logs a warning', async () => {
const contents = (webContents as typeof ElectronInternal.WebContents).create({ nodeIntegration: true });
await contents.loadURL('about:blank');
const messages: string[] = [];
deprecate.setHandler(message => messages.push(message));
const crashEvent = once(contents, 'crashed');
contents.forcefullyCrashRenderer();
const [, killed] = await crashEvent;
expect(killed).to.be.a('boolean');
expect(messages).to.deep.equal(['\'crashed event\' is deprecated and will be removed. Please use \'render-process-gone event\' instead.']);
});
});
describe('context-menu event', () => {