Skip to content

Commit ec85a91

Browse files
authored
docs: update contextIsolation documentation on access to globals (electron#19732)
1 parent cc136f2 commit ec85a91

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

docs/api/browser-window.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -337,18 +337,17 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
337337
more details.
338338
* `contextIsolation` Boolean (optional) - Whether to run Electron APIs and
339339
the specified `preload` script in a separate JavaScript context. Defaults
340-
to `false`. The context that the `preload` script runs in will still
341-
have full access to the `document` and `window` globals but it will use
342-
its own set of JavaScript builtins (`Array`, `Object`, `JSON`, etc.)
343-
and will be isolated from any changes made to the global environment
344-
by the loaded page. The Electron API will only be available in the
345-
`preload` script and not the loaded page. This option should be used when
346-
loading potentially untrusted remote content to ensure the loaded content
347-
cannot tamper with the `preload` script and any Electron APIs being used.
348-
This option uses the same technique used by [Chrome Content Scripts][chrome-content-scripts].
349-
You can access this context in the dev tools by selecting the
350-
'Electron Isolated Context' entry in the combo box at the top of the
351-
Console tab.
340+
to `false`. The context that the `preload` script runs in will only have
341+
access to its own dedicated `document` and `window` globals, as well as
342+
its own set of JavaScript builtins (`Array`, `Object`, `JSON`, etc.),
343+
which are all invisible to the loaded content. The Electron API will only
344+
be available in the `preload` script and not the loaded page. This option
345+
should be used when loading potentially untrusted remote content to ensure
346+
the loaded content cannot tamper with the `preload` script and any
347+
Electron APIs being used. This option uses the same technique used by
348+
[Chrome Content Scripts][chrome-content-scripts]. You can access this
349+
context in the dev tools by selecting the 'Electron Isolated Context'
350+
entry in the combo box at the top of the Console tab.
352351
* `worldSafeExecuteJavaScript` Boolean (optional) - If true, values returned from `webFrame.executeJavaScript` will be sanitized to ensure JS values
353352
can't unsafely cross between worlds when using `contextIsolation`. The default
354353
is `false`. In Electron 12, the default will be changed to `true`. _Deprecated_

docs/tutorial/security.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ practice, that means that global objects like `Array.prototype.push` or
233233
Electron uses the same technology as Chromium's [Content Scripts](https://developer.chrome.com/extensions/content_scripts#execution-environment)
234234
to enable this behavior.
235235

236-
Even when you use `nodeIntegration: false` to enforce strong isolation and
237-
prevent the use of Node primitives, `contextIsolation` must also be used.
236+
Even when `nodeIntegration: false` is used, to truly enforce strong isolation
237+
and prevent the use of Node primitives `contextIsolation` **must** also be used.
238238

239239
### Why & How?
240240

0 commit comments

Comments
 (0)