mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Compare commits
5 Commits
v28.0.0-ni
...
v28.0.0-al
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3e7bf3786 | ||
|
|
3e70692e4b | ||
|
|
c892c61b90 | ||
|
|
2c88626b51 | ||
|
|
7e312c81ca |
@@ -75,6 +75,34 @@ console.log(app.runningUnderRosettaTranslation)
|
||||
console.log(app.runningUnderARM64Translation)
|
||||
```
|
||||
|
||||
### Deprecated: `renderer-process-crashed` event on `app`
|
||||
|
||||
The `renderer-process-crashed` event on `app` has been deprecated.
|
||||
Use the new `render-process-gone` event instead.
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
app.on('renderer-process-crashed', (event, webContents, killed) => { /* ... */ })
|
||||
|
||||
// Replace with
|
||||
app.on('render-process-gone', (event, webContents, details) => { /* ... */ })
|
||||
```
|
||||
|
||||
### Deprecated: `crashed` event on `WebContents` and `<webview>`
|
||||
|
||||
The `crashed` events on `WebContents` and `<webview>` have been deprecated.
|
||||
Use the new `render-process-gone` event instead.
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
win.webContents.on('crashed', (event, killed) => { /* ... */ })
|
||||
webview.addEventListener('crashed', (event) => { /* ... */ })
|
||||
|
||||
// Replace with
|
||||
win.webContents.on('render-process-gone', (event, details) => { /* ... */ })
|
||||
webview.addEventListener('render-process-gone', (event) => { /* ... */ })
|
||||
```
|
||||
|
||||
## Planned Breaking API Changes (27.0)
|
||||
|
||||
### Removed: macOS 10.13 / 10.14 support
|
||||
|
||||
@@ -9,12 +9,13 @@ check out our [Electron Versioning](./electron-versioning.md) doc.
|
||||
|
||||
| Electron | Alpha | Beta | Stable | EOL | Chrome | Node | Supported |
|
||||
| ------- | ----- | ------- | ------ | ------ | ---- | ---- | ---- |
|
||||
| 27.0.0 | 2023-Aug-17 | 2023-Sep-13 | 2023-Oct-10 | TBD | M118 | TBD | ✅ |
|
||||
| 28.0.0 | 2023-Oct-11 | 2023-Nov-6 | 2023-Dec-5 | TBD | M120 | TBD | ✅ |
|
||||
| 27.0.0 | 2023-Aug-17 | 2023-Sep-13 | 2023-Oct-10 | 2024-Apr-16 | M118 | v18.17 | ✅ |
|
||||
| 26.0.0 | 2023-Jun-01 | 2023-Jun-27 | 2023-Aug-15 | 2024-Feb-27 | M116 | v18.16 | ✅ |
|
||||
| 25.0.0 | 2023-Apr-10 | 2023-May-02 | 2023-May-30 | 2024-Jan-02 | M114 | v18.15 | ✅ |
|
||||
| 24.0.0 | 2023-Feb-09 | 2023-Mar-07 | 2023-Apr-04 | 2023-Oct-10 | M112 | v18.14 | ✅ |
|
||||
| 24.0.0 | 2023-Feb-09 | 2023-Mar-07 | 2023-Apr-04 | 2023-Oct-10 | M112 | v18.14 | 🚫 |
|
||||
| 23.0.0 | 2022-Dec-01 | 2023-Jan-10 | 2023-Feb-07 | 2023-Aug-15 | M110 | v18.12 | 🚫 |
|
||||
| 22.0.0 | 2022-Sep-29 | 2022-Oct-25 | 2022-Nov-29 | 2023-Oct-10 | M108 | v16.17 | ✅ |
|
||||
| 22.0.0 | 2022-Sep-29 | 2022-Oct-25 | 2022-Nov-29 | 2023-Oct-10 | M108 | v16.17 | 🚫 |
|
||||
| 21.0.0 | 2022-Aug-04 | 2022-Aug-30 | 2022-Sep-27 | 2023-Apr-04 | M106 | v16.16 | 🚫 |
|
||||
| 20.0.0 | 2022-May-26 | 2022-Jun-21 | 2022-Aug-02 | 2023-Feb-07 | M104 | v16.15 | 🚫 |
|
||||
| 19.0.0 | 2022-Mar-31 | 2022-Apr-26 | 2022-May-24 | 2022-Nov-29 | M102 | v16.14 | 🚫 |
|
||||
|
||||
@@ -142,7 +142,6 @@ auto_filenames = {
|
||||
]
|
||||
|
||||
sandbox_bundle_deps = [
|
||||
"lib/common/api/deprecate.ts",
|
||||
"lib/common/api/native-image.ts",
|
||||
"lib/common/define-properties.ts",
|
||||
"lib/common/ipc-messages.ts",
|
||||
@@ -248,11 +247,11 @@ auto_filenames = {
|
||||
"lib/browser/parse-features-string.ts",
|
||||
"lib/browser/rpc-server.ts",
|
||||
"lib/browser/web-view-events.ts",
|
||||
"lib/common/api/deprecate.ts",
|
||||
"lib/common/api/module-list.ts",
|
||||
"lib/common/api/native-image.ts",
|
||||
"lib/common/api/shell.ts",
|
||||
"lib/common/define-properties.ts",
|
||||
"lib/common/deprecate.ts",
|
||||
"lib/common/init.ts",
|
||||
"lib/common/ipc-messages.ts",
|
||||
"lib/common/reset-search-paths.ts",
|
||||
@@ -266,7 +265,6 @@ auto_filenames = {
|
||||
]
|
||||
|
||||
renderer_bundle_deps = [
|
||||
"lib/common/api/deprecate.ts",
|
||||
"lib/common/api/module-list.ts",
|
||||
"lib/common/api/native-image.ts",
|
||||
"lib/common/api/shell.ts",
|
||||
@@ -305,7 +303,6 @@ auto_filenames = {
|
||||
]
|
||||
|
||||
worker_bundle_deps = [
|
||||
"lib/common/api/deprecate.ts",
|
||||
"lib/common/api/module-list.ts",
|
||||
"lib/common/api/native-image.ts",
|
||||
"lib/common/api/shell.ts",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as fs from 'fs';
|
||||
|
||||
import { Menu, deprecate } from 'electron/main';
|
||||
import { Menu } from 'electron/main';
|
||||
import * as deprecate from '@electron/internal/common/deprecate';
|
||||
|
||||
const bindings = process._linkedBinding('electron_browser_app');
|
||||
const commandLine = process._linkedBinding('electron_common_command_line');
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { app, deprecate } from 'electron/main';
|
||||
import { app } from 'electron/main';
|
||||
import * as deprecate from '@electron/internal/common/deprecate';
|
||||
|
||||
const binding = process._linkedBinding('electron_browser_crash_reporter');
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { app, ipcMain, session, webFrameMain, deprecate } from 'electron/main';
|
||||
import { app, ipcMain, session, webFrameMain } from 'electron/main';
|
||||
import type { BrowserWindowConstructorOptions, LoadURLOptions } from 'electron/main';
|
||||
|
||||
import * as url from 'url';
|
||||
@@ -10,6 +10,7 @@ import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-util
|
||||
import { MessagePortMain } from '@electron/internal/browser/message-port-main';
|
||||
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
|
||||
import { IpcMainImpl } from '@electron/internal/browser/ipc-main-impl';
|
||||
import * as deprecate from '@electron/internal/common/deprecate';
|
||||
|
||||
// session is not used here, the purpose is to make sure session is initialized
|
||||
// before the webContents module.
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// Common modules, please sort alphabetically
|
||||
export const commonModuleList: ElectronInternal.ModuleEntry[] = [
|
||||
{ name: 'nativeImage', loader: () => require('./native-image') },
|
||||
{ name: 'shell', loader: () => require('./shell') },
|
||||
// The internal modules, invisible unless you know their names.
|
||||
{ name: 'deprecate', loader: () => require('./deprecate'), private: true }
|
||||
{ name: 'shell', loader: () => require('./shell') }
|
||||
];
|
||||
|
||||
@@ -9,7 +9,7 @@ export function defineProperties (targetExports: Object, moduleList: ElectronInt
|
||||
const descriptors: PropertyDescriptorMap = {};
|
||||
for (const module of moduleList) {
|
||||
descriptors[module.name] = {
|
||||
enumerable: !module.private,
|
||||
enumerable: true,
|
||||
get: handleESModule(module.loader)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ type DeprecationHandler = (message: string) => void;
|
||||
|
||||
let deprecationHandler: DeprecationHandler | null = null;
|
||||
|
||||
function warnOnce (oldName: string, newName?: string) {
|
||||
export function warnOnce (oldName: string, newName?: string) {
|
||||
return warnOnceMessage(newName
|
||||
? `'${oldName}' is deprecated and will be removed. Please use '${newName}' instead.`
|
||||
: `'${oldName}' is deprecated and will be removed.`);
|
||||
}
|
||||
|
||||
function warnOnceMessage (msg: string) {
|
||||
export function warnOnceMessage (msg: string) {
|
||||
let warned = false;
|
||||
return () => {
|
||||
if (!warned && !process.noDeprecation) {
|
||||
@@ -18,21 +18,21 @@ function warnOnceMessage (msg: string) {
|
||||
};
|
||||
}
|
||||
|
||||
function setHandler (handler: DeprecationHandler | null): void {
|
||||
export function setHandler (handler: DeprecationHandler | null): void {
|
||||
deprecationHandler = handler;
|
||||
}
|
||||
|
||||
function getHandler (): DeprecationHandler | null {
|
||||
export function getHandler (): DeprecationHandler | null {
|
||||
return deprecationHandler;
|
||||
}
|
||||
|
||||
function warn (oldName: string, newName: string): void {
|
||||
export function warn (oldName: string, newName: string): void {
|
||||
if (!process.noDeprecation) {
|
||||
log(`'${oldName}' is deprecated. Use '${newName}' instead.`);
|
||||
}
|
||||
}
|
||||
|
||||
function log (message: string): void {
|
||||
export function log (message: string): void {
|
||||
if (typeof deprecationHandler === 'function') {
|
||||
deprecationHandler(message);
|
||||
} else if (process.throwDeprecation) {
|
||||
@@ -45,7 +45,7 @@ function log (message: string): void {
|
||||
}
|
||||
|
||||
// remove a function with no replacement
|
||||
function removeFunction<T extends Function> (fn: T, removedName: string): T {
|
||||
export function removeFunction<T extends Function> (fn: T, removedName: string): T {
|
||||
if (!fn) { throw new Error(`'${removedName} function' is invalid or does not exist.`); }
|
||||
|
||||
// wrap the deprecated function to warn user
|
||||
@@ -57,7 +57,7 @@ function removeFunction<T extends Function> (fn: T, removedName: string): T {
|
||||
}
|
||||
|
||||
// change the name of a function
|
||||
function renameFunction<T extends Function> (fn: T, newName: string): T {
|
||||
export function renameFunction<T extends Function> (fn: T, newName: string): T {
|
||||
const warn = warnOnce(`${fn.name} function`, `${newName} function`);
|
||||
return function (this: any) {
|
||||
warn();
|
||||
@@ -66,7 +66,7 @@ function renameFunction<T extends Function> (fn: T, newName: string): T {
|
||||
}
|
||||
|
||||
// change the name of an event
|
||||
function event (emitter: NodeJS.EventEmitter, oldName: string, newName: string, transformer: (...args: any[]) => any[] | undefined = (...args) => args) {
|
||||
export function event (emitter: NodeJS.EventEmitter, oldName: string, newName: string, transformer: (...args: any[]) => any[] | undefined = (...args) => args) {
|
||||
const warn = newName.startsWith('-') /* internal event */
|
||||
? warnOnce(`${oldName} event`)
|
||||
: warnOnce(`${oldName} event`, `${newName} event`);
|
||||
@@ -82,7 +82,7 @@ function event (emitter: NodeJS.EventEmitter, oldName: string, newName: string,
|
||||
}
|
||||
|
||||
// remove a property with no replacement
|
||||
function removeProperty<T extends Object, K extends (keyof T & string)>(object: T, removedName: K, onlyForValues?: any[]): T {
|
||||
export function removeProperty<T extends Object, K extends (keyof T & string)>(object: T, removedName: K, onlyForValues?: any[]): T {
|
||||
// if the property's already been removed, warn about it
|
||||
// eslint-disable-next-line no-proto
|
||||
const info = Object.getOwnPropertyDescriptor((object as any).__proto__, removedName);
|
||||
@@ -113,7 +113,7 @@ function removeProperty<T extends Object, K extends (keyof T & string)>(object:
|
||||
}
|
||||
|
||||
// change the name of a property
|
||||
function renameProperty<T extends Object, K extends (keyof T & string)>(object: T, oldName: string, newName: K): T {
|
||||
export function renameProperty<T extends Object, K extends (keyof T & string)>(object: T, oldName: string, newName: K): T {
|
||||
const warn = warnOnce(oldName, newName);
|
||||
|
||||
// if the new property isn't there yet,
|
||||
@@ -137,27 +137,10 @@ function renameProperty<T extends Object, K extends (keyof T & string)>(object:
|
||||
});
|
||||
}
|
||||
|
||||
function moveAPI<T extends Function> (fn: T, oldUsage: string, newUsage: string): T {
|
||||
export function moveAPI<T extends Function> (fn: T, oldUsage: string, newUsage: string): T {
|
||||
const warn = warnOnce(oldUsage, newUsage);
|
||||
return function (this: any) {
|
||||
warn();
|
||||
return fn.apply(this, arguments);
|
||||
} as unknown as typeof fn;
|
||||
}
|
||||
|
||||
const deprecate: ElectronInternal.DeprecationUtil = {
|
||||
warnOnce,
|
||||
warnOnceMessage,
|
||||
setHandler,
|
||||
getHandler,
|
||||
warn,
|
||||
log,
|
||||
removeFunction,
|
||||
renameFunction,
|
||||
event,
|
||||
removeProperty,
|
||||
renameProperty,
|
||||
moveAPI
|
||||
};
|
||||
|
||||
export default deprecate;
|
||||
@@ -18,11 +18,5 @@ export const moduleList: ElectronInternal.ModuleEntry[] = [
|
||||
{
|
||||
name: 'webFrame',
|
||||
loader: () => require('@electron/internal/renderer/api/web-frame')
|
||||
},
|
||||
// The internal modules, invisible unless you know their names.
|
||||
{
|
||||
name: 'deprecate',
|
||||
loader: () => require('@electron/internal/common/api/deprecate'),
|
||||
private: true
|
||||
}
|
||||
];
|
||||
|
||||
@@ -469,9 +469,16 @@ base::IDMap<WebContents*>& GetAllWebContents() {
|
||||
void OnCapturePageDone(gin_helper::Promise<gfx::Image> promise,
|
||||
base::ScopedClosureRunner capture_handle,
|
||||
const SkBitmap& bitmap) {
|
||||
auto ui_task_runner = content::GetUIThreadTaskRunner({});
|
||||
if (!ui_task_runner->RunsTasksInCurrentSequence()) {
|
||||
ui_task_runner->PostTask(
|
||||
FROM_HERE, base::BindOnce(&OnCapturePageDone, std::move(promise),
|
||||
std::move(capture_handle), bitmap));
|
||||
return;
|
||||
}
|
||||
|
||||
// Hack to enable transparency in captured image
|
||||
promise.Resolve(gfx::Image::CreateFrom1xBitmap(bitmap));
|
||||
|
||||
capture_handle.RunAndReset();
|
||||
}
|
||||
|
||||
@@ -3462,22 +3469,16 @@ v8::Local<v8::Promise> WebContents::CapturePage(gin::Arguments* args) {
|
||||
}
|
||||
|
||||
auto* const view = web_contents()->GetRenderWidgetHostView();
|
||||
if (!view) {
|
||||
if (!view || view->GetViewBounds().size().IsEmpty()) {
|
||||
promise.Resolve(gfx::Image());
|
||||
return handle;
|
||||
}
|
||||
|
||||
#if !BUILDFLAG(IS_MAC)
|
||||
// If the view's renderer is suspended this may fail on Windows/Linux -
|
||||
// bail if so. See CopyFromSurface in
|
||||
// content/public/browser/render_widget_host_view.h.
|
||||
auto* rfh = web_contents()->GetPrimaryMainFrame();
|
||||
if (rfh &&
|
||||
rfh->GetVisibilityState() == blink::mojom::PageVisibilityState::kHidden) {
|
||||
promise.Resolve(gfx::Image());
|
||||
if (!view->IsSurfaceAvailableForCopy()) {
|
||||
promise.RejectWithErrorMessage(
|
||||
"Current display surface not available for capture");
|
||||
return handle;
|
||||
}
|
||||
#endif // BUILDFLAG(IS_MAC)
|
||||
|
||||
auto capture_handle = web_contents()->IncrementCapturerCount(
|
||||
rect.size(), stay_hidden, stay_awake);
|
||||
|
||||
@@ -6,9 +6,10 @@ 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, deprecate } from 'electron/main';
|
||||
import { app, BrowserWindow, Menu, session, net as electronNet, WebContents } from 'electron/main';
|
||||
import { closeWindow, closeAllWindows } from './lib/window-helpers';
|
||||
import { ifdescribe, ifit, listen, waitUntil } from './lib/spec-helpers';
|
||||
import { expectDeprecationMessages } from './lib/deprecate-helpers';
|
||||
import { once } from 'node:events';
|
||||
import split = require('split')
|
||||
|
||||
@@ -493,7 +494,6 @@ describe('app module', () => {
|
||||
let w: BrowserWindow = null as any;
|
||||
|
||||
afterEach(() => {
|
||||
deprecate.setHandler(null);
|
||||
closeWindow(w).then(() => { w = null as any; });
|
||||
});
|
||||
|
||||
@@ -538,16 +538,14 @@ describe('app module', () => {
|
||||
});
|
||||
await w.loadURL('about:blank');
|
||||
|
||||
const messages: string[] = [];
|
||||
deprecate.setHandler(message => messages.push(message));
|
||||
expectDeprecationMessages(async () => {
|
||||
const emitted = once(app, 'renderer-process-crashed') as Promise<[any, WebContents, boolean]>;
|
||||
w.webContents.executeJavaScript('process.crash()');
|
||||
|
||||
const emitted = once(app, 'renderer-process-crashed') as Promise<[any, WebContents, boolean]>;
|
||||
w.webContents.executeJavaScript('process.crash()');
|
||||
|
||||
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.']);
|
||||
const [, webContents, killed] = await emitted;
|
||||
expect(webContents).to.equal(w.webContents);
|
||||
expect(killed).to.be.false();
|
||||
}, '\'renderer-process-crashed event\' is deprecated and will be removed. Please use \'render-process-gone event\' instead.');
|
||||
});
|
||||
|
||||
// FIXME: re-enable this test on win32.
|
||||
|
||||
@@ -2224,7 +2224,22 @@ describe('BrowserWindow module', () => {
|
||||
expect(visible).to.equal('hidden');
|
||||
});
|
||||
|
||||
it('resolves after the window is hidden', async () => {
|
||||
it('resolves when the window is occluded', async () => {
|
||||
const w1 = new BrowserWindow({ show: false });
|
||||
w1.loadFile(path.join(fixtures, 'pages', 'a.html'));
|
||||
await once(w1, 'ready-to-show');
|
||||
w1.show();
|
||||
|
||||
const w2 = new BrowserWindow({ show: false });
|
||||
w2.loadFile(path.join(fixtures, 'pages', 'a.html'));
|
||||
await once(w2, 'ready-to-show');
|
||||
w2.show();
|
||||
|
||||
const visibleImage = await w1.capturePage();
|
||||
expect(visibleImage.isEmpty()).to.equal(false);
|
||||
});
|
||||
|
||||
it('resolves when the window is not visible', async () => {
|
||||
const w = new BrowserWindow({ show: false });
|
||||
w.loadFile(path.join(fixtures, 'pages', 'a.html'));
|
||||
await once(w, 'ready-to-show');
|
||||
@@ -2233,21 +2248,10 @@ describe('BrowserWindow module', () => {
|
||||
const visibleImage = await w.capturePage();
|
||||
expect(visibleImage.isEmpty()).to.equal(false);
|
||||
|
||||
w.hide();
|
||||
w.minimize();
|
||||
|
||||
const hiddenImage = await w.capturePage();
|
||||
const isEmpty = process.platform !== 'darwin';
|
||||
expect(hiddenImage.isEmpty()).to.equal(isEmpty);
|
||||
});
|
||||
|
||||
it('resolves after the window is hidden and capturer count is non-zero', async () => {
|
||||
const w = new BrowserWindow({ show: false });
|
||||
w.webContents.setBackgroundThrottling(false);
|
||||
w.loadFile(path.join(fixtures, 'pages', 'a.html'));
|
||||
await once(w, 'ready-to-show');
|
||||
|
||||
const image = await w.capturePage();
|
||||
expect(image.isEmpty()).to.equal(false);
|
||||
expect(hiddenImage.isEmpty()).to.equal(false);
|
||||
});
|
||||
|
||||
it('preserves transparency', async () => {
|
||||
@@ -6357,7 +6361,7 @@ describe('BrowserWindow module', () => {
|
||||
foregroundWindow.loadFile(path.join(__dirname, 'fixtures', 'pages', 'css-transparent.html'));
|
||||
await once(ipcMain, 'set-transparent');
|
||||
|
||||
await setTimeout();
|
||||
await setTimeout(1000);
|
||||
const screenCapture = await captureScreen();
|
||||
const centerColor = getPixelColor(screenCapture, {
|
||||
x: display.size.width / 2,
|
||||
@@ -6380,7 +6384,7 @@ describe('BrowserWindow module', () => {
|
||||
await once(window, 'show');
|
||||
await window.webContents.loadURL('data:text/html,<head><meta name="color-scheme" content="dark"></head>');
|
||||
|
||||
await setTimeout(500);
|
||||
await setTimeout(1000);
|
||||
const screenCapture = await captureScreen();
|
||||
const centerColor = getPixelColor(screenCapture, {
|
||||
x: display.size.width / 2,
|
||||
@@ -6410,6 +6414,7 @@ describe('BrowserWindow module', () => {
|
||||
w.loadURL('about:blank');
|
||||
await once(w, 'ready-to-show');
|
||||
|
||||
await setTimeout(1000);
|
||||
const screenCapture = await captureScreen();
|
||||
const centerColor = getPixelColor(screenCapture, {
|
||||
x: display.size.width / 2,
|
||||
|
||||
@@ -3,9 +3,10 @@ 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, deprecate } from 'electron/main';
|
||||
import { BrowserWindow, ipcMain, webContents, session, app, BrowserView, WebContents } from 'electron/main';
|
||||
import { closeAllWindows } from './lib/window-helpers';
|
||||
import { ifdescribe, defer, waitUntil, listen, ifit } from './lib/spec-helpers';
|
||||
import { expectDeprecationMessages } from './lib/deprecate-helpers';
|
||||
import { once } from 'node:events';
|
||||
import { setTimeout } from 'node:timers/promises';
|
||||
|
||||
@@ -2344,8 +2345,6 @@ describe('webContents module', () => {
|
||||
});
|
||||
|
||||
describe('crashed event', () => {
|
||||
afterEach(() => deprecate.setHandler(null));
|
||||
|
||||
it('does not crash main process when destroying WebContents in it', (done) => {
|
||||
const contents = (webContents as typeof ElectronInternal.WebContents).create({ nodeIntegration: true });
|
||||
contents.once('crashed', () => {
|
||||
@@ -2359,15 +2358,13 @@ describe('webContents module', () => {
|
||||
const contents = (webContents as typeof ElectronInternal.WebContents).create({ nodeIntegration: true });
|
||||
await contents.loadURL('about:blank');
|
||||
|
||||
const messages: string[] = [];
|
||||
deprecate.setHandler(message => messages.push(message));
|
||||
expectDeprecationMessages(async () => {
|
||||
const crashEvent = once(contents, 'crashed');
|
||||
contents.forcefullyCrashRenderer();
|
||||
const [, killed] = await crashEvent;
|
||||
|
||||
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.']);
|
||||
expect(killed).to.be.a('boolean');
|
||||
}, '\'crashed event\' is deprecated and will be removed. Please use \'render-process-gone event\' instead.');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { expect } from 'chai';
|
||||
import { deprecate } from 'electron/main';
|
||||
import * as deprecate from '../lib/common/deprecate';
|
||||
|
||||
describe('deprecate', () => {
|
||||
let throwing: boolean;
|
||||
|
||||
@@ -20,7 +20,7 @@ export async function expectDeprecationMessages (func: () => any, ...expected: s
|
||||
// process.emitWarning seems to need us to wait a tick
|
||||
await new Promise(process.nextTick);
|
||||
console.warn = originalWarn;
|
||||
process.off('warning', warningListener);
|
||||
process.off('warning' as any, warningListener);
|
||||
expect(messages).to.deep.equal(expected);
|
||||
}
|
||||
}
|
||||
|
||||
29
typings/internal-electron.d.ts
vendored
29
typings/internal-electron.d.ts
vendored
@@ -155,18 +155,6 @@ declare namespace Electron {
|
||||
_replyChannel: ReplyChannel;
|
||||
}
|
||||
|
||||
namespace Common {
|
||||
const deprecate: ElectronInternal.DeprecationUtil;
|
||||
}
|
||||
|
||||
namespace Main {
|
||||
const deprecate: ElectronInternal.DeprecationUtil;
|
||||
}
|
||||
|
||||
namespace Renderer {
|
||||
const deprecate: ElectronInternal.DeprecationUtil;
|
||||
}
|
||||
|
||||
class View {}
|
||||
|
||||
// Experimental views API
|
||||
@@ -212,22 +200,6 @@ declare namespace Electron {
|
||||
}
|
||||
|
||||
declare namespace ElectronInternal {
|
||||
type DeprecationHandler = (message: string) => void;
|
||||
interface DeprecationUtil {
|
||||
warnOnce(oldName: string, newName?: string): () => void;
|
||||
warnOnceMessage(msg: string): () => void;
|
||||
setHandler(handler: DeprecationHandler | null): void;
|
||||
getHandler(): DeprecationHandler | null;
|
||||
warn(oldName: string, newName: string): void;
|
||||
log(message: string): void;
|
||||
removeFunction<T extends Function>(fn: T, removedName: string): T;
|
||||
renameFunction<T extends Function>(fn: T, newName: string): T;
|
||||
event(emitter: NodeJS.EventEmitter, oldName: string, newName: string, transformer?: (...args: any[]) => any[] | undefined): void;
|
||||
removeProperty<T extends Object, K extends (keyof T & string)>(object: T, propertyName: K, onlyForValues?: any[]): T;
|
||||
renameProperty<T extends Object, K extends (keyof T & string)>(object: T, oldName: string, newName: K): T;
|
||||
moveAPI<T extends Function>(fn: T, oldUsage: string, newUsage: string): T;
|
||||
}
|
||||
|
||||
interface DesktopCapturer {
|
||||
startHandling(captureWindow: boolean, captureScreen: boolean, thumbnailSize: Electron.Size, fetchWindowIcons: boolean): void;
|
||||
_onerror?: (error: string) => void;
|
||||
@@ -292,7 +264,6 @@ declare namespace ElectronInternal {
|
||||
interface ModuleEntry {
|
||||
name: string;
|
||||
loader: ModuleLoader;
|
||||
private?: boolean;
|
||||
}
|
||||
|
||||
interface UtilityProcessWrapper extends NodeJS.EventEmitter {
|
||||
|
||||
Reference in New Issue
Block a user