electron/docs/breaking-changes.md

990 lines
28 KiB
Markdown
Raw Normal View History

# Breaking Changes
Breaking changes will be documented here, and deprecation warnings added to JS code where possible, at least [one major version](tutorial/electron-versioning.md#semver) before the change is made.
### Types of Breaking Changes
This document uses the following convention to categorize breaking changes:
- **API Changed:** An API was changed in such a way that code that has not been updated is guaranteed to throw an exception.
- **Behavior Changed:** The behavior of Electron has changed, but not in such a way that an exception will necessarily be thrown.
- **Default Changed:** Code depending on the old default may break, not necessarily throwing an exception. The old behavior can be restored by explicitly specifying the value.
- **Deprecated:** An API was marked as deprecated. The API will continue to function, but will emit a deprecation warning, and will be removed in a future release.
- **Removed:** An API or feature was removed, and is no longer supported by Electron.
## Planned Breaking API Changes (13.0)
### Removed: `shell.moveItemToTrash()`
The deprecated synchronous `shell.moveItemToTrash()` API has been removed. Use
the asynchronous `shell.trashItem()` instead.
```js
// Removed in Electron 13
shell.moveItemToTrash(path)
// Replace with
shell.trashItem(path).then(/* ... */)
```
## Planned Breaking API Changes (12.0)
chore: bump chromium to 6b9fa6b352d824d052222e1abe541 (master) (#25558) * chore: bump chromium in DEPS to d5c9bf9e2a18fa508201a88e5803bec1d107b1ae * chore: bump chromium in DEPS to 45f1316afae33e52c92480b34bf4f7fe4a7db898 * update patches * WillCreateURLLoaderFactory now gets a ukm_source_id Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2346803 * ink_drop_visible_opacity -> GetInkDropVisibleOpacity Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2415368 * chore: bump chromium in DEPS to ddb5b6db5e35ab1a7b5adbd9f15373af6c35ea2a * 2418471: PDF Viewer update: Add missing aria-labels to various buttons. https://chromium-review.googlesource.com/c/chromium/src/+/2418471 * update printing.patch given print settings mojoification Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2409467 * update patches * content::BluetoothChooser::Event -> content::BluetoothChooserEvent Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2387901 * set_ink_drop_base_color -> SetInkDropBaseColor Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2419388 * chore: bump chromium in DEPS to ecf7c9ee830d4d85f300b461a2fa13aa40c79a4c * update patches * gfx::ConvertPointToPixel -> gfx::ConvertPointToPixels Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2418568 * remove ContentSettingsObserver::AllowStorage() Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2401847 * service_manager::kCrashDumpSignal -> kCrashDumpSignal Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2417073 * chore: bump chromium in DEPS to abdb7ebe5f8c8328b8f435283df90d0a3ecff7bd * chore: bump chromium in DEPS to 2a7e138ab1066534ceb2622e8a9d2c8ebf574215 * chore: bump chromium in DEPS to ab1884e75ced904e4276851eb4e1ad89919ca93b * chore: bump chromium in DEPS to a12413902380dcc2a73ac74d582328280a8af686 * Fixup printing patch https://chromium-review.googlesource.com/c/chromium/src/+/2428623 * Fixup OSR patch https://chromium-review.googlesource.com/c/chromium/src/+/2415128 * Make ExtensionURLLoaderFactory always owned by its |receivers_|. https://chromium-review.googlesource.com/c/chromium/src/+/2357523 * Add deprecated_default_sources_assignment_filter variable https://chromium-review.googlesource.com/c/chromium/src/+/2416496 * Fixup patch indices * Remove several references to BrowserPlugin from content https://chromium-review.googlesource.com/c/chromium/src/+/2401031 * Remove SurfaceEmbeddingTime and LocalSurfaceIdAllocation https://chromium-review.googlesource.com/c/chromium/src/+/2415128 * Add DragOperation and AllowedDragOperations Mojo types https://chromium-review.googlesource.com/c/chromium/src/+/2196167 * chore: bump chromium in DEPS to 378450342cf6aa160663d0ce3a178a11b570c25a * Fixup patch indices * Remove SurfaceEmbeddingTime and LocalSurfaceIdAllocation https://chromium-review.googlesource.com/c/chromium/src/+/2415128 * Add DragOperation and AllowedDragOperations Mojo types https://chromium-review.googlesource.com/c/chromium/src/+/2196167 * 2426564: Remove global sources assignment filter value https://chromium-review.googlesource.com/c/chromium/src/+/2426564 * Fixup blink_local_frame.patch * [XProto] Remove a subset of ui/gfx/x/x11.h https://chromium-review.googlesource.com/c/chromium/src/+/2430328 * Fixup patch indices * Remove several references to BrowserPlugin from content https://chromium-review.googlesource.com/c/chromium/src/+/2401031 * Remove lossy ConvertSizeToPixel() methods https://chromium-review.googlesource.com/c/chromium/src/+/2419534 * serial: Use USB driver name to disambiguate ports https://chromium-review.googlesource.com/c/chromium/src/+/2413176 * Remove set_sources_filter import * Fix ModMask usage * [XProto] Remove usage of all Xlib headers https://chromium-review.googlesource.com/c/chromium/src/+/2392140 * [XProto] Remove usage of Xlib Visuals https://chromium-review.googlesource.com/c/chromium/src/+/2429933 * Skip Angle manifest file https://chromium-review.googlesource.com/c/angle/angle/+/2425197 * Add whole src\third_party\angle\.git directory This directory is needed in order to properly generate gen/angle/angle_commit.h * [libvpx] Fix HighBD config on Windows ARM64 https://chromium-review.googlesource.com/c/chromium/src/+/2437745 * update patches * fix: correct calling convention for Windows on Arm https://chromium-review.googlesource.com/c/v8/v8/+/2440717 * Add third_party/angle/.git to the archive before adding the rest of the source * fixup source caching on Windows * Fixup erroneous close paren * fixup for goma issues * This should work * chore: bump chromium roll manually https://chromium-review.googlesource.com/c/chromium/src/+/2435142 This landed the day after we paused roller-bot and may resolve the visibility test flakes that we're seeing. h/t to @jkleinsc for finding this with me. * chore: remove obsoleted cherry-pick fix for libvpx https://chromium-review.googlesource.com/c/chromium/src/+/2437745 * chore: remove obsoleted cherry-pick libvpx patch https://chromium-review.googlesource.com/c/chromium/src/+/2437745 * chore: re-export patches * chore: add tracer comment to visibility-stat-spec. The line numbers between the source and the CI runs don't seem to match up, so this temp tracer is to help track the source of that difference. * chore: bump chromium in DEPS to 7c2b8cc3b8638aee8abeb013042a6c1d15b2da6b * update patches * impl SortingLSH service Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2425327 * 2446525: [Flash] Remove some Flash APIs https://chromium-review.googlesource.com/c/chromium/src/+/2446525 * 2440974: Reland "Delete service_manager/embedder/switches.h" https://chromium-review.googlesource.com/c/chromium/src/+/2440974 * 2359402: Remove ContentBrowserClient::NonNetworkURLLoaderFactoryDeprecatedMap. https://chromium-review.googlesource.com/c/chromium/src/+/2359402 * 2250506: Implement tabs.removeCSS https://chromium-review.googlesource.com/c/chromium/src/+/2250506 * 2429143: Remove implicit-conversion-to-integer ConvertRectToPixel() methods. https://chromium-review.googlesource.com/c/chromium/src/+/2429143 * 2444430: Remove DataElementType::kBlob https://chromium-review.googlesource.com/c/chromium/src/+/2444430 * 2441964: Clean up WebView public API https://chromium-review.googlesource.com/c/chromium/src/+/2441964 * 2357523: Make ExtensionURLLoaderFactory always owned by its |receivers_|. https://chromium-review.googlesource.com/c/chromium/src/+/2357523 * 2461606: Use blink::mojom::PreferredColorScheme instead of blink::PreferredColorScheme https://chromium-review.googlesource.com/c/chromium/src/+/2461606 * 2461235: a11y inspect reorg: move PropertyFilter struct to a new location https://chromium-review.googlesource.com/c/chromium/src/+/2461235 * remove flash support * fix frame_host_manager patch * fix lint * remove flash info from docs * fix build * fix osr * chore: bump chromium in DEPS to 9269f9eb1d98d29564c2b2ab97f30c6e148c4e11 * fix visibilityState tests * 2463049: Replace all uses of web_pref::AutoplayPolicy with mojom::AutoplayPolicy https://chromium-review.googlesource.com/c/chromium/src/+/2463049 * update patches * fix tests harder * 2414921: Add Group and Ungroup functions to Tabs extension API https://chromium-review.googlesource.com/c/chromium/src/+/2414921 * more test fix * Remove all keyboard related usage of Xlib Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2436787 * fix linux build * 2453807: [XProto] Remove usage of Xlib error handling https://chromium-review.googlesource.com/c/chromium/src/+/2453807 * lint * fixup! 2453807: [XProto] Remove usage of Xlib error handling * disable CalculateNativeWinOcclusion on win ci * remove UploadBlob from docs * Update appveyor.yml Co-authored-by: Andy Locascio <andy@slack-corp.com> Co-authored-by: John Kleinschmidt <jkleinsc@github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: Jeremy Rose <nornagon@nornagon.net> Co-authored-by: Electron Bot <anonymous@electronjs.org> Co-authored-by: Charles Kerr <charles@charleskerr.com> Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com> Co-authored-by: Jeremy Rose <jeremya@chromium.org>
2020-10-16 01:30:41 +00:00
### Removed: Pepper Flash support
Chromium has removed support for Flash, and so we must follow suit. See
Chromium's [Flash Roadmap](https://www.chromium.org/flash-roadmap) for more
details.
### Default Changed: `contextIsolation` defaults to `true`
In Electron 12, `contextIsolation` will be enabled by default. To restore
the previous behavior, `contextIsolation: false` must be specified in WebPreferences.
We [recommend having contextIsolation enabled](https://github.com/electron/electron/blob/master/docs/tutorial/security.md#3-enable-context-isolation-for-remote-content) for the security of your application.
For more details see: https://github.com/electron/electron/issues/23506
### Removed: `crashReporter` methods in the renderer process
The following `crashReporter` methods are no longer available in the renderer
process:
- `crashReporter.start`
- `crashReporter.getLastCrashReport`
- `crashReporter.getUploadedReports`
- `crashReporter.getUploadToServer`
- `crashReporter.setUploadToServer`
- `crashReporter.getCrashesDirectory`
They should be called only from the main process.
See [#23265](https://github.com/electron/electron/pull/23265) for more details.
### Default Changed: `crashReporter.start({ compress: true })`
The default value of the `compress` option to `crashReporter.start` has changed
from `false` to `true`. This means that crash dumps will be uploaded to the
crash ingestion server with the `Content-Encoding: gzip` header, and the body
will be compressed.
If your crash ingestion server does not support compressed payloads, you can
turn off compression by specifying `{ compress: false }` in the crash reporter
options.
2020-09-10 16:17:17 +00:00
### Deprecated: `remote` module
The `remote` module is deprecated in Electron 12, and will be removed in
Electron 14. It is replaced by the
[`@electron/remote`](https://github.com/electron/remote) module.
```js
// Deprecated in Electron 12:
const { BrowserWindow } = require('electron').remote
```
```js
// Replace with:
const { BrowserWindow } = require('@electron/remote')
// In the main process:
require('@electron/remote/main').initialize()
```
### Deprecated: `shell.moveItemToTrash()`
The synchronous `shell.moveItemToTrash()` has been replaced by the new,
asynchronous `shell.trashItem()`.
```js
// Deprecated in Electron 12
shell.moveItemToTrash(path)
// Replace with
shell.trashItem(path).then(/* ... */)
```
## Planned Breaking API Changes (11.0)
### Removed: `BrowserView.{destroy, fromId, fromWebContents, getAllViews}` and `id` property of `BrowserView`
2020-11-19 04:58:47 +00:00
The experimental APIs `BrowserView.{destroy, fromId, fromWebContents, getAllViews}`
have now been removed. Additionally, the `id` property of `BrowserView`
has also been removed.
For more detailed information, see [#23578](https://github.com/electron/electron/pull/23578).
## Planned Breaking API Changes (10.0)
### Deprecated: `companyName` argument to `crashReporter.start()`
The `companyName` argument to `crashReporter.start()`, which was previously
required, is now optional, and further, is deprecated. To get the same
behavior in a non-deprecated way, you can pass a `companyName` value in
`globalExtra`.
```js
// Deprecated in Electron 10
crashReporter.start({ companyName: 'Umbrella Corporation' })
// Replace with
crashReporter.start({ globalExtra: { _companyName: 'Umbrella Corporation' } })
```
### Deprecated: `crashReporter.getCrashesDirectory()`
The `crashReporter.getCrashesDirectory` method has been deprecated. Usage
should be replaced by `app.getPath('crashDumps')`.
```js
// Deprecated in Electron 10
crashReporter.getCrashesDirectory()
// Replace with
app.getPath('crashDumps')
```
### Deprecated: `crashReporter` methods in the renderer process
Calling the following `crashReporter` methods from the renderer process is
deprecated:
- `crashReporter.start`
- `crashReporter.getLastCrashReport`
- `crashReporter.getUploadedReports`
- `crashReporter.getUploadToServer`
- `crashReporter.setUploadToServer`
- `crashReporter.getCrashesDirectory`
The only non-deprecated methods remaining in the `crashReporter` module in the
renderer are `addExtraParameter`, `removeExtraParameter` and `getParameters`.
All above methods remain non-deprecated when called from the main process.
See [#23265](https://github.com/electron/electron/pull/23265) for more details.
### Deprecated: `crashReporter.start({ compress: false })`
Setting `{ compress: false }` in `crashReporter.start` is deprecated. Nearly
all crash ingestion servers support gzip compression. This option will be
removed in a future version of Electron.
### Removed: Browser Window Affinity
The `affinity` option when constructing a new `BrowserWindow` will be removed
as part of our plan to more closely align with Chromium's process model for security,
performance and maintainability.
For more detailed information see [#18397](https://github.com/electron/electron/issues/18397).
### Default Changed: `enableRemoteModule` defaults to `false`
In Electron 9, using the remote module without explicitly enabling it via the
`enableRemoteModule` WebPreferences option began emitting a warning. In
Electron 10, the remote module is now disabled by default. To use the remote
module, `enableRemoteModule: true` must be specified in WebPreferences:
```js
const w = new BrowserWindow({
webPreferences: {
enableRemoteModule: true
}
})
```
We [recommend moving away from the remote
module](https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31).
### `protocol.unregisterProtocol`
2020-11-19 04:58:47 +00:00
### `protocol.uninterceptProtocol`
The APIs are now synchronous and the optional callback is no longer needed.
```javascript
// Deprecated
protocol.unregisterProtocol(scheme, () => { /* ... */ })
// Replace with
protocol.unregisterProtocol(scheme)
```
### `protocol.registerFileProtocol`
2020-11-19 04:58:47 +00:00
### `protocol.registerBufferProtocol`
2020-11-19 04:58:47 +00:00
### `protocol.registerStringProtocol`
2020-11-19 04:58:47 +00:00
### `protocol.registerHttpProtocol`
2020-11-19 04:58:47 +00:00
### `protocol.registerStreamProtocol`
2020-11-19 04:58:47 +00:00
### `protocol.interceptFileProtocol`
2020-11-19 04:58:47 +00:00
### `protocol.interceptStringProtocol`
2020-11-19 04:58:47 +00:00
### `protocol.interceptBufferProtocol`
2020-11-19 04:58:47 +00:00
### `protocol.interceptHttpProtocol`
2020-11-19 04:58:47 +00:00
### `protocol.interceptStreamProtocol`
The APIs are now synchronous and the optional callback is no longer needed.
```javascript
// Deprecated
protocol.registerFileProtocol(scheme, handler, () => { /* ... */ })
// Replace with
protocol.registerFileProtocol(scheme, handler)
```
The registered or intercepted protocol does not have effect on current page
until navigation happens.
### `protocol.isProtocolHandled`
This API is deprecated and users should use `protocol.isProtocolRegistered`
and `protocol.isProtocolIntercepted` instead.
```javascript
// Deprecated
protocol.isProtocolHandled(scheme).then(() => { /* ... */ })
// Replace with
const isRegistered = protocol.isProtocolRegistered(scheme)
const isIntercepted = protocol.isProtocolIntercepted(scheme)
```
## Planned Breaking API Changes (9.0)
### Default Changed: Loading non-context-aware native modules in the renderer process is disabled by default
As of Electron 9 we do not allow loading of non-context-aware native modules in
the renderer process. This is to improve security, performance and maintainability
of Electron as a project.
If this impacts you, you can temporarily set `app.allowRendererProcessReuse` to `false`
to revert to the old behavior. This flag will only be an option until Electron 11 so
you should plan to update your native modules to be context aware.
For more detailed information see [#18397](https://github.com/electron/electron/issues/18397).
### Removed: `<webview>.getWebContents()`
This API, which was deprecated in Electron 8.0, is now removed.
```js
// Removed in Electron 9.0
webview.getWebContents()
// Replace with
const { remote } = require('electron')
remote.webContents.fromId(webview.getWebContentsId())
```
### Removed: `webFrame.setLayoutZoomLevelLimits()`
Chromium has removed support for changing the layout zoom level limits, and it
is beyond Electron's capacity to maintain it. The function was deprecated in
Electron 8.x, and has been removed in Electron 9.x. The layout zoom level limits
are now fixed at a minimum of 0.25 and a maximum of 5.0, as defined
[here](https://chromium.googlesource.com/chromium/src/+/938b37a6d2886bf8335fc7db792f1eb46c65b2ae/third_party/blink/common/page/page_zoom.cc#11).
### Behavior Changed: Sending non-JS objects over IPC now throws an exception
In Electron 8.0, IPC was changed to use the Structured Clone Algorithm,
bringing significant performance improvements. To help ease the transition, the
old IPC serialization algorithm was kept and used for some objects that aren't
serializable with Structured Clone. In particular, DOM objects (e.g. `Element`,
`Location` and `DOMMatrix`), Node.js objects backed by C++ classes (e.g.
`process.env`, some members of `Stream`), and Electron objects backed by C++
classes (e.g. `WebContents`, `BrowserWindow` and `WebFrame`) are not
serializable with Structured Clone. Whenever the old algorithm was invoked, a
deprecation warning was printed.
In Electron 9.0, the old serialization algorithm has been removed, and sending
such non-serializable objects will now throw an "object could not be cloned"
error.
### API Changed: `shell.openItem` is now `shell.openPath`
The `shell.openItem` API has been replaced with an asynchronous `shell.openPath` API.
You can see the original API proposal and reasoning [here](https://github.com/electron/governance/blob/master/wg-api/spec-documents/shell-openitem.md).
refactor: use v8 serialization for ipc (#20214) * refactor: use v8 serialization for ipc * cloning process.env doesn't work * serialize host objects by enumerating key/values * new serialization can handle NaN, Infinity, and undefined correctly * can't allocate v8 objects during GC * backport microtasks fix * fix compile * fix node_stream_loader reentrancy * update subframe spec to expect undefined instead of null * write undefined instead of crashing when serializing host objects * fix webview spec * fix download spec * buffers are transformed into uint8arrays * can't serialize promises * fix chrome.i18n.getMessage * fix devtools tests * fix zoom test * fix debug build * fix lint * update ipcRenderer tests * fix printToPDF test * update patch * remove accidentally re-added remote-side spec * wip * don't attempt to serialize host objects * jump through different hoops to set options.webContents sometimes * whoops * fix lint * clean up error-handling logic * fix memory leak * fix lint * convert host objects using old base::Value serialization * fix lint more * fall back to base::Value-based serialization * remove commented-out code * add docs to breaking-changes.md * Update breaking-changes.md * update ipcRenderer and WebContents docs * lint * use named values for format tag * save a memcpy for ~30% speedup * get rid of calls to ShallowClone * extra debugging for paranoia * d'oh, use the correct named tags * apparently msstl doesn't like this DCHECK * funny story about that DCHECK * disable remote-related functions when enable_remote_module = false * nits * use EnableIf to disable remote methods in mojom * fix include * review comments
2019-10-09 17:59:08 +00:00
## Planned Breaking API Changes (8.0)
### Behavior Changed: Values sent over IPC are now serialized with Structured Clone Algorithm
refactor: use v8 serialization for ipc (#20214) * refactor: use v8 serialization for ipc * cloning process.env doesn't work * serialize host objects by enumerating key/values * new serialization can handle NaN, Infinity, and undefined correctly * can't allocate v8 objects during GC * backport microtasks fix * fix compile * fix node_stream_loader reentrancy * update subframe spec to expect undefined instead of null * write undefined instead of crashing when serializing host objects * fix webview spec * fix download spec * buffers are transformed into uint8arrays * can't serialize promises * fix chrome.i18n.getMessage * fix devtools tests * fix zoom test * fix debug build * fix lint * update ipcRenderer tests * fix printToPDF test * update patch * remove accidentally re-added remote-side spec * wip * don't attempt to serialize host objects * jump through different hoops to set options.webContents sometimes * whoops * fix lint * clean up error-handling logic * fix memory leak * fix lint * convert host objects using old base::Value serialization * fix lint more * fall back to base::Value-based serialization * remove commented-out code * add docs to breaking-changes.md * Update breaking-changes.md * update ipcRenderer and WebContents docs * lint * use named values for format tag * save a memcpy for ~30% speedup * get rid of calls to ShallowClone * extra debugging for paranoia * d'oh, use the correct named tags * apparently msstl doesn't like this DCHECK * funny story about that DCHECK * disable remote-related functions when enable_remote_module = false * nits * use EnableIf to disable remote methods in mojom * fix include * review comments
2019-10-09 17:59:08 +00:00
The algorithm used to serialize objects sent over IPC (through
`ipcRenderer.send`, `ipcRenderer.sendSync`, `WebContents.send` and related
methods) has been switched from a custom algorithm to V8's built-in [Structured
Clone Algorithm][SCA], the same algorithm used to serialize messages for
`postMessage`. This brings about a 2x performance improvement for large
messages, but also brings some breaking changes in behavior.
- Sending Functions, Promises, WeakMaps, WeakSets, or objects containing any
such values, over IPC will now throw an exception, instead of silently
converting the functions to `undefined`.
refactor: use v8 serialization for ipc (#20214) * refactor: use v8 serialization for ipc * cloning process.env doesn't work * serialize host objects by enumerating key/values * new serialization can handle NaN, Infinity, and undefined correctly * can't allocate v8 objects during GC * backport microtasks fix * fix compile * fix node_stream_loader reentrancy * update subframe spec to expect undefined instead of null * write undefined instead of crashing when serializing host objects * fix webview spec * fix download spec * buffers are transformed into uint8arrays * can't serialize promises * fix chrome.i18n.getMessage * fix devtools tests * fix zoom test * fix debug build * fix lint * update ipcRenderer tests * fix printToPDF test * update patch * remove accidentally re-added remote-side spec * wip * don't attempt to serialize host objects * jump through different hoops to set options.webContents sometimes * whoops * fix lint * clean up error-handling logic * fix memory leak * fix lint * convert host objects using old base::Value serialization * fix lint more * fall back to base::Value-based serialization * remove commented-out code * add docs to breaking-changes.md * Update breaking-changes.md * update ipcRenderer and WebContents docs * lint * use named values for format tag * save a memcpy for ~30% speedup * get rid of calls to ShallowClone * extra debugging for paranoia * d'oh, use the correct named tags * apparently msstl doesn't like this DCHECK * funny story about that DCHECK * disable remote-related functions when enable_remote_module = false * nits * use EnableIf to disable remote methods in mojom * fix include * review comments
2019-10-09 17:59:08 +00:00
```js
// Previously:
ipcRenderer.send('channel', { value: 3, someFunction: () => {} })
// => results in { value: 3 } arriving in the main process
// From Electron 8:
ipcRenderer.send('channel', { value: 3, someFunction: () => {} })
// => throws Error("() => {} could not be cloned.")
```
refactor: use v8 serialization for ipc (#20214) * refactor: use v8 serialization for ipc * cloning process.env doesn't work * serialize host objects by enumerating key/values * new serialization can handle NaN, Infinity, and undefined correctly * can't allocate v8 objects during GC * backport microtasks fix * fix compile * fix node_stream_loader reentrancy * update subframe spec to expect undefined instead of null * write undefined instead of crashing when serializing host objects * fix webview spec * fix download spec * buffers are transformed into uint8arrays * can't serialize promises * fix chrome.i18n.getMessage * fix devtools tests * fix zoom test * fix debug build * fix lint * update ipcRenderer tests * fix printToPDF test * update patch * remove accidentally re-added remote-side spec * wip * don't attempt to serialize host objects * jump through different hoops to set options.webContents sometimes * whoops * fix lint * clean up error-handling logic * fix memory leak * fix lint * convert host objects using old base::Value serialization * fix lint more * fall back to base::Value-based serialization * remove commented-out code * add docs to breaking-changes.md * Update breaking-changes.md * update ipcRenderer and WebContents docs * lint * use named values for format tag * save a memcpy for ~30% speedup * get rid of calls to ShallowClone * extra debugging for paranoia * d'oh, use the correct named tags * apparently msstl doesn't like this DCHECK * funny story about that DCHECK * disable remote-related functions when enable_remote_module = false * nits * use EnableIf to disable remote methods in mojom * fix include * review comments
2019-10-09 17:59:08 +00:00
- `NaN`, `Infinity` and `-Infinity` will now be correctly serialized, instead
of being converted to `null`.
- Objects containing cyclic references will now be correctly serialized,
instead of being converted to `null`.
- `Set`, `Map`, `Error` and `RegExp` values will be correctly serialized,
instead of being converted to `{}`.
- `BigInt` values will be correctly serialized, instead of being converted to
`null`.
- Sparse arrays will be serialized as such, instead of being converted to dense
arrays with `null`s.
- `Date` objects will be transferred as `Date` objects, instead of being
converted to their ISO string representation.
- Typed Arrays (such as `Uint8Array`, `Uint16Array`, `Uint32Array` and so on)
will be transferred as such, instead of being converted to Node.js `Buffer`.
- Node.js `Buffer` objects will be transferred as `Uint8Array`s. You can
convert a `Uint8Array` back to a Node.js `Buffer` by wrapping the underlying
`ArrayBuffer`:
refactor: use v8 serialization for ipc (#20214) * refactor: use v8 serialization for ipc * cloning process.env doesn't work * serialize host objects by enumerating key/values * new serialization can handle NaN, Infinity, and undefined correctly * can't allocate v8 objects during GC * backport microtasks fix * fix compile * fix node_stream_loader reentrancy * update subframe spec to expect undefined instead of null * write undefined instead of crashing when serializing host objects * fix webview spec * fix download spec * buffers are transformed into uint8arrays * can't serialize promises * fix chrome.i18n.getMessage * fix devtools tests * fix zoom test * fix debug build * fix lint * update ipcRenderer tests * fix printToPDF test * update patch * remove accidentally re-added remote-side spec * wip * don't attempt to serialize host objects * jump through different hoops to set options.webContents sometimes * whoops * fix lint * clean up error-handling logic * fix memory leak * fix lint * convert host objects using old base::Value serialization * fix lint more * fall back to base::Value-based serialization * remove commented-out code * add docs to breaking-changes.md * Update breaking-changes.md * update ipcRenderer and WebContents docs * lint * use named values for format tag * save a memcpy for ~30% speedup * get rid of calls to ShallowClone * extra debugging for paranoia * d'oh, use the correct named tags * apparently msstl doesn't like this DCHECK * funny story about that DCHECK * disable remote-related functions when enable_remote_module = false * nits * use EnableIf to disable remote methods in mojom * fix include * review comments
2019-10-09 17:59:08 +00:00
```js
Buffer.from(value.buffer, value.byteOffset, value.byteLength)
```
Sending any objects that aren't native JS types, such as DOM objects (e.g.
`Element`, `Location`, `DOMMatrix`), Node.js objects (e.g. `process.env`,
`Stream`), or Electron objects (e.g. `WebContents`, `BrowserWindow`,
`WebFrame`) is deprecated. In Electron 8, these objects will be serialized as
before with a DeprecationWarning message, but starting in Electron 9, sending
these kinds of objects will throw a 'could not be cloned' error.
[SCA]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
### Deprecated: `<webview>.getWebContents()`
This API is implemented using the `remote` module, which has both performance
and security implications. Therefore its usage should be explicit.
```js
// Deprecated
webview.getWebContents()
// Replace with
const { remote } = require('electron')
remote.webContents.fromId(webview.getWebContentsId())
```
However, it is recommended to avoid using the `remote` module altogether.
```js
// main
const { ipcMain, webContents } = require('electron')
const getGuestForWebContents = (webContentsId, contents) => {
const guest = webContents.fromId(webContentsId)
if (!guest) {
throw new Error(`Invalid webContentsId: ${webContentsId}`)
}
if (guest.hostWebContents !== contents) {
2020-07-09 17:18:49 +00:00
throw new Error('Access denied to webContents')
}
return guest
}
ipcMain.handle('openDevTools', (event, webContentsId) => {
const guest = getGuestForWebContents(webContentsId, event.sender)
guest.openDevTools()
})
// renderer
const { ipcRenderer } = require('electron')
ipcRenderer.invoke('openDevTools', webview.getWebContentsId())
```
### Deprecated: `webFrame.setLayoutZoomLevelLimits()`
Chromium has removed support for changing the layout zoom level limits, and it
is beyond Electron's capacity to maintain it. The function will emit a warning
in Electron 8.x, and cease to exist in Electron 9.x. The layout zoom level
limits are now fixed at a minimum of 0.25 and a maximum of 5.0, as defined
[here](https://chromium.googlesource.com/chromium/src/+/938b37a6d2886bf8335fc7db792f1eb46c65b2ae/third_party/blink/common/page/page_zoom.cc#11).
## Planned Breaking API Changes (7.0)
### Deprecated: Atom.io Node Headers URL
This is the URL specified as `disturl` in a `.npmrc` file or as the `--dist-url`
command line flag when building native Node modules. Both will be supported for
the foreseeable future but it is recommended that you switch.
Deprecated: https://atom.io/download/electron
Replace with: https://electronjs.org/headers
### API Changed: `session.clearAuthCache()` no longer accepts options
The `session.clearAuthCache` API no longer accepts options for what to clear, and instead unconditionally clears the whole cache.
```js
// Deprecated
session.clearAuthCache({ type: 'password' })
// Replace with
session.clearAuthCache()
```
### API Changed: `powerMonitor.querySystemIdleState` is now `powerMonitor.getSystemIdleState`
2019-05-09 18:48:10 +00:00
```js
// Removed in Electron 7.0
powerMonitor.querySystemIdleState(threshold, callback)
// Replace with synchronous API
const idleState = powerMonitor.getSystemIdleState(threshold)
2019-05-09 18:48:10 +00:00
```
### API Changed: `powerMonitor.querySystemIdleTime` is now `powerMonitor.getSystemIdleTime`
2019-05-09 18:48:10 +00:00
```js
// Removed in Electron 7.0
powerMonitor.querySystemIdleTime(callback)
// Replace with synchronous API
const idleTime = powerMonitor.getSystemIdleTime()
2019-05-09 18:48:10 +00:00
```
### API Changed: `webFrame.setIsolatedWorldInfo` replaces separate methods
2019-05-09 18:48:10 +00:00
```js
// Removed in Electron 7.0
2019-05-09 18:48:10 +00:00
webFrame.setIsolatedWorldContentSecurityPolicy(worldId, csp)
webFrame.setIsolatedWorldHumanReadableName(worldId, name)
webFrame.setIsolatedWorldSecurityOrigin(worldId, securityOrigin)
// Replace with
webFrame.setIsolatedWorldInfo(
worldId,
{
securityOrigin: 'some_origin',
name: 'human_readable_name',
csp: 'content_security_policy'
})
```
### Removed: `marked` property on `getBlinkMemoryInfo`
chore: bump chromium to f1d9522c04ca8fa0a906f88ababe9 (master) (#18648) * chore: bump chromium in DEPS to 675d7dc9f3334b15c3ec28c27db3dc19b26bd12e * chore: update patches * chore: bump chromium in DEPS to dce3562696f165a324273fcb6893f0e1fef42ab1 * chore: const interfaces are being removed from //content Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1631749 Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=908139 * chore: update patches * chore: blink::MediaStreamType is now consistent and deduplicated * chore: update patches and printing code for ref -> uniq * chore: bridge_impl() --> GetInProcessNSWindowBridge Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1642988 * fixme: TotalMarkedObjectSize has been removed * chore: fix linting * chore: bump chromium in DEPS to 9503e1a2fcbf17db08094d8caae3e1407e918af3 * chore: fix slightly broken printing patch * chore: update patches for SiteInstanceImpl changes Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1612025 * chore: update patches for SiteInstanceImpl changes * chore: bump chromium in DEPS to 6801e6c1ddd1b7b73e594e97157ddd539ca335d7 * chore: update patches * chore: bump chromium in DEPS to 27e198912d7c1767052ec785c22e2e88b2cb4d8b * chore: remove system_request_context Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1647172 * chore: creation of FtpProtocolHandler needs an auth cache Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1639683 * fixme: disable marked spec * chore: bump chromium in DEPS to 3dcd7fe453ad13a22b114b95f05590eba74c5471 * chore: bump chromium in DEPS to bdc24128b75008743d819e298557a53205706e7c * chore: bump chromium in DEPS to 7da330b58fbe0ba94b9b94abbb8085bead220228 * update patches * remove TotalMarkedObjectSize https://chromium-review.googlesource.com/c/chromium/src/+/1631708 * add libvulkan.so to dist zip manifest on linux * chore: bump chromium in DEPS to 1e85d0f45b52649efd0010cc9dab6d2804f24443 * update patches * add angle features to gpuinfo https://chromium-review.googlesource.com/c/chromium/src/+/1638658 * mark 'marked' property as deprecated * disable webview resize test * FIXME: disable vulkan on 32-bit arm * chore: bump chromium in DEPS to cd0297c6a83fdd2b1f6bc312e7d5acca736a3c56 * Revert "FIXME: disable vulkan on 32-bit arm" This reverts commit 5c1e0ef302a6db1e72231d4e823f91bb08e281af. * backport from upstream: fix swiftshader build on arm https://swiftshader-review.googlesource.com/c/SwiftShader/+/32768/ * update patches * viz: update OutputDeviceWin to new shared memory api https://chromium-review.googlesource.com/c/chromium/src/+/1649574 * base::Contains{Key,Value} => base::Contains https://chromium-review.googlesource.com/c/chromium/src/+/1649478 * fixup! viz: update OutputDeviceWin to new shared memory api * stub out StatusIconLinuxDbus-related delegate methods https://chromium-review.googlesource.com/c/chromium/src/+/1638180 * chore: bump chromium in DEPS to 964ea3fd4bdc006d62533f5755043076220181f1 * Remove the BrowserContext methods to create URLRequestContexts for main/media partitions when a partition_domain is specified https://chromium-review.googlesource.com/c/chromium/src/+/1655087 * fixup! stub out StatusIconLinuxDbus-related delegate methods * add remote_cocoa to chromium_src deps https://chromium-review.googlesource.com/c/chromium/src/+/1657068 * fixup! stub out StatusIconLinuxDbus-related delegate methods * attempt at fix linux-debug build * add swiftshader/libvulkan.so to arm manifest * chore: bump chromium in DEPS to 28688f76afef27c36631aa274691e333ddecdc22 * update patches * chore: bump chromium in DEPS to fe7450e1578a9584189f87d59d0d1a8548bf6b90 * chore: bump chromium in DEPS to f304dfd682dc86a755a6c49a16ee6876e0db45fb * chore: bump chromium in DEPS to f0fd4d6c365aad9edd83bdfff9954c47d271b75c * Update patches * Remove no longer needed WOA patch * Put back IOThread in BrowserProcess We need this until we enable the network service. * move atom.ico to inputs * Update to latest LKGR to fix no template named 'bitset' in namespace 'std' * fixup! Put back IOThread in BrowserProcess * chore: bump chromium in DEPS to dcf9662dc9a896a175d791001350324167b1cad3 * Update patches content_allow_embedder_to_prevent_locking_scheme_registry.patch is no longer necessary as it was upstreamed via https://chromium-review.googlesource.com/c/chromium/src/+/1637040 * Fix renamed enum * Use newer docker container Contains updated dependencies * Try to track down arm test failures * Fix arm tests * chore: bump chromium in DEPS to 8cbceef57b37ee14b9c4c3405a3f7663922c5b5d * Update patches * Add needed dependencies for testing 32-bit linux * Remove arm debugging. * Remove additional debugging * Fix compiler errors * Handle new macOS helper * Fix compile error on Linux * chore: bump chromium in DEPS to 66a93991ddaff6a9f1b13d110959947cb03a1860 * Add new helper files to manifests * fix BUILD.gn for macOS * Fix compile errors * Add patch to put back colors needed for autofill/datalist * chore: bump chromium in DEPS to e89617079f11e33f33cdb3924f719a579c73704b * Updated patches * Remove no longer needed patch * Remove no longer needed patch * Fix compile error with patch * Really fix the patch * chore: bump chromium in DEPS to c70f12476a45840408f1d5ff5968e7f7ceaad9d4 * chore: bump chromium in DEPS to 06d2dd7a8933b41545a7c26349c802f570563fd5 * chore: bump chromium in DEPS to b0b9ff8f727deb519ccbec7cf1c8d9ed543d88ab * Update patches * Fix compiler errors * Fix removed ChromeNetLog * Revert "Fix removed ChromeNetLog" This reverts commit 426dfd90b5ab0a9c1df415d71c88e8aed2bd5bbe. * Remove ChromeNetLog. https://chromium-review.googlesource.com/c/chromium/src/+/1663846 * chore: bump chromium in DEPS to fefcc4926d58dccd59ac95be65eab3a4ebfe2f29 * Update patches * Update v8 patches * Fix lint error * Fix compile errors * chore: bump chromium in DEPS to 4de815ef92ef2eef515506fe09bdc466526a8fd9 * Use custom protocol to test baseURLForDataURL * Use newer SDK (10.0.18362) for Windows * Update patches * Update arm manifest since swiftshader reenabled. * Don't delete dir that isn't ever there. * Fix compile errors. * Need src dir created * Update for removed InspectorFrontendAPI.addExtensions * Revert "Use newer SDK (10.0.18362) for Windows" This reverts commit 68763a0c88cdc44b971462e49662aecc167d3d99. * Revert "Need src dir created" This reverts commit 7daedc29d0844316d4097648dde7f40f1a3848fb. * Revert "Don't delete dir that isn't ever there." This reverts commit bf424bc30ffcb23b1d9a634d4df410342536640e. * chore: bump chromium in DEPS to 97dab6b0124ea53244caf123921b5d14893bcca7 * chore: bump chromium in DEPS to c87d16d49a85dc7122781f6c979d354c20f7f78b * chore: bump chromium in DEPS to 004bcee2ea336687cedfda8f8a151806ac757d15 * chore: bump chromium in DEPS to 24428b26a9d15a013b2a253e1084ec3cb54b660b * chore: bump chromium in DEPS to fd25914e875237df88035a6abf89a70bf1360b57 * Update patches * Update node to fix build error * Fix compile errors * chore: bump chromium in DEPS to 3062b7cf090f1d9522c04ca8fa0a906f88ababe9 * chore: update node ref for pushed tags * chore: update patches for new chromium * chore: fix printing patches * Use new (10.0.18362) Windows SDK * roll node to fix v8 build issues in debug build * Add support for plugin helper * fix: add patch to fix gpu info enumeration Can be removed once CL lands upstream. Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1685993 * spec: navigator.requestMIDIAccess now requires a secure origin This test requires a secure origin so we fake one. Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1657952 * FIXME: temporarily disable SharedWorker tests * use released version of node-abstractsocket * fix abstract-socket
2019-07-03 01:22:09 +00:00
This property was removed in Chromium 77, and as such is no longer available.
### Behavior Changed: `webkitdirectory` attribute for `<input type="file"/>` now lists directory contents
The `webkitdirectory` property on HTML file inputs allows them to select folders.
Previous versions of Electron had an incorrect implementation where the `event.target.files`
of the input returned a `FileList` that returned one `File` corresponding to the selected folder.
As of Electron 7, that `FileList` is now list of all files contained within
the folder, similarly to Chrome, Firefox, and Edge
([link to MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory)).
As an illustration, take a folder with this structure:
```console
folder
├── file1
├── file2
└── file3
```
In Electron <=6, this would return a `FileList` with a `File` object for:
```console
path/to/folder
```
In Electron 7, this now returns a `FileList` with a `File` object for:
```console
/path/to/folder/file3
/path/to/folder/file2
/path/to/folder/file1
```
Note that `webkitdirectory` no longer exposes the path to the selected folder.
If you require the path to the selected folder rather than the folder contents,
see the `dialog.showOpenDialog` API ([link](https://github.com/electron/electron/blob/master/docs/api/dialog.md#dialogshowopendialogbrowserwindow-options)).
## Planned Breaking API Changes (6.0)
### API Changed: `win.setMenu(null)` is now `win.removeMenu()`
```js
// Deprecated
win.setMenu(null)
// Replace with
win.removeMenu()
```
### API Changed: `contentTracing.getTraceBufferUsage()` is now a promise
```js
// Deprecated
contentTracing.getTraceBufferUsage((percentage, value) => {
// do something
})
// Replace with
contentTracing.getTraceBufferUsage().then(infoObject => {
// infoObject has percentage and value fields
})
```
### API Changed: `electron.screen` in the renderer process should be accessed via `remote`
```js
// Deprecated
require('electron').screen
// Replace with
require('electron').remote.screen
```
### API Changed: `require()`ing node builtins in sandboxed renderers no longer implicitly loads the `remote` version
```js
// Deprecated
require('child_process')
// Replace with
require('electron').remote.require('child_process')
// Deprecated
require('fs')
// Replace with
require('electron').remote.require('fs')
// Deprecated
require('os')
// Replace with
require('electron').remote.require('os')
// Deprecated
require('path')
// Replace with
require('electron').remote.require('path')
```
### Deprecated: `powerMonitor.querySystemIdleState` replaced with `powerMonitor.getSystemIdleState`
```js
// Deprecated
powerMonitor.querySystemIdleState(threshold, callback)
// Replace with synchronous API
const idleState = powerMonitor.getSystemIdleState(threshold)
```
### Deprecated: `powerMonitor.querySystemIdleTime` replaced with `powerMonitor.getSystemIdleTime`
```js
// Deprecated
powerMonitor.querySystemIdleTime(callback)
// Replace with synchronous API
const idleTime = powerMonitor.getSystemIdleTime()
```
### Deprecated: `app.enableMixedSandbox()` is no longer needed
```js
// Deprecated
app.enableMixedSandbox()
```
Mixed-sandbox mode is now enabled by default.
### Deprecated: `Tray.setHighlightMode`
Under macOS Catalina our former Tray implementation breaks.
Apple's native substitute doesn't support changing the highlighting behavior.
```js
// Deprecated
tray.setHighlightMode(mode)
// API will be removed in v7.0 without replacement.
```
## Planned Breaking API Changes (5.0)
### Default Changed: `nodeIntegration` and `webviewTag` default to false, `contextIsolation` defaults to true
The following `webPreferences` option default values are deprecated in favor of the new defaults listed below.
| Property | Deprecated Default | New Default |
|----------|--------------------|-------------|
| `contextIsolation` | `false` | `true` |
| `nodeIntegration` | `true` | `false` |
| `webviewTag` | `nodeIntegration` if set else `true` | `false` |
E.g. Re-enabling the webviewTag
```js
const w = new BrowserWindow({
webPreferences: {
webviewTag: true
}
})
```
### Behavior Changed: `nodeIntegration` in child windows opened via `nativeWindowOpen`
Child windows opened with the `nativeWindowOpen` option will always have Node.js integration disabled, unless `nodeIntegrationInSubFrames` is `true`.
### API Changed: Registering privileged schemes must now be done before app ready
Renderer process APIs `webFrame.registerURLSchemeAsPrivileged` and `webFrame.registerURLSchemeAsBypassingCSP` as well as browser process API `protocol.registerStandardSchemes` have been removed.
A new API, `protocol.registerSchemesAsPrivileged` has been added and should be used for registering custom schemes with the required privileges. Custom schemes are required to be registered before app ready.
### Deprecated: `webFrame.setIsolatedWorld*` replaced with `webFrame.setIsolatedWorldInfo`
```js
// Deprecated
webFrame.setIsolatedWorldContentSecurityPolicy(worldId, csp)
webFrame.setIsolatedWorldHumanReadableName(worldId, name)
webFrame.setIsolatedWorldSecurityOrigin(worldId, securityOrigin)
// Replace with
webFrame.setIsolatedWorldInfo(
worldId,
{
securityOrigin: 'some_origin',
name: 'human_readable_name',
csp: 'content_security_policy'
})
```
### API Changed: `webFrame.setSpellCheckProvider` now takes an asynchronous callback
The `spellCheck` callback is now asynchronous, and `autoCorrectWord` parameter has been removed.
```js
// Deprecated
webFrame.setSpellCheckProvider('en-US', true, {
spellCheck: (text) => {
return !spellchecker.isMisspelled(text)
}
})
// Replace with
webFrame.setSpellCheckProvider('en-US', {
spellCheck: (words, callback) => {
callback(words.filter(text => spellchecker.isMisspelled(text)))
}
})
```
## Planned Breaking API Changes (4.0)
The following list includes the breaking API changes made in Electron 4.0.
### `app.makeSingleInstance`
```js
// Deprecated
app.makeSingleInstance((argv, cwd) => {
/* ... */
})
// Replace with
app.requestSingleInstanceLock()
app.on('second-instance', (event, argv, cwd) => {
/* ... */
})
```
### `app.releaseSingleInstance`
```js
// Deprecated
app.releaseSingleInstance()
// Replace with
app.releaseSingleInstanceLock()
```
### `app.getGPUInfo`
```js
app.getGPUInfo('complete')
// Now behaves the same with `basic` on macOS
app.getGPUInfo('basic')
```
### `win_delay_load_hook`
When building native modules for windows, the `win_delay_load_hook` variable in
the module's `binding.gyp` must be true (which is the default). If this hook is
not present, then the native module will fail to load on Windows, with an error
message like `Cannot find module`. See the [native module
guide](/docs/tutorial/using-native-node-modules.md) for more.
## Breaking API Changes (3.0)
2016-09-07 18:41:54 +00:00
The following list includes the breaking API changes in Electron 3.0.
2016-09-07 18:41:54 +00:00
### `app`
2017-05-18 03:01:06 +00:00
```js
// Deprecated
app.getAppMemoryInfo()
// Replace with
app.getAppMetrics()
// Deprecated
const metrics = app.getAppMetrics()
2018-09-13 16:10:51 +00:00
const { memory } = metrics[0] // Deprecated property
2017-05-18 03:01:06 +00:00
```
### `BrowserWindow`
2016-09-08 16:09:49 +00:00
```js
// Deprecated
2020-07-09 17:18:49 +00:00
const optionsA = { webPreferences: { blinkFeatures: '' } }
const windowA = new BrowserWindow(optionsA)
2016-09-08 16:09:49 +00:00
// Replace with
2020-07-09 17:18:49 +00:00
const optionsB = { webPreferences: { enableBlinkFeatures: '' } }
const windowB = new BrowserWindow(optionsB)
// Deprecated
window.on('app-command', (e, cmd) => {
if (cmd === 'media-play_pause') {
// do something
}
})
// Replace with
window.on('app-command', (e, cmd) => {
if (cmd === 'media-play-pause') {
// do something
}
})
2016-09-08 16:09:49 +00:00
```
### `clipboard`
2016-09-08 16:09:49 +00:00
2016-09-07 18:41:54 +00:00
```js
// Deprecated
clipboard.readRtf()
// Replace with
clipboard.readRTF()
// Deprecated
clipboard.writeRtf()
// Replace with
clipboard.writeRTF()
// Deprecated
clipboard.readHtml()
// Replace with
clipboard.readHTML()
// Deprecated
clipboard.writeHtml()
// Replace with
clipboard.writeHTML()
2016-09-08 16:09:49 +00:00
```
### `crashReporter`
2016-11-28 23:06:03 +00:00
```js
// Deprecated
crashReporter.start({
companyName: 'Crashly',
submitURL: 'https://crash.server.com',
autoSubmit: true
})
// Replace with
crashReporter.start({
companyName: 'Crashly',
submitURL: 'https://crash.server.com',
uploadToServer: true
})
```
### `nativeImage`
2016-09-07 18:41:54 +00:00
2016-09-08 16:09:49 +00:00
```js
// Deprecated
nativeImage.createFromBuffer(buffer, 1.0)
// Replace with
nativeImage.createFromBuffer(buffer, {
scaleFactor: 1.0
})
2016-09-08 16:09:49 +00:00
```
2016-09-07 18:41:54 +00:00
### `process`
```js
// Deprecated
const info = process.getProcessMemoryInfo()
```
### `screen`
2016-09-16 22:57:07 +00:00
```js
// Deprecated
screen.getMenuBarHeight()
2016-09-16 22:57:07 +00:00
// Replace with
screen.getPrimaryDisplay().workArea
2016-09-16 22:57:07 +00:00
```
### `session`
2017-02-07 23:44:56 +00:00
```js
// Deprecated
ses.setCertificateVerifyProc((hostname, certificate, callback) => {
2017-02-07 23:44:56 +00:00
callback(true)
})
// Replace with
ses.setCertificateVerifyProc((request, callback) => {
2017-02-07 23:44:56 +00:00
callback(0)
})
```
### `Tray`
2016-09-07 18:41:54 +00:00
2016-09-08 16:09:49 +00:00
```js
2016-09-07 18:41:54 +00:00
// Deprecated
tray.setHighlightMode(true)
// Replace with
tray.setHighlightMode('on')
// Deprecated
tray.setHighlightMode(false)
// Replace with
tray.setHighlightMode('off')
2016-09-08 16:09:49 +00:00
```
2016-09-07 18:41:54 +00:00
### `webContents`
2016-09-08 16:09:49 +00:00
```js
2016-09-07 18:41:54 +00:00
// Deprecated
2018-09-13 16:10:51 +00:00
webContents.openDevTools({ detach: true })
2016-09-07 18:41:54 +00:00
// Replace with
2018-09-13 16:10:51 +00:00
webContents.openDevTools({ mode: 'detach' })
// Removed
webContents.setSize(options)
// There is no replacement for this API
2016-09-07 18:41:54 +00:00
```
### `webFrame`
```js
2016-11-14 18:33:30 +00:00
// Deprecated
webFrame.registerURLSchemeAsSecure('app')
// Replace with
2018-09-13 16:10:51 +00:00
protocol.registerStandardSchemes(['app'], { secure: true })
2016-11-14 18:33:30 +00:00
// Deprecated
2018-09-13 16:10:51 +00:00
webFrame.registerURLSchemeAsPrivileged('app', { secure: true })
2016-11-14 18:33:30 +00:00
// Replace with
2018-09-13 16:10:51 +00:00
protocol.registerStandardSchemes(['app'], { secure: true })
```
### `<webview>`
```js
// Removed
webview.setAttribute('disableguestresize', '')
// There is no replacement for this API
// Removed
webview.setAttribute('guestinstance', instanceId)
// There is no replacement for this API
// Keyboard listeners no longer work on webview tag
webview.onkeydown = () => { /* handler */ }
webview.onkeyup = () => { /* handler */ }
```
### Node Headers URL
This is the URL specified as `disturl` in a `.npmrc` file or as the `--dist-url`
command line flag when building native Node modules.
Deprecated: https://atom.io/download/atom-shell
Replace with: https://atom.io/download/electron
## Breaking API Changes (2.0)
The following list includes the breaking API changes made in Electron 2.0.
### `BrowserWindow`
```js
// Deprecated
2020-07-09 17:18:49 +00:00
const optionsA = { titleBarStyle: 'hidden-inset' }
const windowA = new BrowserWindow(optionsA)
// Replace with
2020-07-09 17:18:49 +00:00
const optionsB = { titleBarStyle: 'hiddenInset' }
const windowB = new BrowserWindow(optionsB)
```
### `menu`
```js
// Removed
menu.popup(browserWindow, 100, 200, 2)
// Replaced with
2018-09-13 16:10:51 +00:00
menu.popup(browserWindow, { x: 100, y: 200, positioningItem: 2 })
```
### `nativeImage`
```js
// Removed
nativeImage.toPng()
// Replaced with
nativeImage.toPNG()
// Removed
nativeImage.toJpeg()
// Replaced with
nativeImage.toJPEG()
```
### `process`
* `process.versions.electron` and `process.version.chrome` will be made
read-only properties for consistency with the other `process.versions`
properties set by Node.
### `webContents`
```js
// Removed
webContents.setZoomLevelLimits(1, 2)
// Replaced with
webContents.setVisualZoomLevelLimits(1, 2)
```
### `webFrame`
```js
// Removed
webFrame.setZoomLevelLimits(1, 2)
// Replaced with
webFrame.setVisualZoomLevelLimits(1, 2)
```
### `<webview>`
```js
// Removed
webview.setZoomLevelLimits(1, 2)
// Replaced with
webview.setVisualZoomLevelLimits(1, 2)
```
### Duplicate ARM Assets
Each Electron release includes two identical ARM builds with slightly different
filenames, like `electron-v1.7.3-linux-arm.zip` and
`electron-v1.7.3-linux-armv7l.zip`. The asset with the `v7l` prefix was added
to clarify to users which ARM version it supports, and to disambiguate it from
future armv6l and arm64 assets that may be produced.
The file _without the prefix_ is still being published to avoid breaking any
setups that may be consuming it. Starting at 2.0, the unprefixed file will
no longer be published.
For details, see
[6986](https://github.com/electron/electron/pull/6986)
and
[7189](https://github.com/electron/electron/pull/7189).