Check for devtools in BrowserWindow.getFocusedWindow() (#12526)
This commit is contained in:
parent
82f8914f9e
commit
970f79e32f
2 changed files with 12 additions and 1 deletions
|
@ -134,7 +134,7 @@ BrowserWindow.prototype._init = function () {
|
||||||
|
|
||||||
BrowserWindow.getFocusedWindow = () => {
|
BrowserWindow.getFocusedWindow = () => {
|
||||||
for (let window of BrowserWindow.getAllWindows()) {
|
for (let window of BrowserWindow.getAllWindows()) {
|
||||||
if (window.isFocused()) return window
|
if (window.isFocused() || window.isDevToolsFocused()) return window
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
|
@ -419,6 +419,17 @@ describe('BrowserWindow module', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('BrowserWindow.getFocusedWindow()', (done) => {
|
||||||
|
it('returns the opener window when dev tools window is focused', (done) => {
|
||||||
|
w.show()
|
||||||
|
w.webContents.once('devtools-focused', () => {
|
||||||
|
assert.deepEqual(BrowserWindow.getFocusedWindow(), w)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
w.webContents.openDevTools({mode: 'undocked'})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('BrowserWindow.capturePage(rect, callback)', () => {
|
describe('BrowserWindow.capturePage(rect, callback)', () => {
|
||||||
it('calls the callback with a Buffer', (done) => {
|
it('calls the callback with a Buffer', (done) => {
|
||||||
w.capturePage({
|
w.capturePage({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue