Skip to content

Commit

Permalink
Merge pull request #10953 from electron/get-browser-view
Browse files Browse the repository at this point in the history
Document and test `getBrowserView`
  • Loading branch information
John Kleinschmidt committed Oct 27, 2017
2 parents 60f5397 + 7bad679 commit 04cce89
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/api/browser-window.md
Expand Up @@ -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.

Expand Down
15 changes: 15 additions & 0 deletions spec/api-browser-view-spec.js
Expand Up @@ -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()
Expand Down

0 comments on commit 04cce89

Please sign in to comment.