Skip to content

Commit

Permalink
test: add test for window.open in BrowserView
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Nov 27, 2018
1 parent d1f0d6c commit 63874da
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion spec/api-browser-view-spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

const assert = require('assert')
const chai = require('chai')
const ChildProcess = require('child_process')
const dirtyChai = require('dirty-chai')
Expand All @@ -14,6 +15,8 @@ const { expect } = chai
chai.use(dirtyChai)

describe('BrowserView module', () => {
const fixtures = path.resolve(__dirname, 'fixtures')

let w = null
let view = null

Expand Down Expand Up @@ -178,11 +181,26 @@ describe('BrowserView module', () => {

describe('new BrowserView()', () => {
it('does not crash on exit', async () => {
const appPath = path.join(__dirname, 'fixtures', 'api', 'leak-exit-browserview.js')
const appPath = path.join(fixtures, 'api', 'leak-exit-browserview.js')
const electronPath = remote.getGlobal('process').execPath
const appProcess = ChildProcess.spawn(electronPath, [appPath])
const [code] = await emittedOnce(appProcess, 'close')
expect(code).to.equal(0)
})
})

describe('window.open()', () => {
it('works in BrowserView', (done) => {
view = new BrowserView()
w.setBrowserView(view)
view.webContents.once('new-window', (e, url, frameName, disposition, options, additionalFeatures) => {
e.preventDefault()
assert.strictEqual(url, 'http://host/')
assert.strictEqual(frameName, 'host')
assert.strictEqual(additionalFeatures[0], 'this-is-not-a-standard-feature')
done()
})
view.webContents.loadFile(path.join(fixtures, 'pages', 'window-open.html'))
})
})
})

0 comments on commit 63874da

Please sign in to comment.