Merge pull request #11224 from electron/browser-view-window

feature: Add `BrowserWindow.fromBrowserView()`
This commit is contained in:
Charles Kerr 2017-11-23 14:41:36 +01:00 committed by GitHub
commit 9c217fc6c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 1 deletions

View file

@ -9,7 +9,7 @@ const http = require('http')
const {closeWindow} = require('./window-helpers')
const {ipcRenderer, remote, screen} = require('electron')
const {app, ipcMain, BrowserWindow, protocol, webContents} = remote
const {app, ipcMain, BrowserWindow, BrowserView, protocol, webContents} = remote
const isCI = remote.getGlobal('isCi')
const nativeModulesEnabled = remote.getGlobal('nativeModulesEnabled')
@ -802,6 +802,29 @@ describe('BrowserWindow module', () => {
})
})
describe('BrowserWindow.fromBrowserView(browserView)', () => {
let bv = null
beforeEach(() => {
bv = new BrowserView()
w.setBrowserView(bv)
})
afterEach(() => {
w.setBrowserView(null)
bv.destroy()
})
it('returns the window with the browserView', () => {
assert.equal(BrowserWindow.fromBrowserView(bv).id, w.id)
})
it('returns undefined if not attached', () => {
w.setBrowserView(null)
assert.equal(BrowserWindow.fromBrowserView(bv), undefined)
})
})
describe('BrowserWindow.setOpacity(opacity)', () => {
it('make window with initial opacity', () => {
w.destroy()