Fix sandbox crash when opening a background tab

When a link is clicked with the middle mouse button, chrome opens a window with
"background-tab" disposition. This is not currently handled in sandbox mode,
causing an api::WebContents to leak leading to eventual crash(since it has no
wrapper).

Also fix the event handler for "-add-new-contents" by having it call
`event.preventDefault()` when the window creation should be cancelled.
This commit is contained in:
Thiago de Arruda 2017-08-14 14:18:14 -03:00
parent a419fe75ca
commit 1709b8e39d

View file

@ -43,8 +43,9 @@ BrowserWindow.prototype._init = function () {
userGesture, left, top, width, userGesture, left, top, width,
height) => { height) => {
let urlFrameName = v8Util.getHiddenValue(webContents, 'url-framename') let urlFrameName = v8Util.getHiddenValue(webContents, 'url-framename')
if ((disposition !== 'foreground-tab' && disposition !== 'new-window') || if ((disposition !== 'foreground-tab' && disposition !== 'new-window' &&
!urlFrameName) { disposition !== 'background-tab') || !urlFrameName) {
event.preventDefault()
return return
} }