From 1709b8e39d83b9c613bf3e4b87efca23bebc0645 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Mon, 14 Aug 2017 14:18:14 -0300 Subject: [PATCH] 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. --- lib/browser/api/browser-window.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/browser/api/browser-window.js b/lib/browser/api/browser-window.js index 2226f7f03aa2..96cadbd33de6 100644 --- a/lib/browser/api/browser-window.js +++ b/lib/browser/api/browser-window.js @@ -43,8 +43,9 @@ BrowserWindow.prototype._init = function () { userGesture, left, top, width, height) => { let urlFrameName = v8Util.getHiddenValue(webContents, 'url-framename') - if ((disposition !== 'foreground-tab' && disposition !== 'new-window') || - !urlFrameName) { + if ((disposition !== 'foreground-tab' && disposition !== 'new-window' && + disposition !== 'background-tab') || !urlFrameName) { + event.preventDefault() return }