Merge pull request #7520 from electron/fix-undef-webprefs
Default webPreferences to empty object always
This commit is contained in:
commit
9339853448
2 changed files with 16 additions and 3 deletions
|
@ -24,14 +24,14 @@ const mergeOptions = function (child, parent) {
|
|||
|
||||
// Merge |options| with the |embedder|'s window's options.
|
||||
const mergeBrowserWindowOptions = function (embedder, options) {
|
||||
if (options.webPreferences == null) {
|
||||
options.webPreferences = {}
|
||||
}
|
||||
if (embedder.browserWindowOptions != null) {
|
||||
// Inherit the original options if it is a BrowserWindow.
|
||||
mergeOptions(options, embedder.browserWindowOptions)
|
||||
} else {
|
||||
// Or only inherit web-preferences if it is a webview.
|
||||
if (options.webPreferences == null) {
|
||||
options.webPreferences = {}
|
||||
}
|
||||
mergeOptions(options.webPreferences, embedder.getWebPreferences())
|
||||
}
|
||||
|
||||
|
|
|
@ -828,6 +828,19 @@ describe('browser-window module', function () {
|
|||
w.loadURL('file://' + fixtures + '/pages/window-open.html')
|
||||
})
|
||||
|
||||
it('emits when window.open is called with no webPreferences', function (done) {
|
||||
w.destroy()
|
||||
w = new BrowserWindow({ show: false })
|
||||
w.webContents.once('new-window', function (e, url, frameName, disposition, options, additionalFeatures) {
|
||||
e.preventDefault()
|
||||
assert.equal(url, 'http://host/')
|
||||
assert.equal(frameName, 'host')
|
||||
assert.equal(additionalFeatures[0], 'this-is-not-a-standard-feature')
|
||||
done()
|
||||
})
|
||||
w.loadURL('file://' + fixtures + '/pages/window-open.html')
|
||||
})
|
||||
|
||||
it('emits when link with target is called', function (done) {
|
||||
this.timeout(10000)
|
||||
w.webContents.once('new-window', function (e, url, frameName) {
|
||||
|
|
Loading…
Reference in a new issue