Merge pull request #10953 from electron/get-browser-view

Document and test `getBrowserView`
This commit is contained in:
John Kleinschmidt 2017-10-27 16:05:51 -04:00 committed by GitHub
commit 04cce89fdc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View file

@ -1443,6 +1443,10 @@ removed in future Electron releases.
* `browserView` [BrowserView](browser-view.md)
#### `win.getBrowserView()` _Experimental_
Returns `BrowserView | null` - an attached BrowserView. Returns `null` if none is attached.
**Note:** The BrowserView API is currently experimental and may change or be
removed in future Electron releases.

View file

@ -90,6 +90,21 @@ describe('BrowserView module', () => {
})
})
describe('BrowserWindow.getBrowserView()', () => {
it('returns the set view', () => {
view = new BrowserView()
w.setBrowserView(view)
assert.notEqual(view.id, null)
let view2 = w.getBrowserView()
assert.equal(view2.webContents.id, view.webContents.id)
})
it('returns null if none is set', () => {
let view = w.getBrowserView()
assert.equal(null, view)
})
})
describe('BrowserView.webContents.getOwnerBrowserWindow()', () => {
it('points to owning window', () => {
view = new BrowserView()