Add spec for webContents.getFocusedWebContents()
This commit is contained in:
parent
ebdf8e1fa1
commit
446e3f06c9
1 changed files with 27 additions and 1 deletions
|
@ -3,7 +3,10 @@
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
const {BrowserWindow, webContents} = require('electron').remote
|
const {remote} = require('electron')
|
||||||
|
const {BrowserWindow, webContents, getCurrentWindow} = remote
|
||||||
|
|
||||||
|
var isCi = remote.getGlobal('isCi')
|
||||||
|
|
||||||
describe('webContents module', function () {
|
describe('webContents module', function () {
|
||||||
var fixtures = path.resolve(__dirname, 'fixtures')
|
var fixtures = path.resolve(__dirname, 'fixtures')
|
||||||
|
@ -47,4 +50,27 @@ describe('webContents module', function () {
|
||||||
w.webContents.openDevTools()
|
w.webContents.openDevTools()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('getFocusedWebContents() API', function () {
|
||||||
|
if (isCi) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
it('returns the focused web contents', function (done) {
|
||||||
|
var specWebContents = getCurrentWindow().webContents
|
||||||
|
assert.equal(specWebContents.getId(), webContents.getFocusedWebContents().getId())
|
||||||
|
|
||||||
|
specWebContents.on('devtools-opened', function () {
|
||||||
|
assert.equal(specWebContents.devToolsWebContents.getId(), webContents.getFocusedWebContents().getId())
|
||||||
|
specWebContents.closeDevTools()
|
||||||
|
})
|
||||||
|
|
||||||
|
specWebContents.on('devtools-closed', function () {
|
||||||
|
assert.equal(specWebContents.getId(), webContents.getFocusedWebContents().getId())
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
|
||||||
|
specWebContents.openDevTools()
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue