Merge pull request #9983 from electron/devtools-mixed-sandbox
Fix devtools open in mixed sandbox
This commit is contained in:
		
				commit
				
					
						48f5a66f87
					
				
			
		
					 4 changed files with 23 additions and 6 deletions
				
			
		| 
						 | 
					@ -154,7 +154,9 @@ content::ContentBrowserClient* AtomMainDelegate::CreateContentBrowserClient() {
 | 
				
			||||||
content::ContentRendererClient*
 | 
					content::ContentRendererClient*
 | 
				
			||||||
    AtomMainDelegate::CreateContentRendererClient() {
 | 
					    AtomMainDelegate::CreateContentRendererClient() {
 | 
				
			||||||
  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
 | 
					  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
 | 
				
			||||||
        switches::kEnableSandbox)) {
 | 
					        switches::kEnableSandbox) ||
 | 
				
			||||||
 | 
					      !base::CommandLine::ForCurrentProcess()->HasSwitch(
 | 
				
			||||||
 | 
					        ::switches::kNoSandbox)) {
 | 
				
			||||||
    renderer_client_.reset(new AtomSandboxedRendererClient);
 | 
					    renderer_client_.reset(new AtomSandboxedRendererClient);
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    renderer_client_.reset(new AtomRendererClient);
 | 
					    renderer_client_.reset(new AtomRendererClient);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -927,9 +927,6 @@ Enables mixed sandbox mode on the app.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
This method can only be called before app is ready.
 | 
					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_
 | 
					### `app.dock.bounce([type])` _macOS_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* `type` String (optional) - Can be `critical` or `informational`. The default is
 | 
					* `type` String (optional) - Can be `critical` or `informational`. The default is
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -641,6 +641,9 @@ describe('app module', function () {
 | 
				
			||||||
            assert.equal(argv.noSandbox.includes('--enable-sandbox'), false)
 | 
					            assert.equal(argv.noSandbox.includes('--enable-sandbox'), false)
 | 
				
			||||||
            assert.equal(argv.noSandbox.includes('--no-sandbox'), true)
 | 
					            assert.equal(argv.noSandbox.includes('--no-sandbox'), true)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            assert.equal(argv.noSandboxDevtools, true)
 | 
				
			||||||
 | 
					            assert.equal(argv.sandboxDevtools, true)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            done()
 | 
					            done()
 | 
				
			||||||
          })
 | 
					          })
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										19
									
								
								spec/fixtures/api/mixed-sandbox-app/main.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								spec/fixtures/api/mixed-sandbox-app/main.js
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -34,13 +34,16 @@ app.once('ready', () => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const argv = {
 | 
					  const argv = {
 | 
				
			||||||
    sandbox: null,
 | 
					    sandbox: null,
 | 
				
			||||||
    noSandbox: null
 | 
					    noSandbox: null,
 | 
				
			||||||
 | 
					    sandboxDevtools: null,
 | 
				
			||||||
 | 
					    noSandboxDevtools: null
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let connected = false
 | 
					  let connected = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function finish () {
 | 
					  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', () => {
 | 
					      client.once('end', () => {
 | 
				
			||||||
        app.exit(0)
 | 
					        app.exit(0)
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
| 
						 | 
					@ -54,6 +57,18 @@ app.once('ready', () => {
 | 
				
			||||||
    finish()
 | 
					    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) => {
 | 
					  ipcMain.on('argv', (event, value) => {
 | 
				
			||||||
    if (event.sender === sandboxWindow.webContents) {
 | 
					    if (event.sender === sandboxWindow.webContents) {
 | 
				
			||||||
      argv.sandbox = value
 | 
					      argv.sandbox = value
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue