Files
electron/build
Samuel Attard 7d3cf33e1a refactor: run sandboxed preload scripts without an Electron JavaScript bundle (#53974)
Sandboxed renderers and service worker preload realms ran a webpack bundle
(sandbox_bundle / preload_realm_bundle) that built the preload scripts'
`process` object and `require`, assembled the `electron` module from the
JavaScript API wrappers, registered the <webview> element and then compiled
and ran each preload script. With the API modules now provided by their
bindings, the rest moves to C++ (shell/renderer/preload_environment.cc):

- `process` is a native EventEmitter carrying the same properties as
  before, plus getProcessMemoryInfo(); 'loaded', 'exit', 'document-start'
  and 'document-end' are emitted on it directly.
- `require('electron')` returns a module object whose properties load their
  binding on first access.
- Preload scripts are compiled with CreatePreloadScript() and called with
  (require, process, exports, module, global); failures are logged and
  reported as 'preload-error' as before.

The only JavaScript Electron still evaluates in a sandboxed renderer is the
<webview> element implementation, now its own `webview_bundle`, and only in
renderers that enable `webviewTag`. The `process` npm polyfill is no longer
needed.
2026-09-17 15:07:40 -07:00
..
2023-11-30 09:51:35 -05:00
2025-02-27 14:31:21 +01:00