From 9a3b78d9fe576e2eb2374d3dea5c13b6087fe7dc Mon Sep 17 00:00:00 2001 From: Hari Juturu Date: Tue, 11 Jul 2017 18:18:36 -0700 Subject: [PATCH] Fix devtools open in mixed sandbox mode --- atom/app/atom_main_delegate.cc | 4 +++- docs/api/app.md | 3 --- spec/api-app-spec.js | 5 ++++- spec/fixtures/api/mixed-sandbox-app/main.js | 19 +++++++++++++++++-- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/atom/app/atom_main_delegate.cc b/atom/app/atom_main_delegate.cc index 0507d5daf..e4e1bc242 100644 --- a/atom/app/atom_main_delegate.cc +++ b/atom/app/atom_main_delegate.cc @@ -154,7 +154,9 @@ content::ContentBrowserClient* AtomMainDelegate::CreateContentBrowserClient() { content::ContentRendererClient* AtomMainDelegate::CreateContentRendererClient() { if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableSandbox)) { + switches::kEnableSandbox) || + !base::CommandLine::ForCurrentProcess()->HasSwitch( + ::switches::kNoSandbox)) { renderer_client_.reset(new AtomSandboxedRendererClient); } else { renderer_client_.reset(new AtomRendererClient); diff --git a/docs/api/app.md b/docs/api/app.md index 82ae0e50f..35548fdad 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -919,9 +919,6 @@ Enables mixed sandbox mode on the app. This method can only be called before app is ready. -**Note:** The devtools will no longer open after mixed sandbox mode has been -enabled (i.e `openDevTools` becomes a no-op). - ### `app.dock.bounce([type])` _macOS_ * `type` String (optional) - Can be `critical` or `informational`. The default is diff --git a/spec/api-app-spec.js b/spec/api-app-spec.js index 8932ac87f..d22499e72 100644 --- a/spec/api-app-spec.js +++ b/spec/api-app-spec.js @@ -567,7 +567,7 @@ describe('app module', function () { }) }) - describe('mixed sandbox option', function () { + describe.only('mixed sandbox option', function () { // FIXME Get these specs running on Linux if (process.platform === 'linux') return @@ -641,6 +641,9 @@ describe('app module', function () { assert.equal(argv.noSandbox.includes('--enable-sandbox'), false) assert.equal(argv.noSandbox.includes('--no-sandbox'), true) + assert.equal(argv.noSandboxDevtools, true) + assert.equal(argv.sandboxDevtools, true) + done() }) }) diff --git a/spec/fixtures/api/mixed-sandbox-app/main.js b/spec/fixtures/api/mixed-sandbox-app/main.js index a71c593f5..4c823490e 100644 --- a/spec/fixtures/api/mixed-sandbox-app/main.js +++ b/spec/fixtures/api/mixed-sandbox-app/main.js @@ -34,13 +34,16 @@ app.once('ready', () => { const argv = { sandbox: null, - noSandbox: null + noSandbox: null, + sandboxDevtools: null, + noSandboxDevtools: null } let connected = false function finish () { - if (connected && argv.sandbox != null && argv.noSandbox != null) { + if (connected && argv.sandbox != null && argv.noSandbox != null + && argv.noSandboxDevtools != null && argv.sandboxDevtools != null) { client.once('end', () => { app.exit(0) }) @@ -54,6 +57,18 @@ app.once('ready', () => { finish() }) + noSandboxWindow.webContents.once('devtools-opened', () => { + argv.noSandboxDevtools = true + finish() + }) + noSandboxWindow.webContents.openDevTools() + + sandboxWindow.webContents.once('devtools-opened', () => { + argv.sandboxDevtools = true + finish() + }) + sandboxWindow.webContents.openDevTools() + ipcMain.on('argv', (event, value) => { if (event.sender === sandboxWindow.webContents) { argv.sandbox = value