Open about:blank when window.open is called with no URL

This commit is contained in:
Kevin Sawicki 2016-09-08 16:10:21 -07:00
parent 638c96345d
commit 9829baed46
2 changed files with 23 additions and 3 deletions

View file

@ -139,7 +139,11 @@ window.open = function (url, frameName, features) {
} }
// Resolve relative urls. // Resolve relative urls.
url = resolveURL(url) if (url == null || url == '') {
url = 'about:blank'
} else {
url = resolveURL(url)
}
for (j = 0, len1 = ints.length; j < len1; j++) { for (j = 0, len1 = ints.length; j < len1; j++) {
name = ints[j] name = ints[j]
if (options[name] != null) { if (options[name] != null) {

View file

@ -250,8 +250,7 @@ describe('chromium feature', function () {
it('defines a window.location setter', function (done) { it('defines a window.location setter', function (done) {
// Load a page that definitely won't redirect // Load a page that definitely won't redirect
var b var b = window.open('about:blank')
b = window.open('about:blank')
webContents.fromId(b.guestId).once('did-finish-load', function () { webContents.fromId(b.guestId).once('did-finish-load', function () {
// When it loads, redirect // When it loads, redirect
b.location = 'file://' + fixtures + '/pages/base-page.html' b.location = 'file://' + fixtures + '/pages/base-page.html'
@ -262,6 +261,23 @@ describe('chromium feature', function () {
}) })
}) })
}) })
it('open a blank page when no URL is specified', function (done) {
let b = window.open()
webContents.fromId(b.guestId).once('did-finish-load', function () {
const {location} = b
b.close()
assert.equal(location, 'about:blank')
let c = window.open('')
webContents.fromId(c.guestId).once('did-finish-load', function () {
const {location} = c
c.close()
assert.equal(location, 'about:blank')
done()
})
})
})
}) })
describe('window.opener', function () { describe('window.opener', function () {