Compare commits

...

46 Commits

Author SHA1 Message Date
Electron Bot
05972074e3 Bump v12.0.1 2021-03-10 13:11:09 -08:00
Keeley Hammond
21ac61270a fix: ensure child window transparency (#28107)
* fix: ensure child window transparency works

Windows opened via window.open and intecepted via setWindowOpenHandler
or the `new-window` event should (a) have the correct background color
and (b) that background color should be transparent if specified.

The changes in api_web_contents fix (a) and the changes in
web_contents_preferences fix (b).

Notes: Child windows with specified background colors or transpency now
work as intended

* fix: set background_color in blink prefs apply logic

* fix: apply changes for 12

* fix: background_color patch simplification

* update patches

Co-authored-by: Samuel Attard <sattard@slack-corp.com>
Co-authored-by: Electron Bot <electron@github.com>
2021-03-10 13:08:44 -08:00
trop[bot]
f0500fae4c fix: capturePage not resolving with hidden windows (#28075)
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2021-03-10 09:38:30 +09:00
trop[bot]
5f2f4182c4 fix: pass IsScreen via parameter instead of sync IPC method (#28080)
Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
2021-03-10 09:21:53 +09:00
Electron Bot
ac8db00a70 chore: bump chromium to 89.0.4389.82 (12-x-y) (#27960)
* chore: bump chromium in DEPS to 89.0.4389.72

* chore: bump chromium in DEPS to 89.0.4389.82
2021-03-09 11:08:06 -08:00
trop[bot]
ab5d0f4c8b chore: remove obsolete native node module patch (#28056)
* chore: remove obsolete native node module patch

* update patches

* Fix merge error

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: Electron Bot <electron@github.com>
Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
2021-03-09 19:51:16 +09:00
trop[bot]
203116867b build: call goma_ctl.py ensure_start directly (#28060)
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2021-03-09 16:05:42 +09:00
trop[bot]
67a67270f5 test: ignore the ready event from PDF Viewer (#28049)
Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
2021-03-09 09:11:34 +09:00
trop[bot]
83a3eb64ec docs: setWindowOpenHandler should show object return (#28036)
* Should use object return

* Fix lint

Co-authored-by: Domenic Horner <domenic@tgxn.net>
Co-authored-by: Cheng Zhao <github@zcbenz.com>
2021-03-08 11:21:14 -05:00
trop[bot]
8b1260184a docs: update WebPreferences default values for Electron 12 (#28037)
Updates the values for `contextIsolation` and `worldSafeExecuteJavaScript` for Electron 12.

Co-authored-by: Erick Zhao <erick@hotmail.ca>
2021-03-08 11:07:20 -05:00
trop[bot]
f13ddca55f fix: navigator.setAppBadge/clearAppBadge from a service worker (#28011)
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2021-03-08 09:32:50 +09:00
trop[bot]
f1c4265072 chore: Add a condition to crashReporter deprecate log (#28013)
* Add a condition to crashReporter deprecate log

When developer set  submitURL to '' crash reports will be saved  at `...\AppData\Roaming\...\Crashpad\reports`, will not be uploaded to the server.
So  at this time `deprecate.log('Sending uncompressed crash reports....')`  is  unnecessary.

* Update lib/browser/api/crash-reporter.ts

change to check uploadToServer

Co-authored-by: Jeremy Rose <nornagon@nornagon.net>

Co-authored-by: liulun <xland@live.cn>
Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
2021-03-07 16:31:37 +09:00
trop[bot]
f5de5e9131 fix: warning when worldSafeExecuteJavaScript is disabled (#27969)
Co-authored-by: Milan Burda <milan.burda@gmail.com>
2021-03-05 10:15:11 +09:00
trop[bot]
a73949315c test: fix contextIsolation value for later added test (#28005)
Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
2021-03-05 10:03:25 +09:00
trop[bot]
189f7e0e4e feat: expose des-ede3 cipher (#27992)
Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
2021-03-04 15:52:46 -05:00
Robo
2950f03e83 chore: cherry-pick 67fe5a41bff from chromium (#27991)
Backports https://chromium-review.googlesource.com/c/chromium/src/+/2666008
2021-03-04 15:39:59 -05:00
trop[bot]
ca417e435c fix: check web_contents() for destroyed WebContents (#27966)
Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
2021-03-04 17:01:15 +09:00
trop[bot]
5237108396 fix: offset browserview drag regions on macOS (#27988)
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2021-03-04 16:33:11 +09:00
Electron Bot
3ae63c9a06 Bump v12.0.0 2021-03-01 16:47:13 -08:00
trop[bot]
8828382b23 feat: enable context isolation by default (#27949)
* feat: enable context isolation by default

* chore: set default in ctx iso getter

* spec: make all specs work with the new contextIsolation default

* spec: fix affinity specs

* spec: update tests for new ctx iso default

* spec: update tests for new ctx iso default

* spec: update tests for new ctx iso default

* spec: update tests for new ctx iso default

* chore: move stray prod deps to dev deps

* spec: update tests for new ctx iso default

* turn off contextIsolation for visibility tests

* turn off contextIsolation for <webview> tag nodeintegration attribute loads native modules when navigation happens

Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
Co-authored-by: Samuel Attard <sattard@slack-corp.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2021-03-01 19:35:03 -05:00
trop[bot]
0e714d19c5 fix: ensure owner window valid (#27947)
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2021-03-01 19:33:45 -05:00
Electron Bot
aec412e35d chore: bump chromium to 89.0.4389.69 (12-x-y) (#27907)
* chore: bump chromium in DEPS to 89.0.4389.69

* update patches

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2021-03-01 16:48:59 -05:00
John Kleinschmidt
4b2d791212 chore: revert webFrameMain.executeJavaScriptInIsolatedWorld method (#27926) (#27937)
(cherry picked from commit 84d0e827a3)

Co-authored-by: Keeley Hammond <VerteDinde@users.noreply.github.com>
2021-03-01 13:34:40 -08:00
Shelley Vohr
fd629c16cb fix: set WebContents background color ubiquitously #27592 (#27593) (#27942)
Move it from LoadURL to RenderViewCreated which is present
in all window creation cases and is called early enough to be
relevant from user prespective and after RenderWidgetHostView
is already present.

Co-authored-by: marekharanczyk <48673767+marekharanczyk@users.noreply.github.com>
2021-03-01 13:32:35 -08:00
Keeley Hammond
007c960f3c fix: values return from the ctx bridge with dynamic property support should themselves support dynamic properties (#27940)
Co-authored-by: Samuel Attard <sattard@slack-corp.com>
2021-03-01 15:17:47 -05:00
Keeley Hammond
b2636e171a ci: ignore errors deleting user app directories on WOA testing (#27939) 2021-03-01 13:58:34 -05:00
Keeley Hammond
e7e1801443 fix: race-condition in electron.net (#27938) 2021-03-01 13:50:03 -05:00
Keeley Hammond
0baf9997ad fix: navigator.bluetooth.requestDevice (#27927)
* fix: navigator.bluetooth.requestDevice

* remove permission observer methods not implemented in 12-x-y

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2021-03-01 13:14:41 -05:00
Electron Bot
e65e989650 Bump v12.0.0-beta.31 2021-03-01 07:00:59 -08:00
Shelley Vohr
26a18c26d7 chore: bump node in DEPS to v14.16.0 (#27911)
* chore: bump node in DEPS to v14.16.0

* bootstrap: refactor to use more primordials

https://github.com/nodejs/node/pull/35999

* chore: update filenames list

Co-authored-by: Electron Bot <electron@github.com>
2021-03-01 20:47:44 +09:00
Electron Bot
a52c88ec4d Bump v12.0.0-beta.30 2021-02-25 07:01:19 -08:00
Erick Zhao
0ee559cd29 fix: cherry-pick 5c7ad5393f74 from chromium (#27598)
* fix: cherry-pick 5c7ad5393f74 from chromium

* patch

* mas fix

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2021-02-24 12:44:13 -08:00
trop[bot]
dfed04b71b docs: fix header level of some events in app.md (#27887)
Co-authored-by: Jeremy Rose <jeremya@chromium.org>
2021-02-24 20:36:34 +09:00
trop[bot]
d628fa07b5 fix: cap sendInputEvent text length at n-1 (#27855)
Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
2021-02-24 18:07:27 +09:00
Jeremy Rose
f0c7789544 fix: ECDH.setPrivateKey correctly sets the key (#27688) (#27856)
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2021-02-24 18:06:49 +09:00
trop[bot]
d00e869560 fix: isFullScreen typo (#27864)
* fix isFullScreen typo

* Update lib/browser/api/base-window.ts

Co-authored-by: John Kleinschmidt <jkleinsc@github.com>

Co-authored-by: Tony Wu <tonywoo@fb.com>
Co-authored-by: Tony <TonyWuu@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
2021-02-24 18:05:32 +09:00
Shelley Vohr
b70e42024a fix: libuv hang when nodeIntegrationInSubframes enabled (#27879) 2021-02-24 17:58:32 +09:00
Electron Bot
44adc8ddb4 chore: bump chromium to 89.0.4389.58 (12-x-y) (#27759)
* chore: bump chromium in DEPS to 89.0.4389.47

* chore: bump chromium in DEPS to 89.0.4389.58

* update patches

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2021-02-23 16:27:25 -05:00
Electron Bot
9e30fe0f96 Bump v12.0.0-beta.29 2021-02-23 08:35:33 -08:00
Erick Zhao
7180b2b13f docs: remove v5 and v6 modernization docs (#27858) 2021-02-22 12:21:21 -08:00
trop[bot]
c734baf8d4 fix: gather crash data for unexpected helper path (#27828)
Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
2021-02-22 11:42:25 -05:00
trop[bot]
a859436f7a revert: patch libuv to use posix_spawn on macOS (#27026) (#27810)
* Revert "perf: patch libuv to use posix_spawn on macOS (#27026)"

This reverts commit f69c11105f.

* Update .patches

Co-authored-by: VerteDinde <khammond@slack-corp.com>
Co-authored-by: Robo <hop2deep@gmail.com>
2021-02-22 10:06:29 -05:00
Electron Bot
3144f992f7 Bump v12.0.0-beta.28 2021-02-22 07:01:39 -08:00
trop[bot]
98f57a20e7 fix: enableBlinkFeatures warning in webviews (#27790)
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2021-02-19 15:46:36 +09:00
trop[bot]
f6007654f9 fix: don't create last saved path if none exists (#27806)
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2021-02-19 15:44:10 +09:00
trop[bot]
84a4a7a944 fix: restore window event redispatching on mac (#27769)
Co-authored-by: clavin <cwatford@slack-corp.com>
2021-02-19 15:41:35 +09:00
133 changed files with 11589 additions and 3243 deletions

View File

@@ -308,7 +308,7 @@ step-setup-goma-for-build: &step-setup-goma-for-build
npm install
mkdir third_party
node -e "require('./src/utils/goma.js').downloadAndPrepare({ gomaOneForAll: true })"
node -e "require('./src/utils/goma.js').ensure()"
third_party/goma/goma_ctl.py ensure_start
echo 'export GN_GOMA_FILE='`node -e "console.log(require('./src/utils/goma.js').gnFilePath)"` >> $BASH_ENV
echo 'export LOCAL_GOMA_DIR='`node -e "console.log(require('./src/utils/goma.js').dir)"` >> $BASH_ENV
cd ..

4
DEPS
View File

@@ -14,9 +14,9 @@ gclient_gn_args = [
vars = {
'chromium_version':
'89.0.4389.23',
'89.0.4389.82',
'node_version':
'v14.15.1',
'v14.16.0',
'nan_version':
'2c4ee8a32a299eada3cd6e468bbd0a473bfea96d',
'squirrel.mac_version':

View File

@@ -1 +1 @@
12.0.0-beta.27
12.0.1

View File

@@ -93,6 +93,6 @@ steps:
condition: always()
- powershell: |
Remove-Item -path $env:APPDATA/Electron* -Recurse -Force
Remove-Item -path $env:APPDATA/Electron* -Recurse -Force -ErrorAction Ignore
displayName: 'Delete user app data directories'
condition: always()

View File

@@ -391,7 +391,7 @@ which contains more information about why the render process disappeared. It
isn't always because it crashed. The `killed` boolean can be replaced by
checking `reason === 'killed'` when you switch to that event.
#### Event: 'render-process-gone'
### Event: 'render-process-gone'
Returns:
@@ -413,7 +413,7 @@ Returns:
Emitted when the renderer process unexpectedly disappears. This is normally
because it was crashed or killed.
#### Event: 'child-process-gone'
### Event: 'child-process-gone'
Returns:

View File

@@ -337,7 +337,7 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
more details.
* `contextIsolation` Boolean (optional) - Whether to run Electron APIs and
the specified `preload` script in a separate JavaScript context. Defaults
to `false`. The context that the `preload` script runs in will only have
to `true`. The context that the `preload` script runs in will only have
access to its own dedicated `document` and `window` globals, as well as
its own set of JavaScript builtins (`Array`, `Object`, `JSON`, etc.),
which are all invisible to the loaded content. The Electron API will only
@@ -349,8 +349,7 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
context in the dev tools by selecting the 'Electron Isolated Context'
entry in the combo box at the top of the Console tab.
* `worldSafeExecuteJavaScript` Boolean (optional) - If true, values returned from `webFrame.executeJavaScript` will be sanitized to ensure JS values
can't unsafely cross between worlds when using `contextIsolation`. The default
is `false`. In Electron 12, the default will be changed to `true`. _Deprecated_
can't unsafely cross between worlds when using `contextIsolation`. Defaults to `true`. _Deprecated_
* `nativeWindowOpen` Boolean (optional) - Whether to use native
`window.open()`. Defaults to `false`. Child windows will always have node
integration disabled unless `nodeIntegrationInSubFrames` is true. **Note:** This option is currently
@@ -1457,7 +1456,7 @@ Returns `Boolean` - Whether the window's document has been edited.
Returns `Promise<NativeImage>` - Resolves with a [NativeImage](native-image.md)
Captures a snapshot of the page within `rect`. Omitting `rect` will capture the whole visible page.
Captures a snapshot of the page within `rect`. Omitting `rect` will capture the whole visible page. If the page is not visible, `rect` may be empty.
#### `win.loadURL(url[, options])`

View File

@@ -1,10 +0,0 @@
## Modernization
The Electron team is currently undergoing an initiative to modernize our API in a few concrete ways. These include: updating our modules to use idiomatic JS properties instead of separate `getPropertyX` and `setPropertyX`, converting callbacks to promises, and removing some other anti-patterns present in our APIs. The current status of the Promise initiative can be tracked in the [promisification](promisification.md) tracking file.
As we work to perform these updates, we seek to create the least disruptive amount of change at any given time, so as many changes as possible will be introduced in a backward compatible manner and deprecated after enough time has passed to give users a chance to upgrade their API calls.
This document and its child documents will be updated to reflect the latest status of our API changes.
* [Promisification](promisification.md)
* [Property Updates](property-updates.md)

View File

@@ -1,42 +0,0 @@
## Promisification
The Electron team recently underwent an initiative to convert callback-based APIs to Promise-based ones. See converted functions below:
- [app.getFileIcon(path[, options], callback)](https://github.com/electron/electron/blob/master/docs/api/app.md#getFileIcon)
- [contents.capturePage([rect, ]callback)](https://github.com/electron/electron/blob/master/docs/api/web-contents.md#capturePage)
- [contents.executeJavaScript(code[, userGesture, callback])](https://github.com/electron/electron/blob/master/docs/api/web-contents.md#executeJavaScript)
- [contents.printToPDF(options, callback)](https://github.com/electron/electron/blob/master/docs/api/web-contents.md#printToPDF)
- [contents.savePage(fullPath, saveType, callback)](https://github.com/electron/electron/blob/master/docs/api/web-contents.md#savePage)
- [contentTracing.getCategories(callback)](https://github.com/electron/electron/blob/master/docs/api/content-tracing.md#getCategories)
- [contentTracing.startRecording(options, callback)](https://github.com/electron/electron/blob/master/docs/api/content-tracing.md#startRecording)
- [contentTracing.stopRecording(resultFilePath, callback)](https://github.com/electron/electron/blob/master/docs/api/content-tracing.md#stopRecording)
- [contentTracing.getTraceBufferUsage(callback)](https://github.com/electron/electron/blob/master/docs/api/content-tracing.md#getTraceBufferUsage)
- [cookies.flushStore(callback)](https://github.com/electron/electron/blob/master/docs/api/cookies.md#flushStore)
- [cookies.get(filter, callback)](https://github.com/electron/electron/blob/master/docs/api/cookies.md#get)
- [cookies.remove(url, name, callback)](https://github.com/electron/electron/blob/master/docs/api/cookies.md#remove)
- [cookies.set(details, callback)](https://github.com/electron/electron/blob/master/docs/api/cookies.md#set)
- [debugger.sendCommand(method[, commandParams, callback])](https://github.com/electron/electron/blob/master/docs/api/debugger.md#sendCommand)
- [desktopCapturer.getSources(options, callback)](https://github.com/electron/electron/blob/master/docs/api/desktop-capturer.md#getSources)
- [dialog.showOpenDialog([browserWindow, ]options[, callback])](https://github.com/electron/electron/blob/master/docs/api/dialog.md#showOpenDialog)
- [dialog.showSaveDialog([browserWindow, ]options[, callback])](https://github.com/electron/electron/blob/master/docs/api/dialog.md#showSaveDialog)
- [inAppPurchase.purchaseProduct(productID, quantity, callback)](https://github.com/electron/electron/blob/master/docs/api/in-app-purchase.md#purchaseProduct)
- [inAppPurchase.getProducts(productIDs, callback)](https://github.com/electron/electron/blob/master/docs/api/in-app-purchase.md#getProducts)
- [dialog.showMessageBox([browserWindow, ]options[, callback])](https://github.com/electron/electron/blob/master/docs/api/dialog.md#showMessageBox)
- [dialog.showCertificateTrustDialog([browserWindow, ]options, callback)](https://github.com/electron/electron/blob/master/docs/api/dialog.md#showCertificateTrustDialog)
- [netLog.stopLogging([callback])](https://github.com/electron/electron/blob/master/docs/api/net-log.md#stopLogging)
- [protocol.isProtocolHandled(scheme, callback)](https://github.com/electron/electron/blob/master/docs/api/protocol.md#isProtocolHandled)
- [ses.clearHostResolverCache([callback])](https://github.com/electron/electron/blob/master/docs/api/session.md#clearHostResolverCache)
- [ses.clearStorageData([options, callback])](https://github.com/electron/electron/blob/master/docs/api/session.md#clearStorageData)
- [ses.setProxy(config, callback)](https://github.com/electron/electron/blob/master/docs/api/session.md#setProxy)
- [ses.resolveProxy(url, callback)](https://github.com/electron/electron/blob/master/docs/api/session.md#resolveProxy)
- [ses.getCacheSize(callback)](https://github.com/electron/electron/blob/master/docs/api/session.md#getCacheSize)
- [ses.clearAuthCache(options[, callback])](https://github.com/electron/electron/blob/master/docs/api/session.md#clearAuthCache)
- [ses.clearCache(callback)](https://github.com/electron/electron/blob/master/docs/api/session.md#clearCache)
- [ses.getBlobData(identifier, callback)](https://github.com/electron/electron/blob/master/docs/api/session.md#getBlobData)
- [shell.openExternal(url[, options, callback])](https://github.com/electron/electron/blob/master/docs/api/shell.md#openExternal)
- [webFrame.executeJavaScript(code[, userGesture, callback])](https://github.com/electron/electron/blob/master/docs/api/web-frame.md#executeJavaScript)
- [webFrame.executeJavaScriptInIsolatedWorld(worldId, scripts[, userGesture, callback])](https://github.com/electron/electron/blob/master/docs/api/web-frame.md#executeJavaScriptInIsolatedWorld)
- [webviewTag.capturePage([rect, ]callback)](https://github.com/electron/electron/blob/master/docs/api/webview-tag.md#capturePage)
- [webviewTag.executeJavaScript(code[, userGesture, callback])](https://github.com/electron/electron/blob/master/docs/api/webview-tag.md#executeJavaScript)
- [webviewTag.printToPDF(options, callback)](https://github.com/electron/electron/blob/master/docs/api/webview-tag.md#printToPDF)
- [win.capturePage([rect, ]callback)](https://github.com/electron/electron/blob/master/docs/api/browser-window.md#capturePage)

View File

@@ -1,41 +0,0 @@
## Property Updates
The Electron team is currently undergoing an initiative to convert separate getter and setter functions in Electron to bespoke properties with `get` and `set` functionality. During this transition period, both the new properties and old getters and setters of these functions will work correctly and be documented.
## Candidates
* `BrowserWindow`
* `menubarVisible`
* `crashReporter` module
* `uploadToServer`
* `webFrame` modules
* `zoomFactor`
* `zoomLevel`
* `audioMuted`
* `<webview>`
* `zoomFactor`
* `zoomLevel`
* `audioMuted`
## Converted Properties
* `app` module
* `accessibilitySupport`
* `applicationMenu`
* `badgeCount`
* `name`
* `DownloadItem` class
* `savePath`
* `BrowserWindow` module
* `autoHideMenuBar`
* `resizable`
* `maximizable`
* `minimizable`
* `fullscreenable`
* `movable`
* `closable`
* `backgroundThrottling`
* `NativeImage`
* `isMacTemplateImage`
* `SystemPreferences` module
* `appLevelAppearance`

View File

@@ -86,17 +86,6 @@ In the browser window some HTML APIs like `requestFullScreen` can only be
invoked by a gesture from the user. Setting `userGesture` to `true` will remove
this limitation.
#### `frame.executeJavaScriptInIsolatedWorld(worldId, code[, userGesture])`
* `worldId` Integer - The ID of the world to run the javascript in, `0` is the default world, `999` is the world used by Electron's `contextIsolation` feature. You can provide any integer here.
* `code` String
* `userGesture` Boolean (optional) - Default is `false`.
Returns `Promise<unknown>` - A promise that resolves with the result of the executed
code or is rejected if execution throws or results in a rejected promise.
Works like `executeJavaScript` but evaluates `scripts` in an isolated context.
#### `frame.reload()`
Returns `boolean` - Whether the reload was initiated successfully. Only results in `false` when the frame has no history.

View File

@@ -83,9 +83,9 @@ const mainWindow = new BrowserWindow()
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
if (url.startsWith('https://github.com/')) {
return true
return { action: 'allow' }
}
return false
return { action: 'deny' }
})
mainWindow.webContents.on('did-create-window', (childWindow) => {

View File

@@ -612,6 +612,55 @@ 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)).
### API Changed: Callback-based versions of promisified APIs
Electron 5 and Electron 6 introduced Promise-based versions of existing
asynchronous APIs and deprecated their older, callback-based counterparts.
In Electron 7, all deprecated callback-based APIs are now removed.
These functions now only return Promises:
* `app.getFileIcon()` [#15742](https://github.com/electron/electron/pull/15742)
* `app.dock.show()` [#16904](https://github.com/electron/electron/pull/16904)
* `contentTracing.getCategories()` [#16583](https://github.com/electron/electron/pull/16583)
* `contentTracing.getTraceBufferUsage()` [#16600](https://github.com/electron/electron/pull/16600)
* `contentTracing.startRecording()` [#16584](https://github.com/electron/electron/pull/16584)
* `contentTracing.stopRecording()` [#16584](https://github.com/electron/electron/pull/16584)
* `contents.executeJavaScript()` [#17312](https://github.com/electron/electron/pull/17312)
* `cookies.flushStore()` [#16464](https://github.com/electron/electron/pull/16464)
* `cookies.get()` [#16464](https://github.com/electron/electron/pull/16464)
* `cookies.remove()` [#16464](https://github.com/electron/electron/pull/16464)
* `cookies.set()` [#16464](https://github.com/electron/electron/pull/16464)
* `debugger.sendCommand()` [#16861](https://github.com/electron/electron/pull/16861)
* `dialog.showCertificateTrustDialog()` [#17181](https://github.com/electron/electron/pull/17181)
* `inAppPurchase.getProducts()` [#17355](https://github.com/electron/electron/pull/17355)
* `inAppPurchase.purchaseProduct()`[#17355](https://github.com/electron/electron/pull/17355)
* `netLog.stopLogging()` [#16862](https://github.com/electron/electron/pull/16862)
* `session.clearAuthCache()` [#17259](https://github.com/electron/electron/pull/17259)
* `session.clearCache()` [#17185](https://github.com/electron/electron/pull/17185)
* `session.clearHostResolverCache()` [#17229](https://github.com/electron/electron/pull/17229)
* `session.clearStorageData()` [#17249](https://github.com/electron/electron/pull/17249)
* `session.getBlobData()` [#17303](https://github.com/electron/electron/pull/17303)
* `session.getCacheSize()` [#17185](https://github.com/electron/electron/pull/17185)
* `session.resolveProxy()` [#17222](https://github.com/electron/electron/pull/17222)
* `session.setProxy()` [#17222](https://github.com/electron/electron/pull/17222)
* `shell.openExternal()` [#16176](https://github.com/electron/electron/pull/16176)
* `webContents.loadFile()` [#15855](https://github.com/electron/electron/pull/15855)
* `webContents.loadURL()` [#15855](https://github.com/electron/electron/pull/15855)
* `webContents.hasServiceWorker()` [#16535](https://github.com/electron/electron/pull/16535)
* `webContents.printToPDF()` [#16795](https://github.com/electron/electron/pull/16795)
* `webContents.savePage()` [#16742](https://github.com/electron/electron/pull/16742)
* `webFrame.executeJavaScript()` [#17312](https://github.com/electron/electron/pull/17312)
* `webFrame.executeJavaScriptInIsolatedWorld()` [#17312](https://github.com/electron/electron/pull/17312)
* `webviewTag.executeJavaScript()` [#17312](https://github.com/electron/electron/pull/17312)
* `win.capturePage()` [#15743](https://github.com/electron/electron/pull/15743)
These functions now have two forms, synchronous and Promise-based asynchronous:
* `dialog.showMessageBox()`/`dialog.showMessageBoxSync()` [#17298](https://github.com/electron/electron/pull/17298)
* `dialog.showOpenDialog()`/`dialog.showOpenDialogSync()` [#16973](https://github.com/electron/electron/pull/16973)
* `dialog.showSaveDialog()`/`dialog.showSaveDialogSync()` [#17054](https://github.com/electron/electron/pull/17054)
## Planned Breaking API Changes (6.0)
### API Changed: `win.setMenu(null)` is now `win.removeMenu()`
@@ -623,19 +672,6 @@ win.setMenu(null)
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
@@ -774,6 +810,31 @@ webFrame.setSpellCheckProvider('en-US', {
})
```
### API Changed: `webContents.getZoomLevel` and `webContents.getZoomFactor` are now synchronous
`webContents.getZoomLevel` and `webContents.getZoomFactor` no longer take callback parameters,
instead directly returning their number values.
```js
// Deprecated
webContents.getZoomLevel((level) => {
console.log(level)
})
// Replace with
const level = webContents.getZoomLevel()
console.log(level)
```
```js
// Deprecated
webContents.getZoomFactor((factor) => {
console.log(factor)
})
// Replace with
const factor = webContents.getZoomFactor()
console.log(factor)
```
## Planned Breaking API Changes (4.0)
The following list includes the breaking API changes made in Electron 4.0.

View File

@@ -34,7 +34,6 @@ auto_filenames = {
"docs/api/menu.md",
"docs/api/message-channel-main.md",
"docs/api/message-port-main.md",
"docs/api/modernization",
"docs/api/native-image.md",
"docs/api/native-theme.md",
"docs/api/net-log.md",

View File

@@ -332,6 +332,8 @@ filenames = {
"shell/browser/badging/badge_manager.h",
"shell/browser/badging/badge_manager_factory.cc",
"shell/browser/badging/badge_manager_factory.h",
"shell/browser/bluetooth/electron_bluetooth_delegate.cc",
"shell/browser/bluetooth/electron_bluetooth_delegate.h",
"shell/browser/browser.cc",
"shell/browser/browser.h",
"shell/browser/browser_observer.h",

View File

@@ -43,7 +43,7 @@ Object.defineProperty(BaseWindow.prototype, 'kiosk', {
});
Object.defineProperty(BaseWindow.prototype, 'documentEdited', {
get: function () { return this.isFullscreen(); },
get: function () { return this.isDocumentEdited(); },
set: function (edited) { this.setDocumentEdited(edited); }
});

View File

@@ -18,7 +18,7 @@ class CrashReporter {
if (submitURL == null) throw new Error('submitURL is a required option to crashReporter.start');
if (!compress) {
if (!compress && uploadToServer) {
deprecate.log('Sending uncompressed crash reports is deprecated and will be removed in a future version of Electron. Set { compress: true } to opt-in to the new behavior. Crash reports will be uploaded gzipped, which most crash reporting servers support.');
}

View File

@@ -119,10 +119,13 @@ class IncomingMessage extends Readable {
this._shouldPush = this.push(chunk);
}
if (this._shouldPush && this._resume) {
this._resume();
// Reset the callback, so that a new one is used for each
// batch of throttled data
// batch of throttled data. Do this before calling resume to avoid a
// potential race-condition
const resume = this._resume;
this._resume = null;
resume();
}
}

View File

@@ -626,6 +626,7 @@ WebContents.prototype._init = function () {
// it's technically a BrowserWindowConstructorOptions option because
// we need to access it in the renderer at init time.
backgroundColor: windowOpenOverriddenOptions.backgroundColor,
transparent: windowOpenOverriddenOptions.transparent,
...windowOpenOverriddenOptions.webPreferences
} : undefined;
this._setNextChildWebPreferences(

View File

@@ -48,8 +48,10 @@ class WebFrame extends EventEmitter {
}
}
const { hasSwitch } = process._linkedBinding('electron_common_command_line');
const worldSafeJS = hasSwitch('world-safe-execute-javascript') && hasSwitch('context-isolation');
const contextIsolation = binding.getWebPreference(window, 'contextIsolation');
const worldSafeExecuteJavaScript = binding.getWebPreference(window, 'worldSafeExecuteJavaScript');
const worldSafeJS = worldSafeExecuteJavaScript || !contextIsolation;
// Populate the methods.
for (const name in binding) {

View File

@@ -225,7 +225,7 @@ const warnAboutExperimentalFeatures = function (webPreferences?: Electron.WebPre
const warnAboutEnableBlinkFeatures = function (webPreferences?: Electron.WebPreferences) {
if (!webPreferences ||
!Object.prototype.hasOwnProperty.call(webPreferences, 'enableBlinkFeatures') ||
(webPreferences.enableBlinkFeatures && webPreferences.enableBlinkFeatures.length === 0)) {
(webPreferences.enableBlinkFeatures != null && webPreferences.enableBlinkFeatures.length === 0)) {
return;
}

View File

@@ -1,6 +1,6 @@
{
"name": "electron",
"version": "12.0.0-beta.27",
"version": "12.0.1",
"repository": "https://github.com/electron/electron",
"description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
"devDependencies": {

View File

@@ -1,2 +1,3 @@
expose_ripemd160.patch
expose_aes-cfb.patch
expose_des-ede3.patch

View File

@@ -0,0 +1,40 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Rose <nornagon@nornagon.net>
Date: Wed, 24 Feb 2021 11:08:34 -0800
Subject: expose des-ede3
This should be upstreamed.
diff --git a/crypto/cipher_extra/cipher_extra.c b/crypto/cipher_extra/cipher_extra.c
index 588a4773437c311877f275bf3679f9688cda3c46..e771ed6589b4579cc35300d5b2a1b68d92e444f5 100644
--- a/crypto/cipher_extra/cipher_extra.c
+++ b/crypto/cipher_extra/cipher_extra.c
@@ -93,6 +93,8 @@ const EVP_CIPHER *EVP_get_cipherbyname(const char *name) {
return EVP_rc4();
} else if (OPENSSL_strcasecmp(name, "des-cbc") == 0) {
return EVP_des_cbc();
+ } else if (OPENSSL_strcasecmp(name, "des-ede3") == 0) {
+ return EVP_des_ede3();
} else if (OPENSSL_strcasecmp(name, "des-ede3-cbc") == 0 ||
// This is not a name used by OpenSSL, but tcpdump registers it
// with |EVP_add_cipher_alias|. Our |EVP_add_cipher_alias| is a
diff --git a/decrepit/evp/evp_do_all.c b/decrepit/evp/evp_do_all.c
index 84af06fc56e4aa72d4d48801d7c037add0221747..fe412e350f43ad20758025da6b9754952d164938 100644
--- a/decrepit/evp/evp_do_all.c
+++ b/decrepit/evp/evp_do_all.c
@@ -39,6 +39,7 @@ void EVP_CIPHER_do_all_sorted(void (*callback)(const EVP_CIPHER *cipher,
callback(EVP_des_cbc(), "DES-CBC", NULL, arg);
callback(EVP_des_ecb(), "DES-ECB", NULL, arg);
callback(EVP_des_ede(), "DES-EDE", NULL, arg);
+ callback(EVP_des_ede3(), "DES-EDE3", NULL, arg);
callback(EVP_des_ede_cbc(), "DES-EDE-CBC", NULL, arg);
callback(EVP_des_ede3_cbc(), "DES-EDE3-CBC", NULL, arg);
callback(EVP_rc2_cbc(), "RC2-CBC", NULL, arg);
@@ -65,6 +66,7 @@ void EVP_CIPHER_do_all_sorted(void (*callback)(const EVP_CIPHER *cipher,
callback(EVP_des_cbc(), "des-cbc", NULL, arg);
callback(EVP_des_ecb(), "des-ecb", NULL, arg);
callback(EVP_des_ede(), "des-ede", NULL, arg);
+ callback(EVP_des_ede3(), "des-ede3", NULL, arg);
callback(EVP_des_ede_cbc(), "des-ede-cbc", NULL, arg);
callback(EVP_des_ede3_cbc(), "des-ede3-cbc", NULL, arg);
callback(EVP_rc2_cbc(), "rc2-cbc", NULL, arg);

View File

@@ -108,3 +108,6 @@ fix_setparentacessibile_crash_win.patch
fix_export_zlib_symbols.patch
don_t_use_potentially_null_getwebframe_-_view_when_get_blink.patch
cherry-pick-5902d1aa722a.patch
cherry-pick-5c7ad5393f74.patch
word_break_between_space_and_alphanumeric.patch
moves_background_color_setter_of_webview_to_blinks_webprefs_logic.patch

View File

@@ -48,10 +48,10 @@ index 9305b576b06a8020583939f357cd42902302b543..d772a31a436bf8f0617d87b5fcf5bd96
// its owning reference back to our owning LocalFrame.
client_->Detached(type);
diff --git a/third_party/blink/renderer/core/frame/local_frame.cc b/third_party/blink/renderer/core/frame/local_frame.cc
index dfd7e20c2665bef0a97d8e3391fda588963f2e47..19f8cb6a9c40657ee88f3d7a75dd631b8e95a999 100644
index 4ceaa30497d240acee5899262f4a119a5a883275..6b70d19009844b074f432ac7566a47aba6aa8882 100644
--- a/third_party/blink/renderer/core/frame/local_frame.cc
+++ b/third_party/blink/renderer/core/frame/local_frame.cc
@@ -670,10 +670,6 @@ bool LocalFrame::DetachImpl(FrameDetachType type) {
@@ -672,10 +672,6 @@ bool LocalFrame::DetachImpl(FrameDetachType type) {
}
DCHECK(!view_ || !view_->IsAttached());
@@ -62,7 +62,7 @@ index dfd7e20c2665bef0a97d8e3391fda588963f2e47..19f8cb6a9c40657ee88f3d7a75dd631b
if (!Client())
return false;
@@ -714,6 +710,10 @@ bool LocalFrame::DetachImpl(FrameDetachType type) {
@@ -716,6 +712,10 @@ bool LocalFrame::DetachImpl(FrameDetachType type) {
DCHECK(!view_->IsAttached());
Client()->WillBeDetached();

View File

@@ -9,10 +9,10 @@ potentially prevent a window from being created.
TODO(loc): this patch is currently broken.
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc
index 94586a3ee62a7add8cc68c271aacc7bc14c93ec8..a3c28369e450ec0cc5385493ceb0cc150df23ef7 100644
index ce1b8c15940f4cee14c429a40d3083c5ab09e235..87c15b97cb0105c57e8312bb2580b33a87ae6f75 100644
--- a/content/browser/renderer_host/render_frame_host_impl.cc
+++ b/content/browser/renderer_host/render_frame_host_impl.cc
@@ -5286,6 +5286,7 @@ void RenderFrameHostImpl::CreateNewWindow(
@@ -5213,6 +5213,7 @@ void RenderFrameHostImpl::CreateNewWindow(
last_committed_origin_, params->window_container_type,
params->target_url, params->referrer.To<Referrer>(),
params->frame_name, params->disposition, *params->features,
@@ -21,7 +21,7 @@ index 94586a3ee62a7add8cc68c271aacc7bc14c93ec8..a3c28369e450ec0cc5385493ceb0cc15
&no_javascript_access);
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 496c364797997997f2886abc95db2e6f49d848c6..3981c2caabd0362530c27e0dee572a56aaac0caf 100644
index f4751d821d34a998407b37ca4b8221cd8a2ad135..762d4d6164df6f097c3dd77c695a3270a225ec68 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -3560,6 +3560,14 @@ RenderFrameHostDelegate* WebContentsImpl::CreateNewWindow(
@@ -68,7 +68,7 @@ index 182c6bf04e9937080efcedfc617fb9e072f10500..6fb3a1ee4a31e9a228e8ab04b1ce21c8
// Operation result when the renderer asks the browser to create a new window.
diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc
index e79384f012c548b5e2d42509a2a81484e0443b49..e485c81b2c6335b958983602a8b0e3d84fff5ab4 100644
index 64493c6a92a36dadd9dd7c254856498341460a68..d1c4beb5f3a8e1fb5dfc7d1d31df9a236e3ade8e 100644
--- a/content/public/browser/content_browser_client.cc
+++ b/content/public/browser/content_browser_client.cc
@@ -553,6 +553,8 @@ bool ContentBrowserClient::CanCreateWindow(
@@ -81,7 +81,7 @@ index e79384f012c548b5e2d42509a2a81484e0443b49..e485c81b2c6335b958983602a8b0e3d8
bool opener_suppressed,
bool* no_javascript_access) {
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
index a0d311812044f008d3220930a04d5300edd678fb..d92cfc2b18881a4d48cc4bd8340d6a84b8469c77 100644
index 2cfb4a2bb17daaa831fca95bd21f8341751db7b3..d42c4f7a76f78f1590451691909066e86f29e809 100644
--- a/content/public/browser/content_browser_client.h
+++ b/content/public/browser/content_browser_client.h
@@ -154,6 +154,7 @@ class NetworkService;

View File

@@ -0,0 +1,298 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Robinson <mrobinson@igalia.com>
Date: Mon, 25 Jan 2021 14:27:23 +0000
Subject: Mac a11y: Use the keyboard focusable element for
NSAccessibilityTextChangeElement
When setting the NSAccessibilityTextChangeElement property for
NSAccessibilitySelectedTextChangedNotifications, use the keyboard
focusable element instead of the element that has the focus side of the
text selection. Using the latter, when the element is an empty group,
VoiceOver will focus the containing Web View (when using the VO
cursor follows keyboard focus setting). This makes it impossible to use
the down keyboard key to move past these empty nodes.
VoiceOver cursor" setting in contenteditable nodes.
AX-Relnotes: Fix a bug with the "Synchronize keyboard focus and
Bug: 952922
Change-Id: I3627936726f89b01132c32bd5d83758fc7c3dac4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2642686
Auto-Submit: Martin Robinson <mrobinson@igalia.com>
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Reviewed-by: Nektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846707}
diff --git a/content/browser/accessibility/browser_accessibility_cocoa_browsertest.mm b/content/browser/accessibility/browser_accessibility_cocoa_browsertest.mm
index 03b84fa0963df86c699c4c0a56ca527d5b50a46c..9d042a004217ec5c182bf562207c86cb967df2d2 100644
--- a/content/browser/accessibility/browser_accessibility_cocoa_browsertest.mm
+++ b/content/browser/accessibility/browser_accessibility_cocoa_browsertest.mm
@@ -20,12 +20,11 @@
#include "net/base/data_url.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/gtest_mac.h"
+#include "ui/accessibility/platform/ax_private_webkit_constants_mac.h"
#include "url/gurl.h"
namespace content {
-namespace {
-
class BrowserAccessibilityCocoaBrowserTest : public ContentBrowserTest {
public:
BrowserAccessibilityCocoaBrowserTest() {}
@@ -73,6 +72,11 @@ void FocusAccessibilityElementAndWaitForFocusChange(
WaitForAccessibilityFocusChange();
}
+ NSDictionary* GetUserInfoForSelectedTextChangedNotification() {
+ auto* manager = static_cast<BrowserAccessibilityManagerMac*>(GetManager());
+ return manager->GetUserInfoForSelectedTextChangedNotification();
+ }
+
private:
BrowserAccessibility* FindNodeInSubtree(BrowserAccessibility& node,
ax::mojom::Role role) {
@@ -89,8 +93,6 @@ void FocusAccessibilityElementAndWaitForFocusChange(
}
};
-} // namespace
-
IN_PROC_BROWSER_TEST_F(BrowserAccessibilityCocoaBrowserTest,
AXTextMarkerForTextEdit) {
EXPECT_TRUE(NavigateToURL(shell(), GURL(url::kAboutBlankURL)));
@@ -106,12 +108,11 @@ GURL url(R"HTML(data:text/html,
BrowserAccessibility* text_field = FindNode(ax::mojom::Role::kTextField);
ASSERT_NE(nullptr, text_field);
- EXPECT_TRUE(content::ExecuteScript(
- shell()->web_contents(), "document.querySelector('input').focus()"));
+ EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
+ "document.querySelector('input').focus()"));
- content::SimulateKeyPress(shell()->web_contents(),
- ui::DomKey::FromCharacter('B'), ui::DomCode::US_B,
- ui::VKEY_B, false, false, false, false);
+ SimulateKeyPress(shell()->web_contents(), ui::DomKey::FromCharacter('B'),
+ ui::DomCode::US_B, ui::VKEY_B, false, false, false, false);
base::scoped_nsobject<BrowserAccessibilityCocoa> cocoa_text_field(
[ToBrowserAccessibilityCocoa(text_field) retain]);
@@ -122,10 +123,9 @@ AccessibilityNotificationWaiter value_waiter(shell()->web_contents(),
AXTextEdit text_edit = [cocoa_text_field computeTextEdit];
EXPECT_NE(text_edit.edit_text_marker, nil);
- EXPECT_EQ(
- content::AXTextMarkerToPosition(text_edit.edit_text_marker)->ToString(),
- "TextPosition anchor_id=4 text_offset=1 affinity=downstream "
- "annotated_text=B<>");
+ EXPECT_EQ(AXTextMarkerToPosition(text_edit.edit_text_marker)->ToString(),
+ "TextPosition anchor_id=4 text_offset=1 affinity=downstream "
+ "annotated_text=B<>");
}
IN_PROC_BROWSER_TEST_F(BrowserAccessibilityCocoaBrowserTest,
@@ -604,7 +604,7 @@ GURL url(R"HTML(data:text/html,
ASSERT_NSEQ(@"AXRow", [tree_children[0] role]);
ASSERT_NSEQ(@"AXRow", [tree_children[1] role]);
- content::RenderProcessHost* render_process_host =
+ RenderProcessHost* render_process_host =
shell()->web_contents()->GetMainFrame()->GetProcess();
auto menu_filter = base::MakeRefCounted<ContextMenuFilter>(
ContextMenuFilter::ShowBehavior::kPreventShow);
@@ -619,9 +619,8 @@ GURL url(R"HTML(data:text/html,
EXPECT_NE(tree_point, item_2_point);
// Now focus the second child and trigger a context menu on the tree.
- ASSERT_TRUE(
- content::ExecuteScript(shell()->web_contents(),
- "document.body.children[0].children[1].focus();"));
+ ASSERT_TRUE(ExecuteScript(shell()->web_contents(),
+ "document.body.children[0].children[1].focus();"));
WaitForAccessibilityFocusChange();
// Triggering a context menu on the tree should now trigger the menu
@@ -741,4 +740,63 @@ GURL url(R"HTML(data:text/html,
}
}
+IN_PROC_BROWSER_TEST_F(BrowserAccessibilityCocoaBrowserTest,
+ TestNSAccessibilityTextChangeElement) {
+ AccessibilityNotificationWaiter waiter(shell()->web_contents(),
+ ui::kAXModeComplete,
+ ax::mojom::Event::kLoadComplete);
+
+ GURL url(R"HTML(data:text/html,
+ <div id="editable" contenteditable="true" dir="auto">
+ <p>One</p>
+ <p>Two</p>
+ <p><br></p>
+ <p>Three</p>
+ <p>Four</p>
+ </div>)HTML");
+
+ ASSERT_TRUE(NavigateToURL(shell(), url));
+ waiter.WaitForNotification();
+
+ base::scoped_nsobject<BrowserAccessibilityCocoa> content_editable(
+ [ToBrowserAccessibilityCocoa(GetManager()->GetRoot()->PlatformGetChild(0))
+ retain]);
+ EXPECT_EQ([[content_editable children] count], 5ul);
+
+ WebContents* web_contents = shell()->web_contents();
+ auto run_script_and_wait_for_selection_change =
+ [web_contents](const char* script) {
+ AccessibilityNotificationWaiter waiter(
+ web_contents, ui::kAXModeComplete,
+ ax::mojom::Event::kTextSelectionChanged);
+ ASSERT_TRUE(ExecuteScript(web_contents, script));
+ waiter.WaitForNotification();
+ };
+
+ FocusAccessibilityElementAndWaitForFocusChange(content_editable);
+
+ run_script_and_wait_for_selection_change(R"script(
+ let editable = document.getElementById('editable');
+ const selection = window.getSelection();
+ selection.collapse(editable.children[0].childNodes[0], 1);)script");
+
+ // The focused node in the user info should be the keyboard focusable
+ // ancestor.
+ NSDictionary* info = GetUserInfoForSelectedTextChangedNotification();
+ EXPECT_EQ(id{content_editable},
+ [info objectForKey:ui::NSAccessibilityTextChangeElement]);
+
+ AccessibilityNotificationWaiter waiter2(
+ web_contents, ui::kAXModeComplete,
+ ax::mojom::Event::kTextSelectionChanged);
+ run_script_and_wait_for_selection_change(
+ "selection.collapse(editable.children[2].childNodes[0], 0);");
+
+ // Even when the cursor is in the empty paragraph text node, the focused
+ // object should be the keyboard focusable ancestor.
+ info = GetUserInfoForSelectedTextChangedNotification();
+ EXPECT_EQ(id{content_editable},
+ [info objectForKey:ui::NSAccessibilityTextChangeElement]);
+}
+
} // namespace content
diff --git a/content/browser/accessibility/browser_accessibility_manager_mac.h b/content/browser/accessibility/browser_accessibility_manager_mac.h
index 925bfe1ea191ab846805fdbff1b0314e779b1c9e..5488245e22b883105dbe1e225156ab18e1a64534 100644
--- a/content/browser/accessibility/browser_accessibility_manager_mac.h
+++ b/content/browser/accessibility/browser_accessibility_manager_mac.h
@@ -19,6 +19,8 @@
namespace content {
+class BrowserAccessibilityCocoaBrowserTest;
+
class CONTENT_EXPORT BrowserAccessibilityManagerMac
: public BrowserAccessibilityManager {
public:
@@ -54,8 +56,7 @@ class CONTENT_EXPORT BrowserAccessibilityManagerMac
const std::vector<Change>& changes) override;
// Returns an autoreleased object.
- NSDictionary* GetUserInfoForSelectedTextChangedNotification(
- bool focus_changed);
+ NSDictionary* GetUserInfoForSelectedTextChangedNotification();
// Returns an autoreleased object.
NSDictionary* GetUserInfoForValueChangedNotification(
@@ -80,6 +81,8 @@ class CONTENT_EXPORT BrowserAccessibilityManagerMac
// constructor.
friend class BrowserAccessibilityManager;
+ friend class BrowserAccessibilityCocoaBrowserTest;
+
DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManagerMac);
};
diff --git a/content/browser/accessibility/browser_accessibility_manager_mac.mm b/content/browser/accessibility/browser_accessibility_manager_mac.mm
index 93bcc87244d41c6b72908ed31f83cdd629f6e69f..bbffc89e4f6f2f7b85d285de24120ade082a0090 100644
--- a/content/browser/accessibility/browser_accessibility_manager_mac.mm
+++ b/content/browser/accessibility/browser_accessibility_manager_mac.mm
@@ -131,8 +131,6 @@ void PostAnnouncementNotification(NSString* announcement) {
auto native_node = ToBrowserAccessibilityCocoa(node);
DCHECK(native_node);
- bool focus_changed = GetFocus() != GetLastFocusedNode();
-
// Refer to |AXObjectCache::postPlatformNotification| in WebKit source code.
NSString* mac_notification = nullptr;
switch (event_type) {
@@ -183,8 +181,7 @@ void PostAnnouncementNotification(NSString* announcement) {
if (!focus)
break; // Just fire a notification on the root.
- NSDictionary* user_info =
- GetUserInfoForSelectedTextChangedNotification(focus_changed);
+ NSDictionary* user_info = GetUserInfoForSelectedTextChangedNotification();
BrowserAccessibilityManager* root_manager = GetRootManager();
if (!root_manager)
@@ -452,9 +449,8 @@ void PostAnnouncementNotification(NSString* announcement) {
}
}
-NSDictionary*
-BrowserAccessibilityManagerMac::GetUserInfoForSelectedTextChangedNotification(
- bool focus_changed) {
+NSDictionary* BrowserAccessibilityManagerMac::
+ GetUserInfoForSelectedTextChangedNotification() {
NSMutableDictionary* user_info =
[[[NSMutableDictionary alloc] init] autorelease];
[user_info setObject:@YES forKey:ui::NSAccessibilityTextStateSyncKey];
@@ -471,7 +467,10 @@ void PostAnnouncementNotification(NSString* announcement) {
// TODO(mrobinson): Determine definitively what the type of this text
// selection change is. This requires passing this information here from
// blink.
- if (focus_changed) {
+ BrowserAccessibility* focused_accessibility = GetFocus();
+ DCHECK(focused_accessibility);
+
+ if (focused_accessibility != GetLastFocusedNode()) {
[user_info setObject:@(ui::AXTextStateChangeTypeSelectionMove)
forKey:ui::NSAccessibilityTextStateChangeTypeKey];
} else {
@@ -479,25 +478,22 @@ void PostAnnouncementNotification(NSString* announcement) {
forKey:ui::NSAccessibilityTextStateChangeTypeKey];
}
- int32_t focus_id = ax_tree()->GetUnignoredSelection().focus_object_id;
- BrowserAccessibility* focus_object = GetFromID(focus_id);
- if (focus_object) {
- focus_object = focus_object->PlatformGetClosestPlatformObject();
- auto native_focus_object = ToBrowserAccessibilityCocoa(focus_object);
- if (native_focus_object && [native_focus_object instanceActive]) {
- [user_info setObject:native_focus_object
- forKey:ui::NSAccessibilityTextChangeElement];
+ focused_accessibility =
+ focused_accessibility->PlatformGetClosestPlatformObject();
+ auto native_focus_object = ToBrowserAccessibilityCocoa(focused_accessibility);
+ if (native_focus_object && [native_focus_object instanceActive]) {
+ [user_info setObject:native_focus_object
+ forKey:ui::NSAccessibilityTextChangeElement];
#ifndef MAS_BUILD
- id selected_text = [native_focus_object selectedTextMarkerRange];
- if (selected_text) {
- NSString* const NSAccessibilitySelectedTextMarkerRangeAttribute =
- @"AXSelectedTextMarkerRange";
- [user_info setObject:selected_text
- forKey:NSAccessibilitySelectedTextMarkerRangeAttribute];
- }
-#endif
+ id selected_text = [native_focus_object selectedTextMarkerRange];
+ if (selected_text) {
+ NSString* const NSAccessibilitySelectedTextMarkerRangeAttribute =
+ @"AXSelectedTextMarkerRange";
+ [user_info setObject:selected_text
+ forKey:NSAccessibilitySelectedTextMarkerRangeAttribute];
}
+#endif
}
return user_info;

View File

@@ -140,10 +140,10 @@ index dc7f3bc886e7130c66d98ae6de73c17db746cbe5..6197db3570c860f39f381370e1af37f8
}
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 1dc23535c42aec292e94a09e9fd2d1c7f37e82cd..01cea80d1fe0effeaf200fb6988df7f89787441a 100644
index 409f908148b3d2885216a12048fc3f2e3ea47c89..d43be2439324753f504109f3a3fc0a4f3799bee5 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -1802,12 +1802,11 @@ bool Browser::IsWebContentsCreationOverridden(
@@ -1804,12 +1804,11 @@ bool Browser::IsWebContentsCreationOverridden(
content::SiteInstance* source_site_instance,
content::mojom::WindowContainerType window_container_type,
const GURL& opener_url,
@@ -159,10 +159,10 @@ index 1dc23535c42aec292e94a09e9fd2d1c7f37e82cd..01cea80d1fe0effeaf200fb6988df7f8
WebContents* Browser::CreateCustomWebContents(
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index 7287ec00c3f57a8e10c4329f181bcdccaed7177d..81b7395aec797c201465164437441cbca6e99e0d 100644
index 1ccab44183bf3d47762cff2198231e3fda9c53fc..7fc6a35ddee24340913f03c23fe7b8f80a102398 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -784,8 +784,7 @@ class Browser : public TabStripModelObserver,
@@ -791,8 +791,7 @@ class Browser : public TabStripModelObserver,
content::SiteInstance* source_site_instance,
content::mojom::WindowContainerType window_container_type,
const GURL& opener_url,
@@ -264,7 +264,7 @@ index c5c5a7b63b5b3b62a9517cbef3ae23ce57a3c89c..4f1b7e88d6d2ae89a60311c8aeb1fcee
void AddNewContents(content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index d20ce60c04007a83e412defbf525a756788bd0cc..a733423a617638147602c49874e0fa60c7983460 100644
index a2bce274bdd70c0481a1bc75d449bfadf7b91618..af8196ef8a368b6e91703a8b91db58b94417a182 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -3521,8 +3521,7 @@ RenderFrameHostDelegate* WebContentsImpl::CreateNewWindow(
@@ -362,7 +362,7 @@ index a7f0b19a8ab9bac6f1315ebd715d8e1b134edfe1..cbe2912d4ab2d9015396bbddf7836e10
content::RenderFrameHost* opener,
content::SiteInstance* source_site_instance,
diff --git a/fuchsia/engine/browser/frame_impl.cc b/fuchsia/engine/browser/frame_impl.cc
index a83c2dd71ef35358e55234200cc1a67f04ac84a9..de02460d4d390950330b07c97f9791388474ee2c 100644
index cadebbfd37738ae7df9486a4240d9bdda4197f47..79ae6d8672b7435fbe5daa22986327cb07aef557 100644
--- a/fuchsia/engine/browser/frame_impl.cc
+++ b/fuchsia/engine/browser/frame_impl.cc
@@ -372,8 +372,7 @@ bool FrameImpl::IsWebContentsCreationOverridden(

View File

@@ -7,10 +7,10 @@ spellchecker uses a few IDS_ resources. We need to load these from
Electrons grit header instead of Chromes
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 5a50d7548785fe5dd5a713313f2d6e5605e81129..255905947e7211d839dd995cd08b88d386adc577 100644
index 508e6780855e31b4e9e520b793527c0e295ed01a..14dd777a3d1ede24e0f73c7718a2b69aaaff8f52 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -6207,6 +6207,7 @@ static_library("browser") {
@@ -6203,6 +6203,7 @@ static_library("browser") {
deps += [
"//components/spellcheck/browser",
"//components/spellcheck/common",

View File

@@ -20,7 +20,7 @@ to deal with color spaces. That is being tracked at
https://crbug.com/634542 and https://crbug.com/711107.
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 22a27d63b4915a52428b17267076c7d9c4a7e812..0ec54b87ecdd4e782da8f8948ea8c17af07090bd 100644
index 23ca139dc684007eedc35696108bb1171191f86d..80a47f960fa8c1fdd45ea9cd18eacd8e7cff8d49 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -1770,6 +1770,10 @@ void LayerTreeHostImpl::SetIsLikelyToRequireADraw(

View File

@@ -34,7 +34,7 @@ index 3dd95dcf37cbc3b73b79b098524bf05666e1b9de..57cb297221c01994580e3a0f3546fbad
const base::TimeDelta& delay) {
new_content_rendering_delay_ = delay;
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index dd16ddb90fa91abe60448838daaa6eb571ebc015..5ef54931e1254fe8c8b5985874ac700cb6f18124 100644
index 33122769e7c40cd88046d0c390a93d4924b9c48f..ee6e08c581d3f2d13e29d03eedf502cf4f156f3c 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -606,7 +606,7 @@ void RenderWidgetHostViewAura::HideImpl() {

View File

@@ -51,7 +51,7 @@ index 103958bba8a41b217bbaf4d8899fec3ad562aa70..a9447adde5430f123bb28fb8bf746d20
// This may only be called on NetworkContexts created with the constructor
// that calls MakeURLRequestContext().
diff --git a/services/network/network_context.h b/services/network/network_context.h
index e7fc843b99e309234df35122a46e324fae81f4e3..e25cb6d5043935f455a033da2426bacc1d5aea0f 100644
index 494d68d7f399152a08dd74ee4aa2d17baec81dd8..19e1fae26676c3ec45fce162b784f67cafdce35a 100644
--- a/services/network/network_context.h
+++ b/services/network/network_context.h
@@ -251,6 +251,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext

View File

@@ -8,25 +8,21 @@ rendering with the viz compositor by way of a custom HostDisplayClient
and LayeredWindowUpdater.
diff --git a/components/viz/host/host_display_client.cc b/components/viz/host/host_display_client.cc
index 3b00759e513dc7e19fd68398e853c8ce6ac73905..d89fe3a7cc3f89d99606a74936626eeee3836956 100644
index 3b00759e513dc7e19fd68398e853c8ce6ac73905..47f4e7cc2e8b3141dcaf9e7a498fec32c9342f40 100644
--- a/components/viz/host/host_display_client.cc
+++ b/components/viz/host/host_display_client.cc
@@ -45,9 +45,13 @@ void HostDisplayClient::OnDisplayReceivedCALayerParams(
@@ -45,9 +45,9 @@ void HostDisplayClient::OnDisplayReceivedCALayerParams(
}
#endif
-#if defined(OS_WIN)
+void HostDisplayClient::IsOffscreen(IsOffscreenCallback callback) {
+ std::move(callback).Run(false);
+}
+
void HostDisplayClient::CreateLayeredWindowUpdater(
mojo::PendingReceiver<mojom::LayeredWindowUpdater> receiver) {
+#if defined(OS_WIN)
if (!NeedsToUseLayerWindow(widget_)) {
DLOG(ERROR) << "HWND shouldn't be using a layered window";
return;
@@ -55,8 +59,12 @@ void HostDisplayClient::CreateLayeredWindowUpdater(
@@ -55,8 +55,12 @@ void HostDisplayClient::CreateLayeredWindowUpdater(
layered_window_updater_ =
std::make_unique<LayeredWindowUpdaterImpl>(widget_, std::move(receiver));
@@ -41,24 +37,15 @@ index 3b00759e513dc7e19fd68398e853c8ce6ac73905..d89fe3a7cc3f89d99606a74936626eee
// TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
// of lacros-chrome is complete.
diff --git a/components/viz/host/host_display_client.h b/components/viz/host/host_display_client.h
index 5e260e13762f61971c99f755e93d73aa794d9175..b4a46b030335f49b59b2c678078e5f18ef432300 100644
index 5e260e13762f61971c99f755e93d73aa794d9175..a57770718b71def04fa35c7655d9368a58f39f20 100644
--- a/components/viz/host/host_display_client.h
+++ b/components/viz/host/host_display_client.h
@@ -32,17 +32,17 @@ class VIZ_HOST_EXPORT HostDisplayClient : public mojom::DisplayClient {
mojo::PendingRemote<mojom::DisplayClient> GetBoundRemote(
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
- private:
+ protected:
// mojom::DisplayClient implementation:
+ void IsOffscreen(IsOffscreenCallback callback) override;
+
#if defined(OS_APPLE)
void OnDisplayReceivedCALayerParams(
@@ -39,10 +39,9 @@ class VIZ_HOST_EXPORT HostDisplayClient : public mojom::DisplayClient {
const gfx::CALayerParams& ca_layer_params) override;
#endif
-#if defined(OS_WIN)
+ protected:
void CreateLayeredWindowUpdater(
mojo::PendingReceiver<mojom::LayeredWindowUpdater> receiver) override;
-#endif
@@ -94,7 +81,7 @@ index 1026b739d283f0fc252fa2af83a6d4cf51bc8553..fe562ab60ce98b8bb0c5080a6428deb3
private:
const HWND hwnd_;
diff --git a/components/viz/service/BUILD.gn b/components/viz/service/BUILD.gn
index c66d791c7c9ade70473ba7f91056d403b10df24b..d1fb89d2ef0f81f2fbe37fabc8e466984d24280c 100644
index 0f6a5a2fa3d82ae76889ef55af14e18b86cacffc..e33cd6305f53aa9287c61bf2d38848f878a14d30 100644
--- a/components/viz/service/BUILD.gn
+++ b/components/viz/service/BUILD.gn
@@ -119,6 +119,8 @@ viz_component("service") {
@@ -106,8 +93,22 @@ index c66d791c7c9ade70473ba7f91056d403b10df24b..d1fb89d2ef0f81f2fbe37fabc8e46698
"display_embedder/software_output_surface.cc",
"display_embedder/software_output_surface.h",
"display_embedder/viz_process_context_provider.cc",
diff --git a/components/viz/service/display_embedder/output_surface_provider.h b/components/viz/service/display_embedder/output_surface_provider.h
index 77d463e683d8b8d3a202681a6884eacaab79d70d..05d51cb2637d34c073cd0025e365803633459a86 100644
--- a/components/viz/service/display_embedder/output_surface_provider.h
+++ b/components/viz/service/display_embedder/output_surface_provider.h
@@ -39,7 +39,8 @@ class OutputSurfaceProvider {
mojom::DisplayClient* display_client,
DisplayCompositorMemoryAndTaskController* gpu_dependency,
const RendererSettings& renderer_settings,
- const DebugRendererSettings* debug_settings) = 0;
+ const DebugRendererSettings* debug_settings,
+ bool offscreen) = 0;
};
} // namespace viz
diff --git a/components/viz/service/display_embedder/output_surface_provider_impl.cc b/components/viz/service/display_embedder/output_surface_provider_impl.cc
index 79c800e77a160cc0b10a29dd560d37e19c9d05fd..6513af7550933f988edacc0de124ae29c06500f8 100644
index 79c800e77a160cc0b10a29dd560d37e19c9d05fd..a9b1b267c97ed513890ba8466f66c3eafcbd5d5b 100644
--- a/components/viz/service/display_embedder/output_surface_provider_impl.cc
+++ b/components/viz/service/display_embedder/output_surface_provider_impl.cc
@@ -25,6 +25,7 @@
@@ -126,29 +127,70 @@ index 79c800e77a160cc0b10a29dd560d37e19c9d05fd..6513af7550933f988edacc0de124ae29
#include "ui/base/ui_base_switches.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/init/gl_factory.h"
@@ -245,6 +247,22 @@ OutputSurfaceProviderImpl::CreateSoftwareOutputDeviceForPlatform(
@@ -130,7 +132,8 @@ std::unique_ptr<OutputSurface> OutputSurfaceProviderImpl::CreateOutputSurface(
mojom::DisplayClient* display_client,
DisplayCompositorMemoryAndTaskController* gpu_dependency,
const RendererSettings& renderer_settings,
- const DebugRendererSettings* debug_settings) {
+ const DebugRendererSettings* debug_settings,
+ bool offscreen) {
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (surface_handle == gpu::kNullSurfaceHandle)
return std::make_unique<OutputSurfaceUnified>();
@@ -142,7 +145,7 @@ std::unique_ptr<OutputSurface> OutputSurfaceProviderImpl::CreateOutputSurface(
if (!gpu_compositing) {
output_surface = std::make_unique<SoftwareOutputSurface>(
- CreateSoftwareOutputDeviceForPlatform(surface_handle, display_client));
+ CreateSoftwareOutputDeviceForPlatform(surface_handle, display_client, offscreen));
} else if (renderer_settings.use_skia_renderer) {
DCHECK(gpu_dependency);
{
@@ -241,10 +244,22 @@ std::unique_ptr<OutputSurface> OutputSurfaceProviderImpl::CreateOutputSurface(
std::unique_ptr<SoftwareOutputDevice>
OutputSurfaceProviderImpl::CreateSoftwareOutputDeviceForPlatform(
gpu::SurfaceHandle surface_handle,
- mojom::DisplayClient* display_client) {
+ mojom::DisplayClient* display_client,
+ bool offscreen) {
if (headless_)
return std::make_unique<SoftwareOutputDevice>();
+#if !defined(OS_MAC)
+ {
+ mojo::ScopedAllowSyncCallForTesting allow_sync;
+ if (offscreen) {
+ DCHECK(display_client);
+ bool offscreen = false;
+ if (display_client->IsOffscreen(&offscreen) && offscreen) {
+ mojom::LayeredWindowUpdaterPtr layered_window_updater;
+ display_client->CreateLayeredWindowUpdater(
+ mojo::MakeRequest(&layered_window_updater));
+
+ return std::make_unique<SoftwareOutputDeviceProxy>(
+ std::move(layered_window_updater));
+ }
+ mojom::LayeredWindowUpdaterPtr layered_window_updater;
+ display_client->CreateLayeredWindowUpdater(
+ mojo::MakeRequest(&layered_window_updater));
+ return std::make_unique<SoftwareOutputDeviceProxy>(
+ std::move(layered_window_updater));
+ }
+#endif
+
#if defined(OS_WIN)
return CreateSoftwareOutputDeviceWin(surface_handle, &output_device_backing_,
display_client);
diff --git a/components/viz/service/display_embedder/output_surface_provider_impl.h b/components/viz/service/display_embedder/output_surface_provider_impl.h
index a6bb42cdbc567f526cc70c5c4d9b967274dc0332..d116844635922c8a1086dfa13063b8ae8b43ce59 100644
--- a/components/viz/service/display_embedder/output_surface_provider_impl.h
+++ b/components/viz/service/display_embedder/output_surface_provider_impl.h
@@ -61,12 +61,14 @@ class VIZ_SERVICE_EXPORT OutputSurfaceProviderImpl
mojom::DisplayClient* display_client,
DisplayCompositorMemoryAndTaskController* gpu_dependency,
const RendererSettings& renderer_settings,
- const DebugRendererSettings* debug_settings) override;
+ const DebugRendererSettings* debug_settings,
+ bool offscreen) override;
private:
std::unique_ptr<SoftwareOutputDevice> CreateSoftwareOutputDeviceForPlatform(
gpu::SurfaceHandle surface_handle,
- mojom::DisplayClient* display_client);
+ mojom::DisplayClient* display_client,
+ bool offscreen);
GpuServiceImpl* const gpu_service_impl_;
gpu::CommandBufferTaskExecutor* const task_executor_;
diff --git a/components/viz/service/display_embedder/software_output_device_mac.cc b/components/viz/service/display_embedder/software_output_device_mac.cc
index 49149081cc603f14eacee647cbb2fcf8ed5e66fd..9ff3f2ee203403fdaa31edb8a0bcc000c4d214d7 100644
--- a/components/viz/service/display_embedder/software_output_device_mac.cc
@@ -454,11 +496,25 @@ index 2bb30e5318b6b48c2e6d4b1f64a6a36c68f963d1..9e805f27a9d7d1c0aa68cdf9f48895c0
&SoftwareOutputDeviceWinProxy::DrawAck, base::Unretained(this)));
waiting_on_draw_ack_ = true;
diff --git a/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.cc b/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.cc
index 8112abf9ca0bf214721f5996bb59f7458d9347d2..8b3c2a4cce0c4789fadd555b360dea2c145ae1a4 100644
--- a/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.cc
+++ b/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.cc
@@ -46,7 +46,8 @@ RootCompositorFrameSinkImpl::Create(
params->gpu_compositing, params->widget, params->renderer_settings);
auto output_surface = output_surface_provider->CreateOutputSurface(
params->widget, params->gpu_compositing, display_client.get(),
- display_controller.get(), params->renderer_settings, debug_settings);
+ display_controller.get(), params->renderer_settings, debug_settings,
+ params->offscreen);
// Creating output surface failed. The host can send a new request, possibly
// with a different compositing mode.
diff --git a/content/browser/compositor/viz_process_transport_factory.cc b/content/browser/compositor/viz_process_transport_factory.cc
index 11ac1649ed0f5be1d12e8a30b8d170f86b8e9bb8..ade5afce4a5d3c9e44081a3b1ac971b595e7a5da 100644
index 11ac1649ed0f5be1d12e8a30b8d170f86b8e9bb8..05746d9a561c3933ae0c5578467f20b486453943 100644
--- a/content/browser/compositor/viz_process_transport_factory.cc
+++ b/content/browser/compositor/viz_process_transport_factory.cc
@@ -414,8 +414,13 @@ void VizProcessTransportFactory::OnEstablishedGpuChannel(
@@ -414,8 +414,14 @@ void VizProcessTransportFactory::OnEstablishedGpuChannel(
compositor_data.display_private.reset();
root_params->display_private =
compositor_data.display_private.BindNewEndpointAndPassReceiver();
@@ -467,6 +523,7 @@ index 11ac1649ed0f5be1d12e8a30b8d170f86b8e9bb8..ade5afce4a5d3c9e44081a3b1ac971b5
+ if (compositor->delegate()) {
+ compositor_data.display_client = compositor->delegate()->CreateHostDisplayClient(
+ compositor);
+ root_params->offscreen = compositor->delegate()->IsOffscreen();
+ } else {
+ compositor_data.display_client =
+ std::make_unique<HostDisplayClient>(compositor);
@@ -474,40 +531,11 @@ index 11ac1649ed0f5be1d12e8a30b8d170f86b8e9bb8..ade5afce4a5d3c9e44081a3b1ac971b5
root_params->display_client =
compositor_data.display_client->GetBoundRemote(resize_task_runner_);
diff --git a/mojo/public/cpp/bindings/sync_call_restrictions.h b/mojo/public/cpp/bindings/sync_call_restrictions.h
index 4ff82130b358cd4f0bf1bd5673a9f7b89c087ea5..2bb5dfb20ab58b623b43da1f36b4d586cd5b8ecb 100644
--- a/mojo/public/cpp/bindings/sync_call_restrictions.h
+++ b/mojo/public/cpp/bindings/sync_call_restrictions.h
@@ -33,6 +33,7 @@ class Compositor;
namespace viz {
class HostFrameSinkManager;
+class GpuDisplayProvider;
}
namespace mojo {
@@ -83,6 +84,8 @@ class COMPONENT_EXPORT(MOJO_CPP_BINDINGS) SyncCallRestrictions {
// For destroying the GL context/surface that draw to a platform window before
// the platform window is destroyed.
friend class viz::HostFrameSinkManager;
+ // For query of whether to use SoftwareOutputDevice or not
+ friend class viz::GpuDisplayProvider;
// For preventing frame swaps of wrong size during resize on Windows.
// (https://crbug.com/811945)
friend class ui::Compositor;
diff --git a/services/viz/privileged/mojom/compositing/display_private.mojom b/services/viz/privileged/mojom/compositing/display_private.mojom
index 0c9686f3c8070000bf5b180d9c06a8817d430c4a..a69b9613a61ef68624b3f69dc087603ad5cfd0c2 100644
index 0c9686f3c8070000bf5b180d9c06a8817d430c4a..4538b95f6e71708144eb7752438b1b31d60cb2ca 100644
--- a/services/viz/privileged/mojom/compositing/display_private.mojom
+++ b/services/viz/privileged/mojom/compositing/display_private.mojom
@@ -80,12 +80,14 @@ interface DisplayPrivate {
};
interface DisplayClient {
+ [Sync]
+ IsOffscreen() => (bool success);
+
[EnableIf=is_mac]
OnDisplayReceivedCALayerParams(gfx.mojom.CALayerParams ca_layer_params);
@@ -85,7 +85,6 @@ interface DisplayClient {
// Creates a LayeredWindowUpdater implementation to draw into a layered
// window.
@@ -515,6 +543,18 @@ index 0c9686f3c8070000bf5b180d9c06a8817d430c4a..a69b9613a61ef68624b3f69dc087603a
CreateLayeredWindowUpdater(pending_receiver<LayeredWindowUpdater> receiver);
// Notifies that a swap has occurred and provides information about the pixel
diff --git a/services/viz/privileged/mojom/compositing/frame_sink_manager.mojom b/services/viz/privileged/mojom/compositing/frame_sink_manager.mojom
index a0b87925e0c9d02f586cc4e9446cbfcf12b7aa1c..71659834eec5237016f95f93defa9dcb30f0af52 100644
--- a/services/viz/privileged/mojom/compositing/frame_sink_manager.mojom
+++ b/services/viz/privileged/mojom/compositing/frame_sink_manager.mojom
@@ -30,6 +30,7 @@ struct RootCompositorFrameSinkParams {
// Disables begin frame rate limiting for the display compositor.
bool disable_frame_rate_limit = false;
bool use_preferred_interval_for_video = false;
+ bool offscreen = false;
[EnableIf=is_android]
float refresh_rate;
diff --git a/services/viz/privileged/mojom/compositing/layered_window_updater.mojom b/services/viz/privileged/mojom/compositing/layered_window_updater.mojom
index 6b7fbb6cf13dc8ee6ade0878a9a2c1efc5d4d3f1..e2af75168cb914a7b3b4a6c9b6a285498c3f8e72 100644
--- a/services/viz/privileged/mojom/compositing/layered_window_updater.mojom
@@ -527,7 +567,7 @@ index 6b7fbb6cf13dc8ee6ade0878a9a2c1efc5d4d3f1..e2af75168cb914a7b3b4a6c9b6a28549
+ Draw(gfx.mojom.Rect damage_rect) => ();
};
diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h
index e1db8f745c077b2f57b39a48aeab434fe0e98541..08c7dfa4988ef0247b0bd788171e4a9653612f19 100644
index e1db8f745c077b2f57b39a48aeab434fe0e98541..ddafd1f2aa38ef30776fa89ffcf5d108be963ac9 100644
--- a/ui/compositor/compositor.h
+++ b/ui/compositor/compositor.h
@@ -77,6 +77,7 @@ class ExternalBeginFrameController;
@@ -538,12 +578,13 @@ index e1db8f745c077b2f57b39a48aeab434fe0e98541..08c7dfa4988ef0247b0bd788171e4a96
class HostFrameSinkManager;
class LocalSurfaceId;
class RasterContextProvider;
@@ -133,6 +134,15 @@ class COMPOSITOR_EXPORT ContextFactory {
@@ -133,6 +134,16 @@ class COMPOSITOR_EXPORT ContextFactory {
virtual viz::HostFrameSinkManager* GetHostFrameSinkManager() = 0;
};
+class COMPOSITOR_EXPORT CompositorDelegate {
+ public:
+ virtual bool IsOffscreen() const = 0;
+ virtual std::unique_ptr<viz::HostDisplayClient> CreateHostDisplayClient(
+ ui::Compositor* compositor) = 0;
+
@@ -554,7 +595,7 @@ index e1db8f745c077b2f57b39a48aeab434fe0e98541..08c7dfa4988ef0247b0bd788171e4a96
// Compositor object to take care of GPU painting.
// A Browser compositor object is responsible for generating the final
// displayable form of pixels comprising a single widget's contents. It draws an
@@ -167,6 +177,9 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient,
@@ -167,6 +178,9 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient,
// Schedules a redraw of the layer tree associated with this compositor.
void ScheduleDraw();
@@ -564,7 +605,7 @@ index e1db8f745c077b2f57b39a48aeab434fe0e98541..08c7dfa4988ef0247b0bd788171e4a96
// Sets the root of the layer tree drawn by this Compositor. The root layer
// must have no parent. The compositor's root layer is reset if the root layer
// is destroyed. NULL can be passed to reset the root layer, in which case the
@@ -435,6 +448,8 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient,
@@ -435,6 +449,8 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient,
std::unique_ptr<PendingBeginFrameArgs> pending_begin_frame_args_;

View File

@@ -13,7 +13,7 @@ This patch can be removed once app.allowRendererProcessReuse is forced
to true as then Chromiums assumptions around processes become correct.
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 3981c2caabd0362530c27e0dee572a56aaac0caf..81ecd2d06104aa125c95d40336e8192ec23a1206 100644
index 762d4d6164df6f097c3dd77c695a3270a225ec68..eac2487f18332616b1550bd7fa1f39f5c532b079 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -2971,11 +2971,13 @@ bool WebContentsImpl::HandleMouseEvent(const blink::WebMouseEvent& event) {

View File

@@ -42,10 +42,10 @@ index 65e627f2fa89352b0be27b5813d71a622bf1d326..113f4fd00f1cf994b39f64c9da387855
// another SiteInstance for the same site.
void RegisterSiteInstance(SiteInstanceImpl* site_instance);
diff --git a/content/browser/renderer_host/navigation_request.cc b/content/browser/renderer_host/navigation_request.cc
index 07c5521daf64a41c20f5b00c64b25fe537da0b8b..0e5e3e13590ab6126c20a1163353c0c76730a10c 100644
index 24450c34eaed19d06bed16368c21ce838ff21e88..7ea0a4b99b7d5c1444fab19913e455153577573a 100644
--- a/content/browser/renderer_host/navigation_request.cc
+++ b/content/browser/renderer_host/navigation_request.cc
@@ -1488,6 +1488,21 @@ void NavigationRequest::BeginNavigation() {
@@ -1496,6 +1496,21 @@ void NavigationRequest::BeginNavigation() {
if (IsSameDocument()) {
render_frame_host_ = frame_tree_node_->current_frame_host();
} else {
@@ -67,7 +67,7 @@ index 07c5521daf64a41c20f5b00c64b25fe537da0b8b..0e5e3e13590ab6126c20a1163353c0c7
// Select an appropriate RenderFrameHost.
std::string frame_host_choice_reason;
render_frame_host_ =
@@ -5334,6 +5349,7 @@ void NavigationRequest::CheckStateTransition(NavigationState state) const {
@@ -5365,6 +5380,7 @@ void NavigationRequest::CheckStateTransition(NavigationState state) const {
{WILL_START_REQUEST, {
WILL_REDIRECT_REQUEST,
WILL_PROCESS_RESPONSE,
@@ -75,7 +75,7 @@ index 07c5521daf64a41c20f5b00c64b25fe537da0b8b..0e5e3e13590ab6126c20a1163353c0c7
READY_TO_COMMIT,
DID_COMMIT,
CANCELING,
@@ -5347,10 +5363,14 @@ void NavigationRequest::CheckStateTransition(NavigationState state) const {
@@ -5378,10 +5394,14 @@ void NavigationRequest::CheckStateTransition(NavigationState state) const {
WILL_FAIL_REQUEST,
}},
{WILL_PROCESS_RESPONSE, {
@@ -91,7 +91,7 @@ index 07c5521daf64a41c20f5b00c64b25fe537da0b8b..0e5e3e13590ab6126c20a1163353c0c7
NOT_STARTED,
DID_COMMIT,
diff --git a/content/browser/renderer_host/navigation_request.h b/content/browser/renderer_host/navigation_request.h
index 63cc56b13dd9831a220544151a5aaa0d1e8cf0f5..6fabf7ff363ab8bf9966e8a5d99217e61c77ccb9 100644
index a5c8cafef454369e593ed5f63770b914f22b0884..396af71f380977e588da58e361b24ffe8b240a6e 100644
--- a/content/browser/renderer_host/navigation_request.h
+++ b/content/browser/renderer_host/navigation_request.h
@@ -133,6 +133,10 @@ class CONTENT_EXPORT NavigationRequest
@@ -106,10 +106,10 @@ index 63cc56b13dd9831a220544151a5aaa0d1e8cf0f5..6fabf7ff363ab8bf9966e8a5d99217e6
READY_TO_COMMIT,
diff --git a/content/browser/renderer_host/render_frame_host_manager.cc b/content/browser/renderer_host/render_frame_host_manager.cc
index 8c5937f1d4caab2d2554269be0bfee10925ddf7e..f276a55a8e097a63f02e7a038667ec381d331224 100644
index 3b3b825f738b1b50974603d4a801aa2e2717b286..5818a15007baa8d1a078c0ddc9d30e00984876cf 100644
--- a/content/browser/renderer_host/render_frame_host_manager.cc
+++ b/content/browser/renderer_host/render_frame_host_manager.cc
@@ -2703,6 +2703,16 @@ scoped_refptr<SiteInstance>
@@ -2726,6 +2726,16 @@ scoped_refptr<SiteInstance>
RenderFrameHostManager::GetSiteInstanceForNavigationRequest(
NavigationRequest* request,
std::string* reason) {
@@ -126,7 +126,7 @@ index 8c5937f1d4caab2d2554269be0bfee10925ddf7e..f276a55a8e097a63f02e7a038667ec38
SiteInstance* current_site_instance = render_frame_host_->GetSiteInstance();
// All children of MHTML documents must be MHTML documents. They all live in
@@ -2730,10 +2740,60 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest(
@@ -2753,10 +2763,60 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest(
//
// TODO(clamy): We should also consider as a candidate SiteInstance the
// speculative SiteInstance that was computed on redirects.
@@ -191,7 +191,7 @@ index 8c5937f1d4caab2d2554269be0bfee10925ddf7e..f276a55a8e097a63f02e7a038667ec38
// Account for renderer-initiated reload as well.
// Needed as a workaround for https://crbug.com/1045524, remove it when it is
@@ -2773,6 +2833,9 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest(
@@ -2796,6 +2856,9 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest(
request->ResetStateForSiteInstanceChange();
}
@@ -202,10 +202,10 @@ index 8c5937f1d4caab2d2554269be0bfee10925ddf7e..f276a55a8e097a63f02e7a038667ec38
}
diff --git a/content/browser/site_instance_impl.cc b/content/browser/site_instance_impl.cc
index 34f32197686fbb350a065cb2ce554a7b4ae917b5..7196c8a8b1be2d4e3496de2de1e8f62430696021 100644
index b0903d9cd7ef9ca15bc32d230b6003a2bfb4c3d9..9da9ae8b51010b9bbf5c62ec810ffd0bc145dad5 100644
--- a/content/browser/site_instance_impl.cc
+++ b/content/browser/site_instance_impl.cc
@@ -742,6 +742,10 @@ bool SiteInstanceImpl::HasRelatedSiteInstance(const SiteInfo& site_info) {
@@ -755,6 +755,10 @@ bool SiteInstanceImpl::HasRelatedSiteInstance(const SiteInfo& site_info) {
return browsing_instance_->HasSiteInstance(site_info);
}
@@ -217,10 +217,10 @@ index 34f32197686fbb350a065cb2ce554a7b4ae917b5..7196c8a8b1be2d4e3496de2de1e8f624
const GURL& url) {
return GetRelatedSiteInstanceImpl(
diff --git a/content/browser/site_instance_impl.h b/content/browser/site_instance_impl.h
index 3dc0f0cf7f3e9b9e75cf053817e9ac5fba0182bc..16759a044e24ac3c0719a57e196fbf3e2975f1b9 100644
index 1d79bf9261aad6e649a029257f7e6848cc34ad69..64cd5e188786ed60e474aeb1cabacd3d85069ae0 100644
--- a/content/browser/site_instance_impl.h
+++ b/content/browser/site_instance_impl.h
@@ -321,6 +321,7 @@ class CONTENT_EXPORT SiteInstanceImpl final : public SiteInstance,
@@ -323,6 +323,7 @@ class CONTENT_EXPORT SiteInstanceImpl final : public SiteInstance,
BrowserContext* GetBrowserContext() override;
const GURL& GetSiteURL() override;
scoped_refptr<SiteInstance> GetRelatedSiteInstance(const GURL& url) override;
@@ -229,7 +229,7 @@ index 3dc0f0cf7f3e9b9e75cf053817e9ac5fba0182bc..16759a044e24ac3c0719a57e196fbf3e
size_t GetRelatedActiveContentsCount() override;
bool RequiresDedicatedProcess() override;
diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc
index e485c81b2c6335b958983602a8b0e3d84fff5ab4..9fd15de448372693e7792aeee0ae1eb51fbe158e 100644
index d1c4beb5f3a8e1fb5dfc7d1d31df9a236e3ade8e..e3279ca97116ea2d6757a2561668692bae8ec8aa 100644
--- a/content/public/browser/content_browser_client.cc
+++ b/content/public/browser/content_browser_client.cc
@@ -65,6 +65,21 @@
@@ -255,12 +255,12 @@ index e485c81b2c6335b958983602a8b0e3d84fff5ab4..9fd15de448372693e7792aeee0ae1eb5
const MainFunctionParams& parameters) {
return nullptr;
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
index d92cfc2b18881a4d48cc4bd8340d6a84b8469c77..b5a1596632f135a52a24f4d90c34aa79defd1d4d 100644
index d42c4f7a76f78f1590451691909066e86f29e809..2ed3eae7909ba40733dd89a3cff9cfe44c29ab33 100644
--- a/content/public/browser/content_browser_client.h
+++ b/content/public/browser/content_browser_client.h
@@ -255,8 +255,45 @@ class CONTENT_EXPORT ContentBrowserClient {
using IsClipboardPasteAllowedCallback =
base::OnceCallback<void(ClipboardPasteAllowed)>;
using IsClipboardPasteContentAllowedCallback =
base::OnceCallback<void(ClipboardPasteContentAllowed)>;
+ // Identifies the type of site instance to use for a navigation.
+ enum SiteInstanceForNavigationType {

View File

@@ -0,0 +1,40 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Mon, 8 Mar 2021 16:27:39 -0800
Subject: moves background_color setter of WebView to blinks webprefs logic
background_color can be updated at runtime, as such we need to apply the
new background color to the WebView in the ApplyPreferences method.
There is no current way to attach an observer to these prefs so patching
is our only option.
Ideally we could add an embedder observer pattern here but that can be
done in future work.
diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc
index 755d037d6f5046d4641b6532918125d1ca84cdd8..adeb4845fe5f8516cb4d2ed36cb59bb26d714b9b 100644
--- a/third_party/blink/renderer/core/exported/web_view_impl.cc
+++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
@@ -154,6 +154,7 @@
#include "third_party/blink/renderer/core/timing/dom_window_performance.h"
#include "third_party/blink/renderer/core/timing/window_performance.h"
#include "third_party/blink/renderer/platform/fonts/font_cache.h"
+#include "third_party/blink/renderer/platform/graphics/color.h"
#include "third_party/blink/renderer/platform/graphics/image.h"
#include "third_party/blink/renderer/platform/graphics/paint/cull_rect.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_record_builder.h"
@@ -1752,6 +1753,14 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs,
RuntimeEnabledFeatures::SetTranslateServiceEnabled(
prefs.translate_service_available);
+
+ SkColor color = SK_ColorTRANSPARENT;
+ if (!prefs.guest_instance_id) { // not inside electron <webview /> tag, which is always transparent.
+ Color blink_color;
+ if (blink_color.SetFromString(WebString::FromASCII(prefs.background_color)))
+ color = static_cast<SkColor>(blink_color);
+ }
+ web_view->SetBaseBackgroundColor(color);
}
void WebViewImpl::ThemeChanged() {

View File

@@ -181,7 +181,7 @@ index db667e13f2e4d9e96e9ac28f17c61412d6279ec7..103958bba8a41b217bbaf4d8899fec3a
#if BUILDFLAG(IS_CT_SUPPORTED)
if (params_->enforce_chrome_ct_policy) {
diff --git a/services/network/network_context.h b/services/network/network_context.h
index f4888484d864abd8a1fd0cb68045843168825279..e7fc843b99e309234df35122a46e324fae81f4e3 100644
index 707cf9a7db7b81da9affef0c9ab4a934f5fd69c9..494d68d7f399152a08dd74ee4aa2d17baec81dd8 100644
--- a/services/network/network_context.h
+++ b/services/network/network_context.h
@@ -90,6 +90,7 @@ class DomainReliabilityMonitor;
@@ -201,7 +201,7 @@ index f4888484d864abd8a1fd0cb68045843168825279..e7fc843b99e309234df35122a46e324f
void ResetURLLoaderFactories() override;
void GetCookieManager(
mojo::PendingReceiver<mojom::CookieManager> receiver) override;
@@ -699,6 +702,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext
@@ -692,6 +695,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext
CertVerifierWithTrustAnchors* cert_verifier_with_trust_anchors_ = nullptr;
#endif

View File

@@ -102,7 +102,7 @@ index 47a5b3c2a11ec595ff926df10f856ed3c5375c55..38769ab454b143a1f50d1291a363092c
}
diff --git a/chrome/browser/printing/print_view_manager_base.cc b/chrome/browser/printing/print_view_manager_base.cc
index ae1ab34986d15dcdb3e8db484e7b3cc9d8a2e4ab..7c20cf3c06bca2191be035ac9171ce5ea5ae56b7 100644
index 83849c57ba42f29ecb169958c91df2d81bdab9dc..3a7eff03f034e71d8f493b425ea2a922c1e6106d 100644
--- a/chrome/browser/printing/print_view_manager_base.cc
+++ b/chrome/browser/printing/print_view_manager_base.cc
@@ -29,10 +29,7 @@
@@ -152,7 +152,7 @@ index ae1ab34986d15dcdb3e8db484e7b3cc9d8a2e4ab..7c20cf3c06bca2191be035ac9171ce5e
RenderParamsFromPrintSettings(printer_query->settings(),
params->params.get());
params->params->document_cookie = printer_query->cookie();
@@ -346,12 +349,14 @@ PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents)
@@ -351,12 +354,14 @@ PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents)
: PrintManager(web_contents),
queue_(g_browser_process->print_job_manager()->queue()) {
DCHECK(queue_);
@@ -167,7 +167,7 @@ index ae1ab34986d15dcdb3e8db484e7b3cc9d8a2e4ab..7c20cf3c06bca2191be035ac9171ce5e
}
PrintViewManagerBase::~PrintViewManagerBase() {
@@ -359,7 +364,10 @@ PrintViewManagerBase::~PrintViewManagerBase() {
@@ -364,7 +369,10 @@ PrintViewManagerBase::~PrintViewManagerBase() {
DisconnectFromCurrentPrintJob();
}
@@ -179,7 +179,7 @@ index ae1ab34986d15dcdb3e8db484e7b3cc9d8a2e4ab..7c20cf3c06bca2191be035ac9171ce5e
DisconnectFromCurrentPrintJob();
// Don't print / print preview crashed tabs.
@@ -367,7 +375,14 @@ bool PrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh) {
@@ -372,7 +380,14 @@ bool PrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh) {
return false;
SetPrintingRFH(rfh);
@@ -195,7 +195,7 @@ index ae1ab34986d15dcdb3e8db484e7b3cc9d8a2e4ab..7c20cf3c06bca2191be035ac9171ce5e
return true;
}
@@ -488,9 +503,9 @@ void PrintViewManagerBase::StartLocalPrintJob(
@@ -493,9 +508,9 @@ void PrintViewManagerBase::StartLocalPrintJob(
void PrintViewManagerBase::UpdatePrintingEnabled() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// The Unretained() is safe because ForEachFrame() is synchronous.
@@ -208,7 +208,7 @@ index ae1ab34986d15dcdb3e8db484e7b3cc9d8a2e4ab..7c20cf3c06bca2191be035ac9171ce5e
}
void PrintViewManagerBase::NavigationStopped() {
@@ -607,12 +622,13 @@ void PrintViewManagerBase::DidPrintDocument(
@@ -612,12 +627,13 @@ void PrintViewManagerBase::DidPrintDocument(
void PrintViewManagerBase::GetDefaultPrintSettings(
GetDefaultPrintSettingsCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@@ -223,7 +223,7 @@ index ae1ab34986d15dcdb3e8db484e7b3cc9d8a2e4ab..7c20cf3c06bca2191be035ac9171ce5e
content::RenderFrameHost* render_frame_host =
print_manager_host_receivers_.GetCurrentTargetFrame();
@@ -628,11 +644,12 @@ void PrintViewManagerBase::UpdatePrintSettings(
@@ -633,11 +649,12 @@ void PrintViewManagerBase::UpdatePrintSettings(
base::Value job_settings,
UpdatePrintSettingsCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@@ -237,7 +237,7 @@ index ae1ab34986d15dcdb3e8db484e7b3cc9d8a2e4ab..7c20cf3c06bca2191be035ac9171ce5e
if (!job_settings.FindIntKey(kSettingPrinterType)) {
UpdatePrintSettingsReply(std::move(callback), nullptr, false);
return;
@@ -671,7 +688,7 @@ void PrintViewManagerBase::PrintingFailed(int32_t cookie) {
@@ -676,7 +693,7 @@ void PrintViewManagerBase::PrintingFailed(int32_t cookie) {
PrintManager::PrintingFailed(cookie);
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
@@ -246,7 +246,7 @@ index ae1ab34986d15dcdb3e8db484e7b3cc9d8a2e4ab..7c20cf3c06bca2191be035ac9171ce5e
#endif
ReleasePrinterQuery();
@@ -683,6 +700,11 @@ void PrintViewManagerBase::PrintingFailed(int32_t cookie) {
@@ -688,6 +705,11 @@ void PrintViewManagerBase::PrintingFailed(int32_t cookie) {
}
void PrintViewManagerBase::ShowInvalidPrinterSettingsError() {
@@ -258,7 +258,7 @@ index ae1ab34986d15dcdb3e8db484e7b3cc9d8a2e4ab..7c20cf3c06bca2191be035ac9171ce5e
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(&ShowWarningMessageBox,
l10n_util::GetStringUTF16(
@@ -752,9 +774,13 @@ void PrintViewManagerBase::OnNotifyPrintJobEvent(
@@ -757,9 +779,13 @@ void PrintViewManagerBase::OnNotifyPrintJobEvent(
content::NotificationService::NoDetails());
break;
}
@@ -274,7 +274,7 @@ index ae1ab34986d15dcdb3e8db484e7b3cc9d8a2e4ab..7c20cf3c06bca2191be035ac9171ce5e
NOTREACHED();
break;
}
@@ -852,8 +878,10 @@ bool PrintViewManagerBase::CreateNewPrintJob(
@@ -857,8 +883,10 @@ bool PrintViewManagerBase::CreateNewPrintJob(
DCHECK(!quit_inner_loop_);
DCHECK(query);
@@ -287,7 +287,7 @@ index ae1ab34986d15dcdb3e8db484e7b3cc9d8a2e4ab..7c20cf3c06bca2191be035ac9171ce5e
// We can't print if there is no renderer.
if (!web_contents()->GetMainFrame()->GetRenderViewHost() ||
@@ -877,8 +905,6 @@ bool PrintViewManagerBase::CreateNewPrintJob(
@@ -882,8 +910,6 @@ bool PrintViewManagerBase::CreateNewPrintJob(
print_job_->SetSource(source, /*source_id=*/"");
#endif
@@ -296,7 +296,7 @@ index ae1ab34986d15dcdb3e8db484e7b3cc9d8a2e4ab..7c20cf3c06bca2191be035ac9171ce5e
printing_succeeded_ = false;
return true;
}
@@ -927,14 +953,22 @@ void PrintViewManagerBase::ReleasePrintJob() {
@@ -932,14 +958,22 @@ void PrintViewManagerBase::ReleasePrintJob() {
content::RenderFrameHost* rfh = printing_rfh_;
printing_rfh_ = nullptr;
@@ -321,7 +321,7 @@ index ae1ab34986d15dcdb3e8db484e7b3cc9d8a2e4ab..7c20cf3c06bca2191be035ac9171ce5e
// Don't close the worker thread.
print_job_ = nullptr;
}
@@ -970,7 +1004,7 @@ bool PrintViewManagerBase::RunInnerMessageLoop() {
@@ -975,7 +1009,7 @@ bool PrintViewManagerBase::RunInnerMessageLoop() {
}
bool PrintViewManagerBase::OpportunisticallyCreatePrintJob(int cookie) {
@@ -385,7 +385,7 @@ index cc728c5e16864ddd227fbe7b0a0bfa9a941243c3..3a1754680cb033695a56a8152a585031
// Tells the RenderFrame to switch the CSS to print media type, render every
// requested page using the print preview document's frame/node, and then
diff --git a/components/printing/renderer/print_render_frame_helper.cc b/components/printing/renderer/print_render_frame_helper.cc
index b8b24528f562e03858e4e0e1a9c64f3e609dd4a8..426abe24c7b3e57220364427e1fe097dc1e4ff55 100644
index c744a25d3414c1f10cf5abba4379923a07188bdb..0a7fece33fcbf560263912a92907502760f78b4e 100644
--- a/components/printing/renderer/print_render_frame_helper.cc
+++ b/components/printing/renderer/print_render_frame_helper.cc
@@ -38,6 +38,7 @@
@@ -516,7 +516,7 @@ index b8b24528f562e03858e4e0e1a9c64f3e609dd4a8..426abe24c7b3e57220364427e1fe097d
// Check if |this| is still valid.
if (!self)
return;
@@ -2107,7 +2148,9 @@ void PrintRenderFrameHelper::IPCProcessed() {
@@ -2112,7 +2153,9 @@ void PrintRenderFrameHelper::IPCProcessed() {
}
}
@@ -527,7 +527,7 @@ index b8b24528f562e03858e4e0e1a9c64f3e609dd4a8..426abe24c7b3e57220364427e1fe097d
mojom::PrintPagesParams settings;
settings.params = mojom::PrintParams::New();
GetPrintManagerHost()->GetDefaultPrintSettings(&settings.params);
@@ -2131,12 +2174,14 @@ bool PrintRenderFrameHelper::InitPrintSettings(bool fit_to_paper_size) {
@@ -2136,12 +2179,14 @@ bool PrintRenderFrameHelper::InitPrintSettings(bool fit_to_paper_size) {
return result;
}
@@ -546,7 +546,7 @@ index b8b24528f562e03858e4e0e1a9c64f3e609dd4a8..426abe24c7b3e57220364427e1fe097d
notify_browser_of_print_failure_ = false;
GetPrintManagerHost()->ShowInvalidPrinterSettingsError();
return false;
@@ -2481,18 +2526,7 @@ void PrintRenderFrameHelper::RequestPrintPreview(PrintPreviewRequestType type) {
@@ -2486,18 +2531,7 @@ void PrintRenderFrameHelper::RequestPrintPreview(PrintPreviewRequestType type) {
}
bool PrintRenderFrameHelper::CheckForCancel() {

View File

@@ -43,7 +43,7 @@ index 3122722665f1e2e4796e9628486c8bea8fdf283e..a5d58e950b91431639fb14b0e6a9bd43
void RenderWidgetHostImpl::ShowContextMenuAtPoint(
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 3ea1b844a80f85da1d4e3c47d0a33d0e9eeb02ef..d20ce60c04007a83e412defbf525a756788bd0cc 100644
index bc54b385d792eaad00c13fe43e9be1536397c5d7..a2bce274bdd70c0481a1bc75d449bfadf7b91618 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -4119,6 +4119,12 @@ TextInputManager* WebContentsImpl::GetTextInputManager() {
@@ -60,7 +60,7 @@ index 3ea1b844a80f85da1d4e3c47d0a33d0e9eeb02ef..d20ce60c04007a83e412defbf525a756
RenderWidgetHostImpl* render_widget_host) {
return render_widget_host == GetMainFrame()->GetRenderWidgetHost();
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
index 4b09bb93269a9c9d25824992660c3613119ad3d4..90d4919d793b99f73a9bad85fbb0b41b380e8845 100644
index 84ecccc204ee33820b8a059219244a841d6d642f..357ba07b83577392a902203cd7ee50e0ba3d27dd 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
@@ -965,6 +965,7 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,

View File

@@ -52,10 +52,10 @@ Some alternatives to this patch:
None of these options seems like a substantial maintainability win over this patch to me (@nornagon).
diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn
index 5eeb0d0c2598bbcff4981dcb6f43cae82ec37c99..f2d498b5fa6811acf62996b9b048aed5210ce8bb 100644
index c28309a07dd643523e4a6d52bf90a9291a521399..090c87ddaf8e0506ba23110fb3f93aef95f1df9a 100644
--- a/chrome/BUILD.gn
+++ b/chrome/BUILD.gn
@@ -1416,7 +1416,7 @@ if (is_chrome_branded && !is_android) {
@@ -1417,7 +1417,7 @@ if (is_chrome_branded && !is_android) {
}
}
@@ -64,7 +64,7 @@ index 5eeb0d0c2598bbcff4981dcb6f43cae82ec37c99..f2d498b5fa6811acf62996b9b048aed5
chrome_paks("packed_resources") {
if (is_mac) {
output_dir = "$root_gen_dir/repack"
@@ -1436,6 +1436,12 @@ if (!is_android) {
@@ -1437,6 +1437,12 @@ if (!is_android) {
}
}

View File

@@ -9,7 +9,7 @@ is needed for OSR.
Originally landed in https://github.com/electron/libchromiumcontent/pull/226.
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 81ecd2d06104aa125c95d40336e8192ec23a1206..3ea1b844a80f85da1d4e3c47d0a33d0e9eeb02ef 100644
index eac2487f18332616b1550bd7fa1f39f5c532b079..bc54b385d792eaad00c13fe43e9be1536397c5d7 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -2725,6 +2725,12 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {

File diff suppressed because it is too large Load Diff

View File

@@ -15,7 +15,5 @@
"src/electron/patches/depot_tools": "src/third_party/depot_tools",
"src/electron/patches/icu": "src/third_party/icu",
"src/electron/patches/nan": "src/third_party/nan"
}

View File

@@ -1 +0,0 @@
fix_apply_tzdata2020f_to_icu.patch

File diff suppressed because it is too large Load Diff

View File

@@ -16,7 +16,6 @@ build_modify_js2c_py_to_allow_injection_of_original-fs_and_custom_embedder_js.pa
refactor_allow_embedder_overriding_of_internal_fs_calls.patch
chore_prevent_warn_non_context-aware_native_modules_being_loaded.patch
chore_read_nobrowserglobals_from_global_not_process.patch
build_bring_back_node_with_ltcg_configuration.patch
revert_crypto_add_oaeplabel_option.patch
enable_31_bit_smis_on_64bit_arch_and_ptr_compression.patch
fix_use_crypto_impls_for_compat.patch
@@ -31,4 +30,4 @@ allow_preventing_preparestacktracecallback.patch
fix_add_safeforterminationscopes_for_sigint_interruptions.patch
remove_makeexternal_case_for_uncached_internal_strings.patch
fix_remove_outdated_--experimental-wasm-bigint_flag.patch
darwin_libuv_use_posix_spawn.patch
fix_parallel_test-crypto-ecdh-convert-key_to_use_compatible_group.patch

View File

@@ -846,10 +846,10 @@ index 0000000000000000000000000000000000000000..2c9d2826c85bdd033f1df1d6188df636
+}
diff --git a/filenames.json b/filenames.json
new file mode 100644
index 0000000000000000000000000000000000000000..9480edd9b00591e7aad7f764a409b86094e4cd5d
index 0000000000000000000000000000000000000000..2dfbb6aae48b65312f212ab01474763d5a796a23
--- /dev/null
+++ b/filenames.json
@@ -0,0 +1,530 @@
@@ -0,0 +1,538 @@
+// This file is automatically generated by generate_gn_filenames_json.py
+// DO NOT EDIT
+{
@@ -874,7 +874,9 @@ index 0000000000000000000000000000000000000000..9480edd9b00591e7aad7f764a409b860
+ "//v8/include/cppgc/cross-thread-persistent.h",
+ "//v8/include/cppgc/custom-space.h",
+ "//v8/include/cppgc/default-platform.h",
+ "//v8/include/cppgc/ephemeron-pair.h",
+ "//v8/include/cppgc/garbage-collected.h",
+ "//v8/include/cppgc/heap-consistency.h",
+ "//v8/include/cppgc/heap.h",
+ "//v8/include/cppgc/liveness-broker.h",
+ "//v8/include/cppgc/macros.h",
@@ -916,6 +918,7 @@ index 0000000000000000000000000000000000000000..9480edd9b00591e7aad7f764a409b860
+ "//v8/include/v8-metrics.h",
+ "//v8/include/v8-platform.h",
+ "//v8/include/v8-profiler.h",
+ "//v8/include/v8-unwinder-state.h",
+ "//v8/include/v8-util.h",
+ "//v8/include/v8-value-serializer-version.h",
+ "//v8/include/v8-version-string.h",
@@ -1160,6 +1163,11 @@ index 0000000000000000000000000000000000000000..9480edd9b00591e7aad7f764a409b860
+ "lib/internal/streams/duplexpair.js",
+ "lib/internal/streams/from.js",
+ "lib/internal/streams/legacy.js",
+ "lib/internal/streams/readable.js",
+ "lib/internal/streams/writable.js",
+ "lib/internal/streams/duplex.js",
+ "lib/internal/streams/passthrough.js",
+ "lib/internal/streams/transform.js",
+ "lib/internal/streams/destroy.js",
+ "lib/internal/streams/state.js",
+ "lib/internal/streams/pipeline.js",
@@ -1181,7 +1189,6 @@ index 0000000000000000000000000000000000000000..9480edd9b00591e7aad7f764a409b860
+ "deps/acorn/acorn/dist/acorn.js",
+ "deps/acorn/acorn-walk/dist/walk.js",
+ "deps/acorn-plugins/acorn-class-fields/index.js",
+ "deps/acorn-plugins/acorn-numeric-separator/index.js",
+ "deps/acorn-plugins/acorn-private-class-elements/index.js",
+ "deps/acorn-plugins/acorn-private-methods/index.js",
+ "deps/acorn-plugins/acorn-static-class-features/index.js",
@@ -1290,6 +1297,7 @@ index 0000000000000000000000000000000000000000..9480edd9b00591e7aad7f764a409b860
+ "src/base_object.h",
+ "src/base_object-inl.h",
+ "src/base64.h",
+ "src/base64-inl.h",
+ "src/callback_queue.h",
+ "src/callback_queue-inl.h",
+ "src/connect_wrap.h",
@@ -1586,7 +1594,7 @@ index 0000000000000000000000000000000000000000..f3c5c798c0aefcb8cf9b1570a7b4817c
+ args = rebase_path(inputs + outputs, root_build_dir)
+}
diff --git a/src/node_version.h b/src/node_version.h
index 20855d5807e0326118a10ccffe694af2e67d8b79..33422dd4eca758c08de679ac4cb5eba83b7ce145 100644
index 0f72abc0bf0302e1f535f71803f5aa063424f8b9..c6a76e408312d8fcfc4849082727331948e710b3 100644
--- a/src/node_version.h
+++ b/src/node_version.h
@@ -89,7 +89,10 @@
@@ -1725,10 +1733,10 @@ index 0000000000000000000000000000000000000000..3088ae4bdf814ae255c9805ebd393b2e
+
+ out_file.writelines(new_contents)
diff --git a/tools/install.py b/tools/install.py
index 655802980a6ea94d1d4ca1dc63c8c8e905fbb83a..ab1a18a215cb7393310324c6dbcacc6655bae9ef 100755
index 729b416fc47d3ff3317ae3671dee977c719a8841..530ca7d441d3b65d4e4fac7dd5880afe56aa3807 100755
--- a/tools/install.py
+++ b/tools/install.py
@@ -163,8 +163,8 @@ def files(action):
@@ -159,8 +159,8 @@ def files(action):
def headers(action):
def ignore_inspector_headers(files_arg, dest):
inspector_headers = [
@@ -1739,7 +1747,7 @@ index 655802980a6ea94d1d4ca1dc63c8c8e905fbb83a..ab1a18a215cb7393310324c6dbcacc66
]
files_arg = [name for name in files_arg if name not in inspector_headers]
action(files_arg, dest)
@@ -186,7 +186,7 @@ def headers(action):
@@ -182,7 +182,7 @@ def headers(action):
if sys.platform.startswith('aix'):
action(['out/Release/node.exp'], 'include/node/')
@@ -1749,7 +1757,7 @@ index 655802980a6ea94d1d4ca1dc63c8c8e905fbb83a..ab1a18a215cb7393310324c6dbcacc66
if 'false' == variables.get('node_shared_libuv'):
subdir_files('deps/uv/include', 'include/node/', action)
diff --git a/tools/js2c.py b/tools/js2c.py
index 195e6a6189a98916bcfb7abb1b73595b8bc8eb38..d5109fcae5542730623f5ec3ca244ec0973109f2 100755
index 0f073e182bdb2858957e4b28ae15b366d7933dbe..93e9474297fd9032981786ae9d4e005f2d1a9a2e 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -130,6 +130,14 @@ def NormalizeFileName(filename):

View File

@@ -1,51 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Deepak Mohan <hop2deep@gmail.com>
Date: Wed, 16 Oct 2019 13:41:12 -0700
Subject: build: bring back node_with_ltcg configuration
This was moved to code node.gyp as part of https://github.com/nodejs/node/pull/25931
which caused native modules size increase which were depending on
this configuration transitively https://github.com/nodejs/node/issues/29501.
THe fix for this should land in node-gyp as discussed in above issue,
landing this as temporary patch.
diff --git a/common.gypi b/common.gypi
index 81568d5afabd6d80b4df445124ccd7108801769d..463adbfdd8fb3af5d19ed30461eae46fd647de1a 100644
--- a/common.gypi
+++ b/common.gypi
@@ -19,7 +19,7 @@
'node_use_v8_platform%': 'true',
'node_use_bundled_v8%': 'true',
'node_module_version%': '',
- 'node_with_ltcg%': '',
+ 'node_with_ltcg%': 'true',
'node_shared_openssl%': 'false',
'node_tag%': '',
@@ -232,6 +232,26 @@
'cflags': [ '-fPIC' ],
'ldflags': [ '-fPIC' ]
}],
+ ['node_with_ltcg=="true"', {
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'WholeProgramOptimization': 'true' # /GL, whole program optimization, needed for LTCG
+ },
+ 'VCLibrarianTool': {
+ 'AdditionalOptions': [
+ '/LTCG:INCREMENTAL', # incremental link-time code generation
+ ]
+ },
+ 'VCLinkerTool': {
+ 'OptimizeReferences': 2, # /OPT:REF
+ 'EnableCOMDATFolding': 2, # /OPT:ICF
+ 'LinkIncremental': 1, # disable incremental linking
+ 'AdditionalOptions': [
+ '/LTCG:INCREMENTAL', # incremental link-time code generation
+ ]
+ }
+ }
+ }]
],
'msvs_settings': {
'VCCLCompilerTool': {

View File

@@ -38,7 +38,7 @@ index 3be3f2364dd252bcdd668c699a0e7ae1e754e873..b2af1bce312ffca44e7005e11f92327e
bool Exists(const char* id);
diff --git a/tools/js2c.py b/tools/js2c.py
index d5109fcae5542730623f5ec3ca244ec0973109f2..b25a9038ea7cfdb49b81e85f5bf497cc360e2b9e 100755
index 93e9474297fd9032981786ae9d4e005f2d1a9a2e..bca4c44a31d1ffe7c9ae15b6f60cd55e325f707d 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -38,6 +38,8 @@ import functools
@@ -129,7 +129,7 @@ index d5109fcae5542730623f5ec3ca244ec0973109f2..b25a9038ea7cfdb49b81e85f5bf497cc
write_if_chaged(out, target)
@@ -209,17 +228,21 @@ def main():
@@ -211,17 +230,21 @@ def main():
)
parser.add_argument('--target', help='output file')
parser.add_argument('--verbose', action='store_true', help='output file')

View File

@@ -8,12 +8,12 @@ once we stop warning and begin to unilaterally prevent non-context aware modules
from being loaded.
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js
index 1b781fb8193002e111d8904e44ca66dbec9daaac..3f80a6e4c03a51d40c25717baab5c690c53abccd 100644
index af69dfc9e71b54a9d7eda0daa498396008aba610..f52e8a09f689bafcfdca39e71822ff3cbf898349 100644
--- a/lib/internal/bootstrap/pre_execution.js
+++ b/lib/internal/bootstrap/pre_execution.js
@@ -93,10 +93,12 @@ function patchProcessObject(expandArgv1) {
if (expandArgv1 && process.argv[1] && !process.argv[1].startsWith('-')) {
@@ -95,10 +95,12 @@ function patchProcessObject(expandArgv1) {
if (expandArgv1 && process.argv[1] &&
!StringPrototypeStartsWith(process.argv[1], '-')) {
// Expand process.argv[1] into a full path.
- const path = require('path');
- try {
@@ -113,7 +113,7 @@ index ca5a01f925a2ae69ba4295d82316e546f45c60cd..f85ab2332a1c0267bd50d5f979d90e55
}
mp->nm_dso_handle = dlib->handle_;
diff --git a/src/node_options.cc b/src/node_options.cc
index 87f547da1de1c4b0d5913f0af461ee229b18aa02..c12ec1d13864b1aca227aa06b75339c14ebc5b4e 100644
index e7dc220f5c3fcab40c9a669a79b3a41b7e9f8cbf..01143e122387db8220d6e0cd0124ae08e082d0c8 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -371,6 +371,10 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {

View File

@@ -7,10 +7,10 @@ This is used so that we can modify the flag at runtime where
config can only be set at compile time.
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
index e1f70addc28e4fe31d3a7089ecec3b5874dde75a..659145e31bbfb6ce782e8dcad452b59202df7573 100644
index 5aab40071b68affe602be16d451be598b246faa1..6a55064eac76ee88d3b0b734d4f242da80aca119 100644
--- a/lib/internal/bootstrap/node.js
+++ b/lib/internal/bootstrap/node.js
@@ -118,7 +118,7 @@ const {
@@ -119,7 +119,7 @@ const {
queueMicrotask
} = require('internal/process/task_queues');

View File

@@ -1,574 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Pat DeSantis <pdesantis3@gmail.com>
Date: Mon, 25 Jan 2021 15:53:44 -0500
Subject: darwin,libuv: use posix_spawn
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur.
This patch is a cherry-pick of https://github.com/libuv/libuv/pull/3064. This patch should be removed when Electron's libuv version is updated to a version containing this fix.
Fixes: https://github.com/libuv/libuv/issues/3050
Fixes: https://github.com/electron/electron/issues/26143
PR-URL: https://github.com/libuv/libuv/pull/3064
Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com>
Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com>
Electron patch prepared by: Pat DeSantis <pdesantis3@gmail.com>
diff --git a/deps/uv/src/unix/process.c b/deps/uv/src/unix/process.c
index b021aaeba87d0b466341f40a016ef69e8beb7543..b4e44b049f5da2eccb051a6ec0403f5a401636d3 100644
--- a/deps/uv/src/unix/process.c
+++ b/deps/uv/src/unix/process.c
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
+#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
@@ -34,8 +35,20 @@
#include <poll.h>
#if defined(__APPLE__) && !TARGET_OS_IPHONE
+# include <spawn.h>
+# include <paths.h>
+# include <sys/kauth.h>
+# include <sys/types.h>
+# include <sys/sysctl.h>
+# include <dlfcn.h>
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
+
+/* macOS 10.14 back does not define this constant */
+# ifndef POSIX_SPAWN_SETSID
+# define POSIX_SPAWN_SETSID 1024
+# endif
+
#else
extern char **environ;
#endif
@@ -44,7 +57,6 @@ extern char **environ;
# include <grp.h>
#endif
-
static void uv__chld(uv_signal_t* handle, int signum) {
uv_process_t* process;
uv_loop_t* loop;
@@ -364,9 +376,8 @@ static void uv__process_child_init(const uv_process_options_t* options,
_exit(127);
}
- if (options->env != NULL) {
+ if (options->env != NULL)
environ = options->env;
- }
/* Reset signal disposition. Use a hard-coded limit because NSIG
* is not fixed on Linux: it's either 32, 34 or 64, depending on
@@ -405,6 +416,476 @@ static void uv__process_child_init(const uv_process_options_t* options,
#endif
+#if defined(__APPLE__)
+typedef struct uv__posix_spawn_fncs_tag {
+ struct {
+ int (*set_uid_np)(const posix_spawnattr_t *, uid_t);
+ int (*set_gid_np)(const posix_spawnattr_t *, gid_t);
+ int (*set_groups_np)(const posix_spawnattr_t*, int, gid_t*, uid_t);
+ } spawnattr;
+
+ struct {
+ int (*addchdir_np)(const posix_spawn_file_actions_t *, const char *);
+ } file_actions;
+} uv__posix_spawn_fncs_t;
+
+
+static uv_once_t posix_spawn_init_once = UV_ONCE_INIT;
+static uv__posix_spawn_fncs_t posix_spawn_fncs;
+static int posix_spawn_can_use_setsid;
+
+
+void uv__spawn_init_posix_spawn_fncs(void) {
+ /* Try to locate all non-portable functions at runtime */
+ posix_spawn_fncs.spawnattr.set_uid_np =
+ dlsym(RTLD_DEFAULT, "posix_spawnattr_set_uid_np");
+ posix_spawn_fncs.spawnattr.set_gid_np =
+ dlsym(RTLD_DEFAULT, "posix_spawnattr_set_gid_np");
+ posix_spawn_fncs.spawnattr.set_groups_np =
+ dlsym(RTLD_DEFAULT, "posix_spawnattr_set_groups_np");
+ posix_spawn_fncs.file_actions.addchdir_np =
+ dlsym(RTLD_DEFAULT, "posix_spawn_file_actions_addchdir_np");
+}
+
+
+void uv__spawn_init_can_use_setsid(void) {
+ static const int MACOS_CATALINA_VERSION_MAJOR = 19;
+ char version_str[256];
+ char* version_major_str;
+ size_t version_str_size = 256;
+ int r;
+ int version_major;
+
+ /* By default, assume failure */
+ posix_spawn_can_use_setsid = 0;
+
+ /* Get a version string */
+ r = sysctlbyname("kern.osrelease", version_str, &version_str_size, NULL, 0);
+ if (r != 0)
+ return;
+
+ /* Try to get the major version number. If not found
+ * fall back to the fork/exec flow */
+ version_major_str = strtok(version_str, ".");
+ if (version_major_str == NULL)
+ return;
+
+ /* Parse the version major as a number. If it is greater than
+ * the major version for macOS Catalina (aka macOS 10.15), then
+ * the POSIX_SPAWN_SETSID flag is available */
+ version_major = atoi(version_major_str);
+ if (version_major >= MACOS_CATALINA_VERSION_MAJOR)
+ posix_spawn_can_use_setsid = 1;
+}
+
+
+void uv__spawn_init_posix_spawn(void) {
+ /* Init handles to all potentially non-defined functions */
+ uv__spawn_init_posix_spawn_fncs();
+
+ /* Init feature detection for POSIX_SPAWN_SETSID flag */
+ uv__spawn_init_can_use_setsid();
+}
+
+
+int uv__spawn_set_posix_spawn_attrs(posix_spawnattr_t* attrs,
+ const uv__posix_spawn_fncs_t* posix_spawn_fncs,
+ const uv_process_options_t* options) {
+ int err;
+ unsigned int flags;
+ sigset_t signal_set;
+
+ err = posix_spawnattr_init(attrs);
+ if (err != 0) {
+ /* If initialization fails, no need to de-init, just return */
+ return err;
+ }
+
+ if (options->flags & UV_PROCESS_SETUID) {
+ if (posix_spawn_fncs->spawnattr.set_uid_np == NULL) {
+ err = ENOSYS;
+ goto error;
+ }
+
+ err = posix_spawn_fncs->spawnattr.set_uid_np(attrs, options->uid);
+ if (err != 0)
+ goto error;
+ }
+
+ if (options->flags & UV_PROCESS_SETGID) {
+ if (posix_spawn_fncs->spawnattr.set_gid_np == NULL) {
+ err = ENOSYS;
+ goto error;
+ }
+
+ err = posix_spawn_fncs->spawnattr.set_gid_np(attrs, options->gid);
+ if (err != 0)
+ goto error;
+ }
+
+ if (options->flags & (UV_PROCESS_SETUID | UV_PROCESS_SETGID)) {
+ /* Using ngroups = 0 implied the group_array is empty, and so
+ * its contents are never traversed. Still the
+ * posix_spawn_set_groups_np function seems to require that the
+ * group_array pointer be non-null */
+ const int ngroups = 0;
+ gid_t group_array = KAUTH_GID_NONE;
+
+ if (posix_spawn_fncs->spawnattr.set_groups_np == NULL) {
+ err = ENOSYS;
+ goto error;
+ }
+
+ /* See the comment on the call to setgroups in uv__process_child_init above
+ * for why this is not a fatal error */
+ SAVE_ERRNO(posix_spawn_fncs->spawnattr.set_groups_np(
+ attrs,
+ ngroups,
+ &group_array,
+ KAUTH_UID_NONE));
+ }
+
+ /* Set flags for spawn behavior
+ * 1) POSIX_SPAWN_CLOEXEC_DEFAULT: (Apple Extension) All descriptors in
+ * the parent will be treated as if they had been created with O_CLOEXEC.
+ * The only fds that will be passed on to the child are those manipulated
+ * by the file actions
+ * 2) POSIX_SPAWN_SETSIGDEF: Signals mentioned in spawn-sigdefault in
+ * the spawn attributes will be reset to behave as their default
+ * 3) POSIX_SPAWN_SETSIGMASK: Signal mask will be set to the value of
+ * spawn-sigmask in attributes
+ * 4) POSIX_SPAWN_SETSID: Make the process a new session leader if a
+ * detached session was requested. */
+ flags = POSIX_SPAWN_CLOEXEC_DEFAULT |
+ POSIX_SPAWN_SETSIGDEF |
+ POSIX_SPAWN_SETSIGMASK;
+ if (options->flags & UV_PROCESS_DETACHED) {
+ /* If running on a version of macOS where this flag is not supported,
+ * revert back to the fork/exec flow. Otherwise posix_spawn will
+ * silently ignore the flag. */
+ if (!posix_spawn_can_use_setsid) {
+ err = ENOSYS;
+ goto error;
+ }
+
+ flags |= POSIX_SPAWN_SETSID;
+ }
+ err = posix_spawnattr_setflags(attrs, flags);
+ if (err != 0)
+ goto error;
+
+ /* Reset all signal the child to their default behavior */
+ sigfillset(&signal_set);
+ err = posix_spawnattr_setsigdefault(attrs, &signal_set);
+ if (err != 0)
+ goto error;
+
+ /* Reset the signal mask for all signals */
+ sigemptyset(&signal_set);
+ err = posix_spawnattr_setsigmask(attrs, &signal_set);
+ if (err != 0)
+ goto error;
+
+ return err;
+
+error:
+ (void) posix_spawnattr_destroy(attrs);
+ return err;
+}
+
+
+int uv__spawn_set_posix_spawn_file_actions(posix_spawn_file_actions_t* actions,
+ const uv__posix_spawn_fncs_t* posix_spawn_fncs,
+ const uv_process_options_t* options,
+ int stdio_count,
+ int (*pipes)[2]) {
+ int fd;
+ int err;
+
+ err = posix_spawn_file_actions_init(actions);
+ if (err != 0) {
+ /* If initialization fails, no need to de-init, just return */
+ return err;
+ }
+
+ /* Set the current working directory if requested */
+ if (options->cwd != NULL) {
+ if (posix_spawn_fncs->file_actions.addchdir_np == NULL) {
+ err = ENOSYS;
+ goto error;
+ }
+
+ err = posix_spawn_fncs->file_actions.addchdir_np(actions, options->cwd);
+ if (err != 0)
+ goto error;
+ }
+
+ /* First, duplicate any required fd into orbit, out of the range of
+ * the descriptors that should be mapped in. */
+ for (fd = 0; fd < stdio_count; fd++) {
+ if (pipes[fd][1] < 0)
+ continue;
+
+ err = posix_spawn_file_actions_adddup2(
+ actions,
+ pipes[fd][1],
+ stdio_count + fd);
+ if (err != 0)
+ goto error;
+ }
+
+ /* Second, move the descriptors into their respective places */
+ for (fd = 0; fd < stdio_count; fd++) {
+ if (pipes[fd][1] < 0)
+ continue;
+
+ err = posix_spawn_file_actions_adddup2(actions, stdio_count + fd, fd);
+ if (err != 0)
+ goto error;
+ }
+
+ /* Finally, close all the superfluous descriptors */
+ for (fd = 0; fd < stdio_count; fd++) {
+ if (pipes[fd][1] < 0)
+ continue;
+
+ err = posix_spawn_file_actions_addclose(actions, stdio_count + fd);
+ if (err != 0)
+ goto error;
+ }
+
+ /* Finally process the standard streams as per documentation */
+ for (fd = 0; fd < 3; fd++) {
+ int oflags;
+ const int mode = 0;
+
+ oflags = fd == 0 ? O_RDONLY : O_RDWR;
+
+ if (pipes[fd][1] != -1) {
+ /* If not ignored, make sure the fd is marked as non-blocking */
+ uv__nonblock_fcntl(pipes[fd][1], 0);
+ } else {
+ /* If ignored, redirect to (or from) /dev/null, */
+ err = posix_spawn_file_actions_addopen(
+ actions,
+ fd,
+ "/dev/null",
+ oflags,
+ mode);
+ if (err != 0)
+ goto error;
+ }
+ }
+
+ return 0;
+
+error:
+ (void) posix_spawn_file_actions_destroy(actions);
+ return err;
+}
+
+char* uv__spawn_find_path_in_env(char** env) {
+ char** env_iterator;
+ const char path_var[] = "PATH=";
+
+ /* Look for an environment variable called PATH in the
+ * provided env array, and return its value if found */
+ for (env_iterator = env; *env_iterator != NULL; env_iterator++) {
+ if (strncmp(*env_iterator, path_var, sizeof(path_var) - 1) == 0) {
+ /* Found "PATH=" at the beginning of the string */
+ return *env_iterator + sizeof(path_var) - 1;
+ }
+ }
+
+ return NULL;
+}
+
+
+int uv__spawn_resolve_and_spawn(const uv_process_options_t* options,
+ posix_spawnattr_t* attrs,
+ posix_spawn_file_actions_t* actions,
+ pid_t* pid) {
+ const char *p;
+ const char *z;
+ const char *path;
+ size_t l;
+ size_t k;
+ int err;
+
+ path = NULL;
+ err = -1;
+
+ /* Short circuit for erroneous case */
+ if (options->file == NULL)
+ return ENOENT;
+
+ /* The environment for the child process is that of the parent unless overriden
+ * by options->env */
+ char** env = environ;
+ if (options->env != NULL)
+ env = options->env;
+
+ /* If options->file contains a slash, posix_spawn/posix_spawnp behave
+ * the same, and don't involve PATH resolution at all. Otherwise, if
+ * options->file does not include a slash, but no custom environment is
+ * to be used, the environment used for path resolution as well for the
+ * child process is that of the parent process, so posix_spawnp is the
+ * way to go. */
+ if (strchr(options->file, '/') != NULL || options->env == NULL)
+ return posix_spawnp(pid, options->file, actions, attrs, options->args, env);
+
+ /* Look for the definition of PATH in the provided env */
+ path = uv__spawn_find_path_in_env(options->env);
+
+ /* The following resolution logic (execvpe emulation) is taken from
+ * https://github.com/JuliaLang/libuv/commit/9af3af617138d6a6de7d72819ed362996ff255d9
+ * and adapted to work around our own situations */
+
+ /* If no path was provided in options->env, use the default value
+ * to look for the executable */
+ if (path == NULL)
+ path = _PATH_DEFPATH;
+
+ k = strnlen(options->file, NAME_MAX + 1);
+ if (k > NAME_MAX)
+ return ENAMETOOLONG;
+
+ l = strnlen(path, PATH_MAX - 1) + 1;
+
+ for (p = path;; p = z) {
+ /* Compose the new process file from the entry in the PATH
+ * environment variable and the actual file name */
+ char b[PATH_MAX + NAME_MAX];
+ z = strchr(p, ':');
+ if (!z)
+ z = p + strlen(p);
+ if ((size_t)(z - p) >= l) {
+ if (!*z++)
+ break;
+
+ continue;
+ }
+ memcpy(b, p, z - p);
+ b[z - p] = '/';
+ memcpy(b + (z - p) + (z > p), options->file, k + 1);
+
+ /* Try to spawn the new process file. If it fails with ENOENT, the
+ * new process file is not in this PATH entry, continue with the next
+ * PATH entry. */
+ err = posix_spawn(pid, b, actions, attrs, options->args, env);
+ if (err != ENOENT)
+ return err;
+
+ if (!*z++)
+ break;
+ }
+
+ return err;
+}
+
+
+int uv__spawn_and_init_child_posix_spawn(const uv_process_options_t* options,
+ int stdio_count,
+ int (*pipes)[2],
+ pid_t* pid,
+ const uv__posix_spawn_fncs_t* posix_spawn_fncs) {
+ int err;
+ posix_spawnattr_t attrs;
+ posix_spawn_file_actions_t actions;
+
+ err = uv__spawn_set_posix_spawn_attrs(&attrs, posix_spawn_fncs, options);
+ if (err != 0)
+ goto error;
+
+ err = uv__spawn_set_posix_spawn_file_actions(
+ &actions,
+ posix_spawn_fncs,
+ options,
+ stdio_count,
+ pipes);
+ if (err != 0) {
+ (void) posix_spawnattr_destroy(&attrs);
+ goto error;
+ }
+
+ /* Try to spawn options->file resolving in the provided environment
+ * if any */
+ err = uv__spawn_resolve_and_spawn(options, &attrs, &actions, pid);
+
+ /* Destroy the actions/attributes */
+ (void) posix_spawn_file_actions_destroy(&actions);
+ (void) posix_spawnattr_destroy(&attrs);
+
+error:
+ /* In an error situation, the attributes and file actions are
+ * already destroyed, only the happy path requires cleanup */
+ return UV__ERR(err);
+}
+#endif
+
+int uv__spawn_and_init_child_fork(const uv_process_options_t* options,
+ int stdio_count,
+ int (*pipes)[2],
+ int error_fd,
+ pid_t* pid) {
+ *pid = fork();
+
+ if (*pid == -1) {
+ /* Failed to fork */
+ return UV__ERR(errno);
+ }
+
+ if (*pid == 0) {
+ /* Fork succeeded, in the child process */
+ uv__process_child_init(options, stdio_count, pipes, error_fd);
+ abort();
+ }
+
+ /* Fork succeeded, in the parent process */
+ return 0;
+}
+
+int uv__spawn_and_init_child(const uv_process_options_t* options,
+ int stdio_count,
+ int (*pipes)[2],
+ int error_fd,
+ pid_t* pid) {
+ int err;
+
+#if defined(__APPLE__)
+ uv_once(&posix_spawn_init_once, uv__spawn_init_posix_spawn);
+
+ /* Special child process spawn case for macOS Big Sur (11.0) onwards
+ *
+ * Big Sur introduced a significant performance degradation on a call to
+ * fork/exec when the process has many pages mmaped in with MAP_JIT, like, say
+ * a javascript interpreter. Electron-based applications, for example,
+ * are impacted; though the magnitude of the impact depends on how much the
+ * app relies on subprocesses.
+ *
+ * On macOS, though, posix_spawn is implemented in a way that does not
+ * exhibit the problem. This block implements the forking and preparation
+ * logic with posix_spawn and its related primitives. It also takes advantage of
+ * the macOS extension POSIX_SPAWN_CLOEXEC_DEFAULT that makes impossible to
+ * leak descriptors to the child process. */
+ err = uv__spawn_and_init_child_posix_spawn(options,
+ stdio_count,
+ pipes,
+ pid,
+ &posix_spawn_fncs);
+
+ /* The posix_spawn flow will return UV_ENOSYS if any of the posix_spawn_x_np
+ * non-standard functions is both _needed_ and _undefined_. In those cases,
+ * default back to the fork/execve strategy. For all other errors, just fail. */
+ if (err != UV_ENOSYS)
+ return err;
+
+#endif
+ err = uv__spawn_and_init_child_fork(options, stdio_count, pipes, error_fd, pid);
+
+ return err;
+}
+
int uv_spawn(uv_loop_t* loop,
uv_process_t* process,
const uv_process_options_t* options) {
@@ -486,21 +967,16 @@ int uv_spawn(uv_loop_t* loop,
/* Acquire write lock to prevent opening new fds in worker threads */
uv_rwlock_wrlock(&loop->cloexec_lock);
- pid = fork();
- if (pid == -1) {
- err = UV__ERR(errno);
+ /* Spawn the child */
+ err = uv__spawn_and_init_child(options, stdio_count, pipes, signal_pipe[1], &pid);
+ if (err != 0) {
uv_rwlock_wrunlock(&loop->cloexec_lock);
uv__close(signal_pipe[0]);
uv__close(signal_pipe[1]);
goto error;
}
- if (pid == 0) {
- uv__process_child_init(options, stdio_count, pipes, signal_pipe[1]);
- abort();
- }
-
/* Release lock in parent process */
uv_rwlock_wrunlock(&loop->cloexec_lock);
uv__close(signal_pipe[1]);

View File

@@ -8,7 +8,7 @@ node modules will have different (wrong) ideas about how v8 structs are laid
out in memory on 64-bit machines, and will summarily fail to work.
diff --git a/common.gypi b/common.gypi
index 463adbfdd8fb3af5d19ed30461eae46fd647de1a..4d63ac7981edca3f99c05ce08af8ea41628b0387 100644
index d37d29736ead82aca6c89cc7625ca4d9a053da32..b6aa3c0504fd108ada368d30f3021d1c171a4879 100644
--- a/common.gypi
+++ b/common.gypi
@@ -64,7 +64,7 @@

View File

@@ -6,10 +6,10 @@ Subject: feat: initialize asar support
This patch initializes asar support in Node.js.
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js
index 9689e2a9edf69530546d5238155f6ea28dd70daf..1b781fb8193002e111d8904e44ca66dbec9daaac 100644
index c76add4621b614dd7dd4f4d369fb6ce7598ee22d..af69dfc9e71b54a9d7eda0daa498396008aba610 100644
--- a/lib/internal/bootstrap/pre_execution.js
+++ b/lib/internal/bootstrap/pre_execution.js
@@ -74,6 +74,7 @@ function prepareMainThreadExecution(expandArgv1 = false) {
@@ -75,6 +75,7 @@ function prepareMainThreadExecution(expandArgv1 = false) {
assert(!CJSLoader.hasLoadedAnyUserCJSModule);
loadPreloadModules();
initializeFrozenIntrinsics();
@@ -17,7 +17,7 @@ index 9689e2a9edf69530546d5238155f6ea28dd70daf..1b781fb8193002e111d8904e44ca66db
}
function patchProcessObject(expandArgv1) {
@@ -448,6 +449,10 @@ function loadPreloadModules() {
@@ -450,6 +451,10 @@ function loadPreloadModules() {
}
}

View File

@@ -8,7 +8,7 @@ common.gypi is a file that's included in the node header bundle, despite
the fact that we do not build node with gyp.
diff --git a/common.gypi b/common.gypi
index 4745bb5ac77639a97b30a9730d0ab990fdcca05e..81568d5afabd6d80b4df445124ccd7108801769d 100644
index e610650a01d4ab39f9595d11aac7f49d62bd27b7..d37d29736ead82aca6c89cc7625ca4d9a053da32 100644
--- a/common.gypi
+++ b/common.gypi
@@ -81,6 +81,22 @@

View File

@@ -6,7 +6,7 @@ Subject: fix: add v8_enable_reverse_jsargs defines in common.gypi
This can be removed once node upgrades V8 and inevitably has to do this exact same thing. Also hi node people if you are looking at this.
diff --git a/common.gypi b/common.gypi
index 4d63ac7981edca3f99c05ce08af8ea41628b0387..42d353c7495ff29a58a942ad72227ada8be662a9 100644
index b6aa3c0504fd108ada368d30f3021d1c171a4879..9a2552ab3c1ba44b57b2d3b1ddf2becaa32ebbda 100644
--- a/common.gypi
+++ b/common.gypi
@@ -65,6 +65,7 @@
@@ -25,7 +25,7 @@ index 4d63ac7981edca3f99c05ce08af8ea41628b0387..42d353c7495ff29a58a942ad72227ada
##### end V8 defaults #####
# When building native modules using 'npm install' with the system npm,
@@ -392,6 +394,9 @@
@@ -372,6 +374,9 @@
['v8_enable_pointer_compression == 1 or v8_enable_31bit_smis_on_64bit_arch == 1', {
'defines': ['V8_31BIT_SMIS_ON_64BIT_ARCH'],
}],

View File

@@ -9,7 +9,7 @@ with what's exposed through BoringSSL. I plan to upstream parts of this or
otherwise introduce shims to reduce friction.
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index 91cb94d8dbe9db0adbee5e005649188e1ccbcbf9..c3d12dc4cc18888815ff5e2c30a21974322d1faf 100644
index 91cb94d8dbe9db0adbee5e005649188e1ccbcbf9..2000c789d9daac835c0ecc1e4144179575c9b502 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -5192,11 +5192,11 @@ bool DiffieHellman::Init(int primeLength, int g) {
@@ -48,18 +48,16 @@ index 91cb94d8dbe9db0adbee5e005649188e1ccbcbf9..c3d12dc4cc18888815ff5e2c30a21974
return false;
}
BIGNUM* bn_p =
@@ -5718,8 +5718,9 @@ void ECDH::SetPrivateKey(const FunctionCallbackInfo<Value>& args) {
@@ -5719,7 +5719,7 @@ void ECDH::SetPrivateKey(const FunctionCallbackInfo<Value>& args) {
if (!EC_KEY_set_public_key(new_key.get(), pub.get()))
return env->ThrowError("Failed to set generated public key");
-
+#if 0
EC_KEY_copy(ecdh->key_.get(), new_key.get());
+#endif
- EC_KEY_copy(ecdh->key_.get(), new_key.get());
+ ecdh->key_.reset(EC_KEY_dup(new_key.get()));
ecdh->group_ = EC_KEY_get0_group(ecdh->key_.get());
}
@@ -6207,6 +6208,7 @@ class DHKeyPairGenerationConfig : public KeyPairGenerationConfig {
@@ -6207,6 +6207,7 @@ class DHKeyPairGenerationConfig : public KeyPairGenerationConfig {
EVPKeyCtxPointer Setup() override {
EVPKeyPointer params;
if (prime_info_.fixed_value_) {
@@ -67,7 +65,7 @@ index 91cb94d8dbe9db0adbee5e005649188e1ccbcbf9..c3d12dc4cc18888815ff5e2c30a21974
DHPointer dh(DH_new());
if (!dh)
return nullptr;
@@ -6223,6 +6225,7 @@ class DHKeyPairGenerationConfig : public KeyPairGenerationConfig {
@@ -6223,6 +6224,7 @@ class DHKeyPairGenerationConfig : public KeyPairGenerationConfig {
params = EVPKeyPointer(EVP_PKEY_new());
CHECK(params);
EVP_PKEY_assign_DH(params.get(), dh.release());
@@ -75,7 +73,7 @@ index 91cb94d8dbe9db0adbee5e005649188e1ccbcbf9..c3d12dc4cc18888815ff5e2c30a21974
} else {
EVPKeyCtxPointer param_ctx(EVP_PKEY_CTX_new_id(EVP_PKEY_DH, nullptr));
if (!param_ctx)
@@ -6230,7 +6233,7 @@ class DHKeyPairGenerationConfig : public KeyPairGenerationConfig {
@@ -6230,7 +6232,7 @@ class DHKeyPairGenerationConfig : public KeyPairGenerationConfig {
if (EVP_PKEY_paramgen_init(param_ctx.get()) <= 0)
return nullptr;
@@ -84,7 +82,7 @@ index 91cb94d8dbe9db0adbee5e005649188e1ccbcbf9..c3d12dc4cc18888815ff5e2c30a21974
if (EVP_PKEY_CTX_set_dh_paramgen_prime_len(param_ctx.get(),
prime_info_.prime_size_) <= 0)
return nullptr;
@@ -6238,7 +6241,7 @@ class DHKeyPairGenerationConfig : public KeyPairGenerationConfig {
@@ -6238,7 +6240,7 @@ class DHKeyPairGenerationConfig : public KeyPairGenerationConfig {
if (EVP_PKEY_CTX_set_dh_paramgen_generator(param_ctx.get(),
generator_) <= 0)
return nullptr;

View File

@@ -0,0 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Rose <nornagon@nornagon.net>
Date: Tue, 9 Feb 2021 11:59:08 -0800
Subject: fix parallel/test-crypto-ecdh-convert-key to use compatible group
This fixes a node crypto test to use an algorithm that's boringssl also
supports.
This should be upstreamed.
diff --git a/test/parallel/test-crypto-ecdh-convert-key.js b/test/parallel/test-crypto-ecdh-convert-key.js
index 69ee339aa7a653a8f2b4523bf8b28f1b2254c705..93074a42f770fb4d26c609520fa4c72f520c0d1b 100644
--- a/test/parallel/test-crypto-ecdh-convert-key.js
+++ b/test/parallel/test-crypto-ecdh-convert-key.js
@@ -117,7 +117,7 @@ if (getCurves().includes('secp256k1')) {
// rather than Node's generic error message.
const badKey = 'f'.repeat(128);
assert.throws(
- () => ECDH.convertKey(badKey, 'secp256k1', 'hex', 'hex', 'compressed'),
+ () => ECDH.convertKey(badKey, 'secp521r1', 'hex', 'hex', 'compressed'),
/Failed to convert Buffer to EC_POINT/);
// Next statement should not throw an exception.

View File

@@ -7,10 +7,10 @@ We use this to allow node's 'fs' module to read from ASAR files as if they were
a real filesystem.
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
index 6d6ca2af629c41df68fe1a4652cf94fef30be038..e1f70addc28e4fe31d3a7089ecec3b5874dde75a 100644
index 2705f8b50a658db0fc1ce6fba245792f6a567300..5aab40071b68affe602be16d451be598b246faa1 100644
--- a/lib/internal/bootstrap/node.js
+++ b/lib/internal/bootstrap/node.js
@@ -56,6 +56,10 @@ setupBuffer();
@@ -57,6 +57,10 @@ setupBuffer();
process.domain = null;
process._exiting = false;

View File

@@ -10,7 +10,7 @@ through MakeExternal - to fix this we make the strings bigger so as to
make then internal & external & not uncached (i.e. cached).
diff --git a/test/parallel/test-fs-write.js b/test/parallel/test-fs-write.js
index a6724eac300d16a36ca0e64788516adb9d6f6536..e152383b56c6f2791852d5f9fb151693c2d962a6 100644
index bdee397eb58dd2e5ca59dc1ec280e9e664ba23f9..c52c958a1fd1a5679f731a1360b0563d13fa7581 100644
--- a/test/parallel/test-fs-write.js
+++ b/test/parallel/test-fs-write.js
@@ -40,7 +40,7 @@ const constants = fs.constants;

View File

@@ -30,7 +30,7 @@ index e9235d17955089433ef27d3d10c1b5994862b550..d89a5bbed03d8782885b7b9c69d1513c
* Free the memory block of size |length|, pointed to by |data|.
* That memory is guaranteed to be previously allocated by |Allocate|.
diff --git a/src/api/api.cc b/src/api/api.cc
index 325a25fa1e37ff618c8ad57633c060d4e50d949f..39d877942bcf17a01b32c0e6325a47b798f81262 100644
index 9b19d155bd80c4df641713cf8891ca916497bc25..c9f15567632b08b6e334d17ad40b5758876a40c2 100644
--- a/src/api/api.cc
+++ b/src/api/api.cc
@@ -545,6 +545,10 @@ void V8::SetSnapshotDataBlob(StartupData* snapshot_blob) {

View File

@@ -6,10 +6,10 @@ Subject: dcheck.patch
https://github.com/auchenberg/volkswagen
diff --git a/src/api/api.cc b/src/api/api.cc
index 39d877942bcf17a01b32c0e6325a47b798f81262..68089eb223224ad8fcc695acefb914a6b400700b 100644
index c9f15567632b08b6e334d17ad40b5758876a40c2..204064661d68cc448b168d013519481869a237dc 100644
--- a/src/api/api.cc
+++ b/src/api/api.cc
@@ -9002,7 +9002,7 @@ void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) {
@@ -9003,7 +9003,7 @@ void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) {
}
void Isolate::PerformMicrotaskCheckpoint() {

View File

@@ -25,7 +25,6 @@
"parallel/test-crypto-des3-wrap",
"parallel/test-crypto-dh",
"parallel/test-crypto-ecb",
"parallel/test-crypto-ecdh-convert-key",
"parallel/test-crypto-engine",
"parallel/test-crypto-hash-stream-pipe",
"parallel/test-crypto-key-objects",

View File

@@ -1109,7 +1109,7 @@ void BaseWindow::ResetBrowserViews() {
// reset if the owner window is *this* window.
if (browser_view->web_contents()) {
auto* owner_window = browser_view->web_contents()->owner_window();
if (owner_window == window_.get()) {
if (owner_window && owner_window == window_.get()) {
browser_view->web_contents()->SetOwnerWindow(nullptr);
owner_window->RemoveBrowserView(browser_view->view());
}

View File

@@ -88,7 +88,6 @@
#include "shell/browser/electron_browser_main_parts.h"
#include "shell/browser/electron_javascript_dialog_manager.h"
#include "shell/browser/electron_navigation_throttle.h"
#include "shell/browser/lib/bluetooth_chooser.h"
#include "shell/browser/native_window.h"
#include "shell/browser/session_preferences.h"
#include "shell/browser/ui/drag_util.h"
@@ -1056,6 +1055,16 @@ void WebContents::AddNewContents(
v8::HandleScope handle_scope(isolate);
auto api_web_contents =
CreateAndTake(isolate, std::move(new_contents), Type::kBrowserWindow);
// We call RenderFrameCreated here as at this point the empty "about:blank"
// render frame has already been created. If the window never navigates again
// RenderFrameCreated won't be called and certain prefs like
// "kBackgroundColor" will not be applied.
auto* frame = api_web_contents->MainFrame();
if (frame) {
api_web_contents->HandleNewRenderFrame(frame);
}
if (Emit("-add-new-contents", api_web_contents, disposition, user_gesture,
initial_rect.x(), initial_rect.y(), initial_rect.width(),
initial_rect.height(), tracker->url, tracker->frame_name,
@@ -1074,7 +1083,7 @@ content::WebContents* WebContents::OpenURLFromTab(
return nullptr;
}
if (!weak_this)
if (!weak_this || !web_contents())
return nullptr;
content::NavigationController::LoadURLParams load_url_params(params.url);
@@ -1354,17 +1363,27 @@ void WebContents::BeforeUnloadFired(bool proceed,
// there are two virtual functions named BeforeUnloadFired.
}
void WebContents::RenderViewCreated(content::RenderViewHost* render_view_host) {
if (!background_throttling_)
render_view_host->SetSchedulerThrottling(false);
}
void WebContents::RenderFrameCreated(
void WebContents::HandleNewRenderFrame(
content::RenderFrameHost* render_frame_host) {
auto* rwhv = render_frame_host->GetView();
if (!rwhv)
return;
// Set the background color of RenderWidgetHostView.
auto* web_preferences = WebContentsPreferences::From(web_contents());
if (web_preferences) {
std::string color_name;
if (web_preferences->GetPreference(options::kBackgroundColor,
&color_name)) {
rwhv->SetBackgroundColor(ParseHexColor(color_name));
} else {
rwhv->SetBackgroundColor(SK_ColorTRANSPARENT);
}
}
if (!background_throttling_)
render_frame_host->GetRenderViewHost()->SetSchedulerThrottling(false);
auto* rwh_impl =
static_cast<content::RenderWidgetHostImpl*>(rwhv->GetRenderWidgetHost());
if (rwh_impl)
@@ -1373,6 +1392,11 @@ void WebContents::RenderFrameCreated(
WebFrameMain::RenderFrameCreated(render_frame_host);
}
void WebContents::RenderFrameCreated(
content::RenderFrameHost* render_frame_host) {
HandleNewRenderFrame(render_frame_host);
}
void WebContents::RenderViewDeleted(content::RenderViewHost* render_view_host) {
// This event is necessary for tracking any states with respect to
// intermediate render view hosts aka speculative render view hosts. Currently
@@ -1394,7 +1418,7 @@ void WebContents::RenderProcessGone(base::TerminationStatus status) {
Emit("crashed", status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED);
// User might destroy WebContents in the crashed event.
if (!weak_this)
if (!weak_this || !web_contents())
return;
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
@@ -1465,7 +1489,7 @@ void WebContents::DidFinishLoad(content::RenderFrameHost* render_frame_host,
// ⚠WARNING!⚠️
// Emit() triggers JS which can call destroy() on |this|. It's not safe to
// assume that |this| points to valid memory at this point.
if (is_main_frame && weak_this)
if (is_main_frame && weak_this && web_contents())
Emit("did-finish-load");
}
@@ -1854,6 +1878,7 @@ void WebContents::WebContentsDestroyed() {
// also do not want any method to be used, so just mark as destroyed here.
MarkDestroyed();
Observe(nullptr); // this->web_contents() will return nullptr
Emit("destroyed");
// For guest view based on OOPIF, the WebContents is released by the embedder
@@ -1985,26 +2010,11 @@ void WebContents::LoadURL(const GURL& url,
// ⚠WARNING!⚠️
// LoadURLWithParams() triggers JS events which can call destroy() on |this|.
// It's not safe to assume that |this| points to valid memory at this point.
if (!weak_this)
if (!weak_this || !web_contents())
return;
// Required to make beforeunload handler work.
NotifyUserActivation();
// Set the background color of RenderWidgetHostView.
// We have to call it right after LoadURL because the RenderViewHost is only
// created after loading a page.
auto* const view = weak_this->web_contents()->GetRenderWidgetHostView();
if (view) {
auto* web_preferences = WebContentsPreferences::From(web_contents());
std::string color_name;
if (web_preferences->GetPreference(options::kBackgroundColor,
&color_name)) {
view->SetBackgroundColor(ParseHexColor(color_name));
} else {
view->SetBackgroundColor(SK_ColorTRANSPARENT);
}
}
}
void WebContents::DownloadURL(const GURL& url) {
@@ -2812,6 +2822,18 @@ v8::Local<v8::Promise> WebContents::CapturePage(gin::Arguments* args) {
return handle;
}
#if !defined(OS_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()->GetMainFrame();
if (rfh &&
rfh->GetVisibilityState() == blink::mojom::PageVisibilityState::kHidden) {
promise.Resolve(gfx::Image());
return handle;
}
#endif // defined(OS_MAC)
// Capture full page if user doesn't specify a |rect|.
const gfx::Size view_size =
rect.IsEmpty() ? view->GetViewBounds().size() : rect.size();

View File

@@ -211,6 +211,7 @@ class WebContents : public gin::Wrappable<WebContents>,
void IncrementCapturerCount(gin::Arguments* args);
void DecrementCapturerCount(gin::Arguments* args);
bool IsBeingCaptured();
void HandleNewRenderFrame(content::RenderFrameHost* render_frame_host);
#if BUILDFLAG(ENABLE_PRINTING)
void OnGetDefaultPrinter(base::Value print_settings,
@@ -550,7 +551,6 @@ class WebContents : public gin::Wrappable<WebContents>,
// content::WebContentsObserver:
void BeforeUnloadFired(bool proceed,
const base::TimeTicks& proceed_time) override;
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
void RenderViewDeleted(content::RenderViewHost*) override;
void RenderProcessGone(base::TerminationStatus status) override;

View File

@@ -6,6 +6,7 @@
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/ui/cocoa/event_dispatching_window.h"
#include "shell/browser/web_contents_preferences.h"
#include "ui/base/cocoa/command_dispatcher.h"
#include "ui/events/keycodes/keyboard_codes.h"
#import <Cocoa/Cocoa.h>
@@ -58,6 +59,7 @@ bool WebContents::PlatformHandleKeyboardEvent(
[[NSApp mainMenu] performKeyEquivalent:event.os_event])
return true;
// Let the window redispatch the OS event
if (event.os_event.window &&
[event.os_event.window isKindOfClass:[EventDispatchingWindow class]]) {
[event.os_event.window redispatchKeyEvent:event.os_event];
@@ -65,6 +67,16 @@ bool WebContents::PlatformHandleKeyboardEvent(
// devtools windows as Widgets in order to take advantage of the
// pre-existing redispatch code in bridged_native_widget.
return false;
} else if (event.os_event.window &&
[event.os_event.window
conformsToProtocol:@protocol(CommandDispatchingWindow)]) {
NSObject<CommandDispatchingWindow>* window =
static_cast<NSObject<CommandDispatchingWindow>*>(event.os_event.window);
[[window commandDispatcher] redispatchKeyEvent:event.os_event];
// FIXME(clavin): Not exactly sure what to return here, likely the same
// situation as the branch above. If a future refactor removes
// |EventDispatchingWindow| then only this branch will need to remain.
return false;
}
return false;

View File

@@ -116,49 +116,6 @@ v8::Local<v8::Promise> WebFrameMain::ExecuteJavaScript(
return handle;
}
v8::Local<v8::Promise> WebFrameMain::ExecuteJavaScriptInIsolatedWorld(
gin::Arguments* args,
int world_id,
const base::string16& code) {
gin_helper::Promise<base::Value> promise(args->isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
// Optional userGesture parameter
bool user_gesture;
if (!args->PeekNext().IsEmpty()) {
if (args->PeekNext()->IsBoolean()) {
args->GetNext(&user_gesture);
} else {
args->ThrowTypeError("userGesture must be a boolean");
return handle;
}
} else {
user_gesture = false;
}
if (render_frame_disposed_) {
promise.RejectWithErrorMessage(
"Render frame was disposed before WebFrameMain could be accessed");
return handle;
}
if (user_gesture) {
auto* ftn = content::FrameTreeNode::From(render_frame_);
ftn->UpdateUserActivationState(
blink::mojom::UserActivationUpdateType::kNotifyActivation,
blink::mojom::UserActivationNotificationType::kTest);
}
render_frame_->ExecuteJavaScriptForTests(
code,
base::BindOnce([](gin_helper::Promise<base::Value> promise,
base::Value value) { promise.Resolve(value); },
std::move(promise)),
world_id);
return handle;
}
bool WebFrameMain::Reload() {
if (!CheckRenderFrame())
return false;
@@ -365,8 +322,6 @@ v8::Local<v8::ObjectTemplate> WebFrameMain::FillObjectTemplate(
v8::Local<v8::ObjectTemplate> templ) {
return gin_helper::ObjectTemplateBuilder(isolate, templ)
.SetMethod("executeJavaScript", &WebFrameMain::ExecuteJavaScript)
.SetMethod("executeJavaScriptInIsolatedWorld",
&WebFrameMain::ExecuteJavaScriptInIsolatedWorld)
.SetMethod("reload", &WebFrameMain::Reload)
.SetMethod("_send", &WebFrameMain::Send)
.SetMethod("_postMessage", &WebFrameMain::PostMessage)

View File

@@ -79,10 +79,6 @@ class WebFrameMain : public gin::Wrappable<WebFrameMain>,
v8::Local<v8::Promise> ExecuteJavaScript(gin::Arguments* args,
const base::string16& code);
v8::Local<v8::Promise> ExecuteJavaScriptInIsolatedWorld(
gin::Arguments* args,
int world_id,
const base::string16& code);
bool Reload();
void Send(v8::Isolate* isolate,
bool internal,

View File

@@ -47,6 +47,27 @@ void BadgeManager::BindFrameReceiver(
std::move(context));
}
void BadgeManager::BindServiceWorkerReceiver(
content::RenderProcessHost* service_worker_process_host,
const GURL& service_worker_scope,
mojo::PendingReceiver<blink::mojom::BadgeService> receiver) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
auto* browser_context = service_worker_process_host->GetBrowserContext();
auto* badge_manager =
badging::BadgeManagerFactory::GetInstance()->GetForBrowserContext(
browser_context);
if (!badge_manager)
return;
auto context = std::make_unique<BadgeManager::ServiceWorkerBindingContext>(
service_worker_process_host->GetID(), service_worker_scope);
badge_manager->receivers_.Add(badge_manager, std::move(receiver),
std::move(context));
}
std::string BadgeManager::GetBadgeString(base::Optional<int> badge_content) {
if (!badge_content)
return "";

View File

@@ -37,6 +37,10 @@ class BadgeManager : public KeyedService, public blink::mojom::BadgeService {
static void BindFrameReceiver(
content::RenderFrameHost* frame,
mojo::PendingReceiver<blink::mojom::BadgeService> receiver);
static void BindServiceWorkerReceiver(
content::RenderProcessHost* service_worker_process_host,
const GURL& service_worker_scope,
mojo::PendingReceiver<blink::mojom::BadgeService> receiver);
// Determines the text to put on the badge based on some badge_content.
static std::string GetBadgeString(base::Optional<int> badge_content);
@@ -66,6 +70,21 @@ class BadgeManager : public KeyedService, public blink::mojom::BadgeService {
int frame_id_;
};
// The BindingContext for ServiceWorkerGlobalScope execution contexts.
class ServiceWorkerBindingContext final : public BindingContext {
public:
ServiceWorkerBindingContext(int process_id, const GURL& scope)
: process_id_(process_id), scope_(scope) {}
~ServiceWorkerBindingContext() override = default;
int GetProcessId() { return process_id_; }
GURL GetScope() { return scope_; }
private:
int process_id_;
GURL scope_;
};
// blink::mojom::BadgeService:
// Note: These are private to stop them being called outside of mojo as they
// require a mojo binding context.

View File

@@ -0,0 +1,117 @@
// Copyright (c) 2020 Microsoft, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/browser/bluetooth/electron_bluetooth_delegate.h"
#include <memory>
#include "base/scoped_observer.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "device/bluetooth/bluetooth_device.h"
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/lib/bluetooth_chooser.h"
#include "third_party/blink/public/common/bluetooth/web_bluetooth_device_id.h"
#include "third_party/blink/public/mojom/bluetooth/web_bluetooth.mojom.h"
using blink::WebBluetoothDeviceId;
using content::RenderFrameHost;
using content::WebContents;
using device::BluetoothUUID;
namespace electron {
ElectronBluetoothDelegate::ElectronBluetoothDelegate() = default;
ElectronBluetoothDelegate::~ElectronBluetoothDelegate() = default;
std::unique_ptr<content::BluetoothChooser>
ElectronBluetoothDelegate::RunBluetoothChooser(
content::RenderFrameHost* frame,
const content::BluetoothChooser::EventHandler& event_handler) {
auto* api_web_contents =
api::WebContents::From(content::WebContents::FromRenderFrameHost(frame));
return std::make_unique<BluetoothChooser>(api_web_contents, event_handler);
}
// The following methods are not currently called in Electron.
std::unique_ptr<content::BluetoothScanningPrompt>
ElectronBluetoothDelegate::ShowBluetoothScanningPrompt(
content::RenderFrameHost* frame,
const content::BluetoothScanningPrompt::EventHandler& event_handler) {
NOTIMPLEMENTED();
return nullptr;
}
WebBluetoothDeviceId ElectronBluetoothDelegate::GetWebBluetoothDeviceId(
RenderFrameHost* frame,
const std::string& device_address) {
NOTIMPLEMENTED();
return WebBluetoothDeviceId::Create();
}
std::string ElectronBluetoothDelegate::GetDeviceAddress(
RenderFrameHost* frame,
const WebBluetoothDeviceId& device_id) {
NOTIMPLEMENTED();
return nullptr;
}
WebBluetoothDeviceId ElectronBluetoothDelegate::AddScannedDevice(
RenderFrameHost* frame,
const std::string& device_address) {
NOTIMPLEMENTED();
return WebBluetoothDeviceId::Create();
}
WebBluetoothDeviceId ElectronBluetoothDelegate::GrantServiceAccessPermission(
RenderFrameHost* frame,
const device::BluetoothDevice* device,
const blink::mojom::WebBluetoothRequestDeviceOptions* options) {
NOTIMPLEMENTED();
return WebBluetoothDeviceId::Create();
}
bool ElectronBluetoothDelegate::HasDevicePermission(
RenderFrameHost* frame,
const WebBluetoothDeviceId& device_id) {
NOTIMPLEMENTED();
return true;
}
bool ElectronBluetoothDelegate::IsAllowedToAccessService(
RenderFrameHost* frame,
const WebBluetoothDeviceId& device_id,
const BluetoothUUID& service) {
NOTIMPLEMENTED();
return true;
}
bool ElectronBluetoothDelegate::IsAllowedToAccessAtLeastOneService(
RenderFrameHost* frame,
const WebBluetoothDeviceId& device_id) {
NOTIMPLEMENTED();
return true;
}
bool ElectronBluetoothDelegate::IsAllowedToAccessManufacturerData(
RenderFrameHost* frame,
const WebBluetoothDeviceId& device_id,
uint16_t manufacturer_code) {
NOTIMPLEMENTED();
return true;
}
std::vector<blink::mojom::WebBluetoothDevicePtr>
ElectronBluetoothDelegate::GetPermittedDevices(
content::RenderFrameHost* frame) {
std::vector<blink::mojom::WebBluetoothDevicePtr> permitted_devices;
NOTIMPLEMENTED();
return permitted_devices;
}
} // namespace electron

View File

@@ -0,0 +1,87 @@
// Copyright (c) 2020 Microsoft, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_BROWSER_BLUETOOTH_ELECTRON_BLUETOOTH_DELEGATE_H_
#define SHELL_BROWSER_BLUETOOTH_ELECTRON_BLUETOOTH_DELEGATE_H_
#include <memory>
#include <string>
#include <vector>
#include "base/observer_list.h"
#include "base/scoped_observation.h"
#include "content/public/browser/bluetooth_delegate.h"
#include "content/public/browser/render_frame_host.h"
#include "third_party/blink/public/mojom/bluetooth/web_bluetooth.mojom-forward.h"
namespace blink {
class WebBluetoothDeviceId;
} // namespace blink
namespace content {
class RenderFrameHost;
} // namespace content
namespace device {
class BluetoothDevice;
class BluetoothUUID;
} // namespace device
namespace electron {
// Provides an interface for managing device permissions for Web Bluetooth and
// Web Bluetooth Scanning API. This is the Electron-specific implementation of
// the BluetoothDelegate.
class ElectronBluetoothDelegate : public content::BluetoothDelegate {
public:
ElectronBluetoothDelegate();
~ElectronBluetoothDelegate() override;
// Move-only class.
ElectronBluetoothDelegate(const ElectronBluetoothDelegate&) = delete;
ElectronBluetoothDelegate& operator=(const ElectronBluetoothDelegate&) =
delete;
// BluetoothDelegate implementation:
std::unique_ptr<content::BluetoothChooser> RunBluetoothChooser(
content::RenderFrameHost* frame,
const content::BluetoothChooser::EventHandler& event_handler) override;
std::unique_ptr<content::BluetoothScanningPrompt> ShowBluetoothScanningPrompt(
content::RenderFrameHost* frame,
const content::BluetoothScanningPrompt::EventHandler& event_handler)
override;
blink::WebBluetoothDeviceId GetWebBluetoothDeviceId(
content::RenderFrameHost* frame,
const std::string& device_address) override;
std::string GetDeviceAddress(
content::RenderFrameHost* frame,
const blink::WebBluetoothDeviceId& device_id) override;
blink::WebBluetoothDeviceId AddScannedDevice(
content::RenderFrameHost* frame,
const std::string& device_address) override;
blink::WebBluetoothDeviceId GrantServiceAccessPermission(
content::RenderFrameHost* frame,
const device::BluetoothDevice* device,
const blink::mojom::WebBluetoothRequestDeviceOptions* options) override;
bool HasDevicePermission(
content::RenderFrameHost* frame,
const blink::WebBluetoothDeviceId& device_id) override;
bool IsAllowedToAccessService(content::RenderFrameHost* frame,
const blink::WebBluetoothDeviceId& device_id,
const device::BluetoothUUID& service) override;
bool IsAllowedToAccessAtLeastOneService(
content::RenderFrameHost* frame,
const blink::WebBluetoothDeviceId& device_id) override;
bool IsAllowedToAccessManufacturerData(
content::RenderFrameHost* frame,
const blink::WebBluetoothDeviceId& device_id,
uint16_t manufacturer_code) override;
std::vector<blink::mojom::WebBluetoothDevicePtr> GetPermittedDevices(
content::RenderFrameHost* frame) override;
};
} // namespace electron
#endif // SHELL_BROWSER_BLUETOOTH_ELECTRON_BLUETOOTH_DELEGATE_H_

View File

@@ -13,6 +13,7 @@
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/debug/crash_logging.h"
#include "base/environment.h"
#include "base/files/file_util.h"
#include "base/json/json_reader.h"
@@ -719,7 +720,13 @@ void ElectronBrowserClient::AppendExtraCommandLineSwitches(
<< "Aborted from launching unexpected helper executable";
}
#else
base::PathService::Get(content::CHILD_PROCESS_EXE, &child_path);
if (!base::PathService::Get(content::CHILD_PROCESS_EXE, &child_path)) {
CHECK(false) << "Unable to get child process binary name.";
}
SCOPED_CRASH_KEY_STRING256("ChildProcess", "child_process_exe",
child_path.AsUTF8Unsafe());
SCOPED_CRASH_KEY_STRING256("ChildProcess", "program",
program.AsUTF8Unsafe());
CHECK_EQ(program, child_path);
#endif
}
@@ -1768,4 +1775,18 @@ content::SerialDelegate* ElectronBrowserClient::GetSerialDelegate() {
return serial_delegate_.get();
}
content::BluetoothDelegate* ElectronBrowserClient::GetBluetoothDelegate() {
if (!bluetooth_delegate_)
bluetooth_delegate_ = std::make_unique<ElectronBluetoothDelegate>();
return bluetooth_delegate_.get();
}
void ElectronBrowserClient::BindBadgeServiceReceiverFromServiceWorker(
content::RenderProcessHost* service_worker_process_host,
const GURL& service_worker_scope,
mojo::PendingReceiver<blink::mojom::BadgeService> receiver) {
badging::BadgeManager::BindServiceWorkerReceiver(
service_worker_process_host, service_worker_scope, std::move(receiver));
}
} // namespace electron

View File

@@ -19,6 +19,7 @@
#include "electron/buildflags/buildflags.h"
#include "net/ssl/client_cert_identity.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "shell/browser/bluetooth/electron_bluetooth_delegate.h"
#include "shell/browser/serial/electron_serial_delegate.h"
namespace content {
@@ -72,6 +73,10 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
void RegisterBrowserInterfaceBindersForFrame(
content::RenderFrameHost* render_frame_host,
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) override;
void BindBadgeServiceReceiverFromServiceWorker(
content::RenderProcessHost* service_worker_process_host,
const GURL& service_worker_scope,
mojo::PendingReceiver<blink::mojom::BadgeService> receiver) override;
#if defined(OS_LINUX)
void GetAdditionalMappedFilesForChildProcess(
const base::CommandLine& command_line,
@@ -86,6 +91,8 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
bool CanUseCustomSiteInstance() override;
content::SerialDelegate* GetSerialDelegate() override;
content::BluetoothDelegate* GetBluetoothDelegate() override;
protected:
void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
content::SpeechRecognitionManagerDelegate*
@@ -336,6 +343,7 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
uint64_t next_id_ = 0;
std::unique_ptr<ElectronSerialDelegate> serial_delegate_;
std::unique_ptr<ElectronBluetoothDelegate> bluetooth_delegate_;
DISALLOW_COPY_AND_ASSIGN(ElectronBrowserClient);
};

View File

@@ -37,15 +37,27 @@ base::FilePath CreateDownloadPath(const GURL& url,
const std::string& content_disposition,
const std::string& suggested_filename,
const std::string& mime_type,
const base::FilePath& last_saved_directory,
const base::FilePath& default_download_path) {
auto generated_name =
net::GenerateFileName(url, content_disposition, std::string(),
suggested_filename, mime_type, "download");
if (!base::PathExists(default_download_path))
base::CreateDirectory(default_download_path);
base::FilePath download_path;
return default_download_path.Append(generated_name);
// If the last saved directory is a non-empty existent path, use it as the
// default.
if (last_saved_directory.empty() || !base::PathExists(last_saved_directory)) {
download_path = default_download_path;
if (!base::PathExists(download_path))
base::CreateDirectory(download_path);
} else {
// Otherwise use the global default.
download_path = last_saved_directory;
}
return download_path.Append(generated_name);
}
} // namespace
@@ -153,10 +165,7 @@ void ElectronDownloadManagerDelegate::OnDownloadSaveDialogDone(
if (!canceled) {
if (result.Get("filePath", &path)) {
// Remember the last selected download directory.
auto* browser_context = static_cast<ElectronBrowserContext*>(
download_manager_->GetBrowserContext());
browser_context->prefs()->SetFilePath(prefs::kDownloadDefaultDirectory,
path.DirName());
last_saved_directory_ = path.DirName();
api::DownloadItem* download = api::DownloadItem::FromDownloadItem(item);
if (download)
@@ -222,7 +231,7 @@ bool ElectronDownloadManagerDelegate::DetermineDownloadTarget(
base::BindOnce(&CreateDownloadPath, download->GetURL(),
download->GetContentDisposition(),
download->GetSuggestedFilename(), download->GetMimeType(),
default_download_path),
last_saved_directory_, default_download_path),
base::BindOnce(&ElectronDownloadManagerDelegate::OnDownloadPathGenerated,
weak_ptr_factory_.GetWeakPtr(), download->GetId(),
std::move(*callback)));

View File

@@ -52,6 +52,8 @@ class ElectronDownloadManagerDelegate
content::DownloadTargetCallback download_callback,
gin_helper::Dictionary result);
base::FilePath last_saved_directory_;
content::DownloadManager* download_manager_;
base::WeakPtrFactory<ElectronDownloadManagerDelegate> weak_ptr_factory_;

View File

@@ -44,7 +44,9 @@ BluetoothChooser::BluetoothChooser(api::WebContents* contents,
const EventHandler& event_handler)
: api_web_contents_(contents), event_handler_(event_handler) {}
BluetoothChooser::~BluetoothChooser() = default;
BluetoothChooser::~BluetoothChooser() {
event_handler_.Reset();
}
void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) {
switch (presence) {
@@ -60,9 +62,11 @@ void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) {
void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
switch (state) {
case DiscoveryState::FAILED_TO_START:
refreshing_ = false;
event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, "");
break;
case DiscoveryState::IDLE:
refreshing_ = false;
if (device_map_.empty()) {
auto event = ++num_retries_ > kMaxScanRetries
? content::BluetoothChooserEvent::CANCELLED
@@ -81,6 +85,14 @@ void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
}
break;
case DiscoveryState::DISCOVERING:
// The first time this state fires is due to a rescan triggering so set a
// flag to ignore devices
if (!refreshing_) {
refreshing_ = true;
} else {
// The second time this state fires we are now safe to pick a device
refreshing_ = false;
}
break;
}
}
@@ -91,6 +103,11 @@ void BluetoothChooser::AddOrUpdateDevice(const std::string& device_id,
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) {
if (refreshing_) {
// If the list of bluetooth devices is currently being generated don't fire
// an event
return;
}
bool changed = false;
auto entry = device_map_.find(device_id);
if (entry == device_map_.end()) {

View File

@@ -41,6 +41,7 @@ class BluetoothChooser : public content::BluetoothChooser {
api::WebContents* api_web_contents_;
EventHandler event_handler_;
int num_retries_ = 0;
bool refreshing_ = false;
DISALLOW_COPY_AND_ASSIGN(BluetoothChooser);
};

View File

@@ -297,7 +297,6 @@ void NativeBrowserViewMac::UpdateDraggableRegions(
NSView* web_view = web_contents->GetNativeView().GetNativeNSView();
NSView* inspectable_view = iwc_view->GetNativeView().GetNativeNSView();
NSView* window_content_view = inspectable_view.superview;
const auto window_content_view_height = NSHeight(window_content_view.bounds);
// Remove all DragRegionViews that were added last time. Note that we need
// to copy the `subviews` array to avoid mutation during iteration.
@@ -313,14 +312,15 @@ void NativeBrowserViewMac::UpdateDraggableRegions(
[[DragRegionView alloc] initWithFrame:web_view.bounds]);
[web_view addSubview:drag_region_view];
// Then, on top of that, add "exclusion zones"
// Then, on top of that, add "exclusion zones".
auto const offset = GetBounds().OffsetFromOrigin();
const auto window_content_view_height = NSHeight(window_content_view.bounds);
for (const auto& rect : drag_exclude_rects) {
const auto window_content_view_exclude_rect =
NSMakeRect(rect.x(), window_content_view_height - rect.bottom(),
rect.width(), rect.height());
const auto x = rect.x() + offset.x();
const auto y = window_content_view_height - rect.bottom() + offset.y();
const auto exclude_rect = NSMakeRect(x, y, rect.width(), rect.height());
const auto drag_region_view_exclude_rect =
[window_content_view convertRect:window_content_view_exclude_rect
toView:drag_region_view];
[window_content_view convertRect:exclude_rect toView:drag_region_view];
base::scoped_nsobject<NSView> exclude_drag_region_view(
[[ExcludeDragRegionView alloc]

View File

@@ -90,10 +90,6 @@ void OffScreenHostDisplayClient::SetActive(bool active) {
}
}
void OffScreenHostDisplayClient::IsOffscreen(IsOffscreenCallback callback) {
std::move(callback).Run(true);
}
void OffScreenHostDisplayClient::CreateLayeredWindowUpdater(
mojo::PendingReceiver<viz::mojom::LayeredWindowUpdater> receiver) {
layered_window_updater_ =

View File

@@ -55,8 +55,6 @@ class OffScreenHostDisplayClient : public viz::HostDisplayClient {
void SetActive(bool active);
private:
void IsOffscreen(IsOffscreenCallback callback) override;
#if defined(OS_MAC)
void OnDisplayReceivedCALayerParams(
const gfx::CALayerParams& ca_layer_params) override;

View File

@@ -612,6 +612,10 @@ void OffScreenRenderWidgetHostView::ProxyViewDestroyed(
Invalidate();
}
bool OffScreenRenderWidgetHostView::IsOffscreen() const {
return true;
}
std::unique_ptr<viz::HostDisplayClient>
OffScreenRenderWidgetHostView::CreateHostDisplayClient(
ui::Compositor* compositor) {

View File

@@ -149,6 +149,7 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase,
gfx::PointF* transformed_point) override;
// ui::CompositorDelegate:
bool IsOffscreen() const override;
std::unique_ptr<viz::HostDisplayClient> CreateHostDisplayClient(
ui::Compositor* compositor) override;

View File

@@ -50,8 +50,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 12,0,0,27
PRODUCTVERSION 12,0,0,27
FILEVERSION 12,0,1,0
PRODUCTVERSION 12,0,1,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -68,12 +68,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "GitHub, Inc."
VALUE "FileDescription", "Electron"
VALUE "FileVersion", "12.0.0"
VALUE "FileVersion", "12.0.1"
VALUE "InternalName", "electron.exe"
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
VALUE "OriginalFilename", "electron.exe"
VALUE "ProductName", "Electron"
VALUE "ProductVersion", "12.0.0"
VALUE "ProductVersion", "12.0.1"
VALUE "SquirrelAwareVersion", "1"
END
END

View File

@@ -127,16 +127,7 @@ WebContentsPreferences::WebContentsPreferences(
SetDefaultBoolIfUndefined(options::kWebviewTag, false);
SetDefaultBoolIfUndefined(options::kSandbox, false);
SetDefaultBoolIfUndefined(options::kNativeWindowOpen, false);
if (IsUndefined(options::kContextIsolation)) {
node::Environment* env = node::Environment::GetCurrent(isolate);
EmitWarning(env,
"The default of contextIsolation is deprecated and will be "
"changing from false to true in a future release of Electron. "
"See https://github.com/electron/electron/issues/23506 for "
"more information",
"electron");
}
SetDefaultBoolIfUndefined(options::kContextIsolation, false);
SetDefaultBoolIfUndefined(options::kContextIsolation, true);
SetDefaultBoolIfUndefined(options::kWorldSafeExecuteJavaScript, true);
SetDefaultBoolIfUndefined(options::kJavaScript, true);
SetDefaultBoolIfUndefined(options::kImages, true);
@@ -429,7 +420,7 @@ void WebContentsPreferences::OverrideWebkitPrefs(
prefs->opener_id = opener_id;
// Run Electron APIs and preload script in isolated world
prefs->context_isolation = IsEnabled(options::kContextIsolation);
prefs->context_isolation = IsEnabled(options::kContextIsolation, true);
#if BUILDFLAG(ENABLE_REMOTE_MODULE)
// Whether to enable the remote module

View File

@@ -209,9 +209,9 @@ bool Converter<blink::WebKeyboardEvent>::FromV8(v8::Isolate* isolate,
size_t text_length_cap = blink::WebKeyboardEvent::kTextLengthCap;
base::string16 text16 = base::UTF8ToUTF16(str);
memset(out->text, 0, text_length_cap);
memset(out->unmodified_text, 0, text_length_cap);
for (size_t i = 0; i < std::min(text_length_cap, text16.size()); ++i) {
std::fill_n(out->text, text_length_cap, 0);
std::fill_n(out->unmodified_text, text_length_cap, 0);
for (size_t i = 0; i < std::min(text_length_cap - 1, text16.size()); ++i) {
out->text[i] = text16[i];
out->unmodified_text[i] = text16[i];
}

View File

@@ -531,6 +531,18 @@ void NodeBindings::LoadEnvironment(node::Environment* env) {
}
void NodeBindings::PrepareMessageLoop() {
#if !defined(OS_WIN)
int handle = uv_backend_fd(uv_loop_);
#else
HANDLE handle = uv_loop_->iocp;
#endif
// If the backend fd hasn't changed, don't proceed.
if (handle == handle_)
return;
handle_ = handle;
// Add dummy handle for libuv, otherwise libuv would quit when there is
// nothing to do.
uv_async_init(uv_loop_, dummy_uv_handle_.get(), nullptr);

View File

@@ -159,6 +159,12 @@ class NodeBindings {
// Isolate data used in creating the environment
node::IsolateData* isolate_data_ = nullptr;
#if defined(OS_WIN)
HANDLE handle_;
#else
int handle_ = -1;
#endif
base::WeakPtrFactory<NodeBindings> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(NodeBindings);

View File

@@ -475,13 +475,15 @@ v8::MaybeLocal<v8::Object> CreateProxyForAPI(
v8::Local<v8::Value> setter_proxy;
if (!getter.IsEmpty()) {
if (!PassValueToOtherContext(source_context, destination_context,
getter, object_cache, false, 1)
getter, object_cache,
support_dynamic_properties, 1)
.ToLocal(&getter_proxy))
continue;
}
if (!setter.IsEmpty()) {
if (!PassValueToOtherContext(source_context, destination_context,
setter, object_cache, false, 1)
setter, object_cache,
support_dynamic_properties, 1)
.ToLocal(&setter_proxy))
continue;
}

View File

@@ -112,9 +112,8 @@ void ElectronRendererClient::DidCreateScriptContext(
bool should_load_node =
(is_main_frame || is_devtools || allow_node_in_subframes) &&
!IsWebViewFrame(renderer_context, render_frame);
if (!should_load_node) {
if (!should_load_node)
return;
}
injected_frames_.insert(render_frame);

View File

@@ -265,22 +265,6 @@ void RendererClientBase::RenderFrameCreated(
// service_impl_.reset(new ElectronApiServiceImpl(render_frame, this));
new ElectronApiServiceImpl(render_frame, this);
content::RenderView* render_view = render_frame->GetRenderView();
if (render_frame->IsMainFrame() && render_view) {
blink::WebView* webview = render_view->GetWebView();
if (webview) {
auto prefs = render_frame->GetBlinkPreferences();
if (prefs.guest_instance_id) { // webview.
webview->SetBaseBackgroundColor(SK_ColorTRANSPARENT);
} else { // normal window.
std::string name = prefs.background_color;
SkColor color =
name.empty() ? SK_ColorTRANSPARENT : ParseHexColor(name);
webview->SetBaseBackgroundColor(color);
}
}
}
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
auto* dispatcher = extensions_renderer_client_->GetDispatcher();
// ExtensionFrameHelper destroys itself when the RenderFrame is destroyed.

View File

@@ -408,7 +408,8 @@ describe('app module', () => {
w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
contextIsolation: false
}
});
await w.loadURL('about:blank');
@@ -425,7 +426,8 @@ describe('app module', () => {
w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
contextIsolation: false
}
});
await w.loadURL('about:blank');
@@ -443,7 +445,8 @@ describe('app module', () => {
w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
contextIsolation: false
}
});
await w.loadURL('about:blank');
@@ -462,7 +465,8 @@ describe('app module', () => {
show: false,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true
enableRemoteModule: true,
contextIsolation: false
}
});
await w.loadURL('about:blank');
@@ -480,7 +484,8 @@ describe('app module', () => {
show: false,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true
enableRemoteModule: true,
contextIsolation: false
}
});
await w.loadURL('about:blank');
@@ -498,7 +503,8 @@ describe('app module', () => {
show: false,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true
enableRemoteModule: true,
contextIsolation: false
}
});
await w.loadURL('about:blank');
@@ -516,7 +522,8 @@ describe('app module', () => {
show: false,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true
enableRemoteModule: true,
contextIsolation: false
}
});
await w.loadURL('about:blank');
@@ -533,7 +540,8 @@ describe('app module', () => {
show: false,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true
enableRemoteModule: true,
contextIsolation: false
}
});
await w.loadURL('about:blank');

View File

@@ -3,6 +3,7 @@ import * as path from 'path';
import { ipcMain, BrowserWindow, WebPreferences, app } from 'electron/main';
import { closeWindow } from './window-helpers';
import { emittedOnce } from './events-helpers';
describe('BrowserWindow with affinity module', () => {
const fixtures = path.resolve(__dirname, '..', 'spec', 'fixtures');
@@ -88,19 +89,15 @@ describe('BrowserWindow with affinity module', () => {
const affinityWithNodeTrue = 'affinityWithNodeTrue';
const affinityWithNodeFalse = 'affinityWithNodeFalse';
function testNodeIntegration (present: boolean) {
return new Promise<void>((resolve) => {
ipcMain.once('answer', (event, typeofProcess, typeofBuffer) => {
if (present) {
expect(typeofProcess).to.not.equal('undefined');
expect(typeofBuffer).to.not.equal('undefined');
} else {
expect(typeofProcess).to.equal('undefined');
expect(typeofBuffer).to.equal('undefined');
}
resolve();
});
});
async function testNodeIntegration (present: boolean) {
const [, typeofProcess, typeofBuffer] = await emittedOnce(ipcMain, 'answer');
if (present) {
expect(typeofProcess).to.not.equal('undefined');
expect(typeofBuffer).to.not.equal('undefined');
} else {
expect(typeofProcess).to.equal('undefined');
expect(typeofBuffer).to.equal('undefined');
}
}
it('disables node integration when specified to false', async () => {
@@ -109,7 +106,8 @@ describe('BrowserWindow with affinity module', () => {
createWindowWithWebPrefs({
affinity: affinityWithNodeTrue,
preload,
nodeIntegration: false
nodeIntegration: false,
contextIsolation: false
})
]);
await closeWindow(w, { assertNotWindows: false });
@@ -120,7 +118,8 @@ describe('BrowserWindow with affinity module', () => {
createWindowWithWebPrefs({
affinity: affinityWithNodeTrue,
preload,
nodeIntegration: false
nodeIntegration: false,
contextIsolation: false
})
]);
const [, w2] = await Promise.all([
@@ -128,7 +127,8 @@ describe('BrowserWindow with affinity module', () => {
createWindowWithWebPrefs({
affinity: affinityWithNodeTrue,
preload,
nodeIntegration: true
nodeIntegration: true,
contextIsolation: false
})
]);
await Promise.all([
@@ -143,7 +143,8 @@ describe('BrowserWindow with affinity module', () => {
createWindowWithWebPrefs({
affinity: affinityWithNodeFalse,
preload,
nodeIntegration: true
nodeIntegration: true,
contextIsolation: false
})
]);
await closeWindow(w, { assertNotWindows: false });
@@ -155,7 +156,8 @@ describe('BrowserWindow with affinity module', () => {
createWindowWithWebPrefs({
affinity: affinityWithNodeFalse,
preload,
nodeIntegration: true
nodeIntegration: true,
contextIsolation: false
})
]);
const [, w2] = await Promise.all([
@@ -163,7 +165,8 @@ describe('BrowserWindow with affinity module', () => {
createWindowWithWebPrefs({
affinity: affinityWithNodeFalse,
preload,
nodeIntegration: false
nodeIntegration: false,
contextIsolation: false
})
]);
await Promise.all([

View File

@@ -95,7 +95,7 @@ describe('BrowserWindow module', () => {
describe('BrowserWindow.close()', () => {
let w = null as unknown as BrowserWindow;
beforeEach(() => {
w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } });
w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
});
afterEach(async () => {
await closeWindow(w);
@@ -190,7 +190,7 @@ describe('BrowserWindow module', () => {
describe('window.close()', () => {
let w = null as unknown as BrowserWindow;
beforeEach(() => {
w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } });
w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
});
afterEach(async () => {
await closeWindow(w);
@@ -445,11 +445,9 @@ describe('BrowserWindow module', () => {
});
});
it('should support support base url for data urls', async () => {
const answer = emittedOnce(ipcMain, 'answer');
w.loadURL('data:text/html,<script src="loaded-from-dataurl.js"></script>', { baseURLForDataURL: `other://${path.join(fixtures, 'api')}${path.sep}` });
const [, test] = await answer;
expect(test).to.equal('test');
it('should support base url for data urls', async () => {
await w.loadURL('data:text/html,<script src="loaded-from-dataurl.js"></script>', { baseURLForDataURL: `other://${path.join(fixtures, 'api')}${path.sep}` });
expect(await w.webContents.executeJavaScript('window.ping')).to.equal('pong');
});
});
@@ -1340,6 +1338,22 @@ describe('BrowserWindow module', () => {
expect(image.isEmpty()).to.equal(true);
});
it('resolves after the window is hidden', async () => {
const w = new BrowserWindow({ show: false });
w.loadFile(path.join(fixtures, 'pages', 'a.html'));
await emittedOnce(w, 'ready-to-show');
w.show();
const visibleImage = await w.capturePage();
expect(visibleImage.isEmpty()).to.equal(false);
w.hide();
const hiddenImage = await w.capturePage();
const isEmpty = process.platform !== 'darwin';
expect(hiddenImage.isEmpty()).to.equal(isEmpty);
});
it('preserves transparency', async () => {
const w = new BrowserWindow({ show: false, transparent: true });
w.loadFile(path.join(fixtures, 'pages', 'theme-color.html'));
@@ -1976,6 +1990,7 @@ describe('BrowserWindow module', () => {
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
preload
}
});
@@ -1990,6 +2005,7 @@ describe('BrowserWindow module', () => {
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
contextIsolation: false,
preload
}
});
@@ -2003,6 +2019,7 @@ describe('BrowserWindow module', () => {
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
preload
}
});
@@ -2042,7 +2059,8 @@ describe('BrowserWindow module', () => {
show: false,
webPreferences: {
sandbox,
preload: path.join(fixtures, 'module', 'get-global-preload.js')
preload: path.join(fixtures, 'module', 'get-global-preload.js'),
contextIsolation: false
}
});
w.loadURL('about:blank');
@@ -2096,7 +2114,8 @@ describe('BrowserWindow module', () => {
const w = new BrowserWindow({
show: false,
webPreferences: {
preload
preload,
contextIsolation: false
}
});
w.loadFile(path.join(fixtures, 'api', 'blank.html'));
@@ -2191,7 +2210,8 @@ describe('BrowserWindow module', () => {
show: false,
webPreferences: {
sandbox: true,
preload
preload,
contextIsolation: false
}
});
w.loadFile(path.join(fixtures, 'api', 'preload.html'));
@@ -2205,7 +2225,8 @@ describe('BrowserWindow module', () => {
show: false,
webPreferences: {
sandbox: true,
preload: preloadSpecialChars
preload: preloadSpecialChars,
contextIsolation: false
}
});
w.loadFile(path.join(fixtures, 'api', 'preload.html'));
@@ -2230,7 +2251,8 @@ describe('BrowserWindow module', () => {
show: false,
webPreferences: {
sandbox: true,
preload
preload,
contextIsolation: false
}
});
const htmlPath = path.join(__dirname, 'fixtures', 'api', 'sandbox.html?exit-event');
@@ -2248,7 +2270,8 @@ describe('BrowserWindow module', () => {
show: true,
webPreferences: {
sandbox: true,
preload
preload,
contextIsolation: false
}
});
@@ -2282,7 +2305,8 @@ describe('BrowserWindow module', () => {
show: true,
webPreferences: {
sandbox: true,
preload
preload,
contextIsolation: false
}
});
@@ -2380,7 +2404,8 @@ describe('BrowserWindow module', () => {
show: false,
webPreferences: {
sandbox: true,
preload
preload,
contextIsolation: false
}
});
let childWc: WebContents | null = null;
@@ -2477,7 +2502,8 @@ describe('BrowserWindow module', () => {
webPreferences: {
preload,
sandbox: true,
enableRemoteModule: true
enableRemoteModule: true,
contextIsolation: false
}
});
w.loadFile(path.join(__dirname, 'fixtures', 'api', 'sandbox.html'), { search: 'reload-remote' });
@@ -2514,7 +2540,8 @@ describe('BrowserWindow module', () => {
webPreferences: {
preload,
sandbox: true,
enableRemoteModule: true
enableRemoteModule: true,
contextIsolation: false
}
});
w.webContents.setWindowOpenHandler(() => ({ action: 'allow', overrideBrowserWindowOptions: { webPreferences: { preload } } }));
@@ -2552,7 +2579,8 @@ describe('BrowserWindow module', () => {
show: false,
webPreferences: {
sandbox: true,
preload
preload,
contextIsolation: false
}
});
w.webContents.once('preload-error', (event, preloadPath, error) => {
@@ -2593,7 +2621,8 @@ describe('BrowserWindow module', () => {
webPreferences: {
sandbox: true,
preload,
webviewTag: true
webviewTag: true,
contextIsolation: false
}
});
const didAttachWebview = emittedOnce(w.webContents, 'did-attach-webview');
@@ -2616,7 +2645,8 @@ describe('BrowserWindow module', () => {
nodeIntegration: true,
nativeWindowOpen: true,
// tests relies on preloads in opened windows
nodeIntegrationInSubFrames: true
nodeIntegrationInSubFrames: true,
contextIsolation: false
}
});
});
@@ -2666,6 +2696,7 @@ describe('BrowserWindow module', () => {
nodeIntegrationInSubFrames: true,
nativeWindowOpen: true,
webviewTag: true,
contextIsolation: false,
preload
}
});
@@ -2738,7 +2769,8 @@ describe('BrowserWindow module', () => {
webPreferences: {
nativeWindowOpen: true,
// test relies on preloads in opened window
nodeIntegrationInSubFrames: true
nodeIntegrationInSubFrames: true,
contextIsolation: false
}
});
@@ -2925,7 +2957,8 @@ describe('BrowserWindow module', () => {
width: 100,
height: 100,
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
contextIsolation: false
}
});
@@ -2949,7 +2982,8 @@ describe('BrowserWindow module', () => {
width: 100,
height: 100,
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
contextIsolation: false
}
});
@@ -2976,7 +3010,8 @@ describe('BrowserWindow module', () => {
width: 100,
height: 100,
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
contextIsolation: false
}
});
@@ -2996,7 +3031,8 @@ describe('BrowserWindow module', () => {
width: 100,
height: 100,
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
contextIsolation: false
}
});
w.loadFile(path.join(fixtures, 'pages', 'visibilitychange.html'));
@@ -3016,7 +3052,8 @@ describe('BrowserWindow module', () => {
width: 100,
height: 100,
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
contextIsolation: false
}
});
w.loadFile(path.join(fixtures, 'pages', 'visibilitychange.html'));
@@ -4389,7 +4426,8 @@ describe('BrowserWindow module', () => {
const w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
contextIsolation: false
}
});

View File

@@ -1053,6 +1053,24 @@ describe('contextBridge', () => {
expect(result).to.equal('hi there');
});
it('should work with nested getters', async () => {
await makeBindingWindow(() => {
contextBridge.internalContextBridge!.overrideGlobalValueWithDynamicPropsFromIsolatedWorld(['thing'], {
get foo () {
return {
get bar () {
return 'hi there';
}
};
}
});
});
const result = await callWithBindings(async (root: any) => {
return root.thing.foo.bar;
});
expect(result).to.equal('hi there');
});
it('should work with setters', async () => {
await makeBindingWindow(() => {
let a: any = null;
@@ -1072,6 +1090,29 @@ describe('contextBridge', () => {
expect(result).to.equal(124);
});
it('should work with nested getter / setter combos', async () => {
await makeBindingWindow(() => {
let a: any = null;
contextBridge.internalContextBridge!.overrideGlobalValueWithDynamicPropsFromIsolatedWorld(['thing'], {
get thingy () {
return {
get foo () {
return a;
},
set foo (arg: any) {
a = arg + 1;
}
};
}
});
});
const result = await callWithBindings(async (root: any) => {
root.thing.thingy.foo = 123;
return root.thing.thingy.foo;
});
expect(result).to.equal(124);
});
it('should work with deep properties', async () => {
await makeBindingWindow(() => {
contextBridge.internalContextBridge.overrideGlobalValueWithDynamicPropsFromIsolatedWorld(['thing'], {

View File

@@ -239,7 +239,7 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
remotely(() => {
const { BrowserWindow } = require('electron');
const bw = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } });
const bw = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
bw.loadURL('about:blank');
bw.webContents.executeJavaScript('process._linkedBinding(\'electron_common_v8_util\').triggerFatalErrorForTesting()');
});
@@ -409,7 +409,7 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
// 2. generate a crash in the renderer.
remotely(() => {
const { BrowserWindow } = require('electron');
const bw = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } });
const bw = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
bw.loadURL('about:blank');
bw.webContents.executeJavaScript('process.crash()');
});
@@ -485,7 +485,7 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
const rendererParameters = await remotely(async () => {
const { crashReporter, BrowserWindow } = require('electron');
crashReporter.start({ submitURL: 'http://' });
const bw = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } });
const bw = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
bw.loadURL('about:blank');
await bw.webContents.executeJavaScript('require(\'electron\').crashReporter.addExtraParameter(\'hello\', \'world\')');
return bw.webContents.executeJavaScript('require(\'electron\').crashReporter.getParameters()');
@@ -531,7 +531,7 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
} else if (processType === 'renderer') {
return remotely(() => {
const { BrowserWindow } = require('electron');
const bw = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } });
const bw = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
bw.loadURL('about:blank');
bw.webContents.executeJavaScript('process.crash()');
});
@@ -539,7 +539,7 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
const preloadPath = path.join(__dirname, 'fixtures', 'apps', 'crash', 'sandbox-preload.js');
return remotely((preload: string) => {
const { BrowserWindow } = require('electron');
const bw = new BrowserWindow({ show: false, webPreferences: { sandbox: true, preload } });
const bw = new BrowserWindow({ show: false, webPreferences: { sandbox: true, preload, contextIsolation: false } });
bw.loadURL('about:blank');
}, preloadPath);
} else if (processType === 'node') {

View File

@@ -17,7 +17,7 @@ ifdescribe(!process.arch.includes('arm') && process.platform !== 'win32')('deskt
let w: BrowserWindow;
before(async () => {
w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } });
w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
await w.loadURL('about:blank');
});
@@ -96,7 +96,7 @@ ifdescribe(!process.arch.includes('arm') && process.platform !== 'win32')('deskt
});
it('disabling thumbnail should return empty images', async () => {
const w2 = new BrowserWindow({ show: false, width: 200, height: 200 });
const w2 = new BrowserWindow({ show: false, width: 200, height: 200, webPreferences: { contextIsolation: false } });
const wShown = emittedOnce(w2, 'show');
w2.show();
await wShown;
@@ -116,7 +116,7 @@ ifdescribe(!process.arch.includes('arm') && process.platform !== 'win32')('deskt
});
it('getMediaSourceId should match DesktopCapturerSource.id', async () => {
const w = new BrowserWindow({ show: false, width: 100, height: 100 });
const w = new BrowserWindow({ show: false, width: 100, height: 100, webPreferences: { contextIsolation: false } });
const wShown = emittedOnce(w, 'show');
const wFocused = emittedOnce(w, 'focus');
w.show();

View File

@@ -18,7 +18,8 @@ describe('ipc main module', () => {
const w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
contextIsolation: false
}
});
ipcMain.once('send-sync-message', (event) => {
@@ -32,7 +33,8 @@ describe('ipc main module', () => {
const w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
contextIsolation: false
}
});
ipcMain.on('send-sync-message', (event) => {
@@ -72,7 +74,8 @@ describe('ipc main module', () => {
const w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
contextIsolation: false
}
});
w.loadURL('about:blank');

View File

@@ -9,7 +9,7 @@ describe('ipcRenderer module', () => {
let w: BrowserWindow;
before(async () => {
w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, nativeWindowOpen: true } });
w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, nativeWindowOpen: true, contextIsolation: false } });
await w.loadURL('about:blank');
});
after(async () => {

Some files were not shown because too many files have changed in this diff Show More