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:
parent
8b8fbd0408
commit
737e3de3fa
12 changed files with 106 additions and 27 deletions
|
@ -6,7 +6,7 @@ import * as net from 'node:net';
|
|||
import * as fs from 'fs-extra';
|
||||
import * as path from 'node:path';
|
||||
import { promisify } from 'node:util';
|
||||
import { app, BrowserWindow, Menu, session, net as electronNet, WebContents } from 'electron/main';
|
||||
import { app, BrowserWindow, Menu, session, net as electronNet, WebContents, deprecate } from 'electron/main';
|
||||
import { closeWindow, closeAllWindows } from './lib/window-helpers';
|
||||
import { ifdescribe, ifit, listen, waitUntil } from './lib/spec-helpers';
|
||||
import { once } from 'node:events';
|
||||
|
@ -492,7 +492,10 @@ describe('app module', () => {
|
|||
describe('BrowserWindow events', () => {
|
||||
let w: BrowserWindow = null as any;
|
||||
|
||||
afterEach(() => closeWindow(w).then(() => { w = null as any; }));
|
||||
afterEach(() => {
|
||||
deprecate.setHandler(null);
|
||||
closeWindow(w).then(() => { w = null as any; });
|
||||
});
|
||||
|
||||
it('should emit browser-window-focus event when window is focused', async () => {
|
||||
const emitted = once(app, 'browser-window-focus') as Promise<[any, BrowserWindow]>;
|
||||
|
@ -535,11 +538,16 @@ describe('app module', () => {
|
|||
});
|
||||
await w.loadURL('about:blank');
|
||||
|
||||
const emitted = once(app, 'renderer-process-crashed') as Promise<[any, WebContents]>;
|
||||
const messages: string[] = [];
|
||||
deprecate.setHandler(message => messages.push(message));
|
||||
|
||||
const emitted = once(app, 'renderer-process-crashed') as Promise<[any, WebContents, boolean]>;
|
||||
w.webContents.executeJavaScript('process.crash()');
|
||||
|
||||
const [, webContents] = await emitted;
|
||||
const [, webContents, killed] = await emitted;
|
||||
expect(webContents).to.equal(w.webContents);
|
||||
expect(killed).to.be.false();
|
||||
expect(messages).to.deep.equal(['\'renderer-process-crashed event\' is deprecated and will be removed. Please use \'render-process-gone event\' instead.']);
|
||||
});
|
||||
|
||||
// FIXME: re-enable this test on win32.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue