Merge remote-tracking branch 'origin/master' into renaesop_master
This commit is contained in:
commit
84a9b6a42d
336 changed files with 16704 additions and 2418 deletions
|
@ -1178,7 +1178,6 @@ describe('BrowserWindow module', function () {
|
|||
}
|
||||
})
|
||||
w.loadURL('file://' + path.join(fixtures, 'api', 'sandbox.html?allocate-memory'))
|
||||
w.webContents.openDevTools({mode: 'detach'})
|
||||
ipcMain.once('answer', function (event, {bytesBeforeOpen, bytesAfterOpen, bytesAfterClose}) {
|
||||
const memoryIncreaseByOpen = bytesAfterOpen - bytesBeforeOpen
|
||||
const memoryDecreaseByClose = bytesAfterOpen - bytesAfterClose
|
||||
|
@ -1190,6 +1189,137 @@ describe('BrowserWindow module', function () {
|
|||
done()
|
||||
})
|
||||
})
|
||||
|
||||
// see #9387
|
||||
it('properly manages remote object references after page reload', (done) => {
|
||||
w.destroy()
|
||||
w = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
preload: preload,
|
||||
sandbox: true
|
||||
}
|
||||
})
|
||||
w.loadURL('file://' + path.join(fixtures, 'api', 'sandbox.html?reload-remote'))
|
||||
|
||||
ipcMain.on('get-remote-module-path', (event) => {
|
||||
event.returnValue = path.join(fixtures, 'module', 'hello.js')
|
||||
})
|
||||
|
||||
let reload = false
|
||||
ipcMain.on('reloaded', (event) => {
|
||||
event.returnValue = reload
|
||||
reload = !reload
|
||||
})
|
||||
|
||||
ipcMain.once('reload', (event) => {
|
||||
event.sender.reload()
|
||||
})
|
||||
|
||||
ipcMain.once('answer', (event, arg) => {
|
||||
ipcMain.removeAllListeners('reloaded')
|
||||
ipcMain.removeAllListeners('get-remote-module-path')
|
||||
assert.equal(arg, 'hi')
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('properly manages remote object references after page reload in child window', (done) => {
|
||||
w.destroy()
|
||||
w = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
preload: preload,
|
||||
sandbox: true
|
||||
}
|
||||
})
|
||||
w.loadURL('file://' + path.join(fixtures, 'api', 'sandbox.html?reload-remote-child'))
|
||||
|
||||
ipcMain.on('get-remote-module-path', (event) => {
|
||||
event.returnValue = path.join(fixtures, 'module', 'hello-child.js')
|
||||
})
|
||||
|
||||
let reload = false
|
||||
ipcMain.on('reloaded', (event) => {
|
||||
event.returnValue = reload
|
||||
reload = !reload
|
||||
})
|
||||
|
||||
ipcMain.once('reload', (event) => {
|
||||
event.sender.reload()
|
||||
})
|
||||
|
||||
ipcMain.once('answer', (event, arg) => {
|
||||
ipcMain.removeAllListeners('reloaded')
|
||||
ipcMain.removeAllListeners('get-remote-module-path')
|
||||
assert.equal(arg, 'hi child window')
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('nativeWindowOpen option', () => {
|
||||
beforeEach(() => {
|
||||
w.destroy()
|
||||
w = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
nativeWindowOpen: true
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('opens window of about:blank with cross-scripting enabled', (done) => {
|
||||
ipcMain.once('answer', (event, content) => {
|
||||
assert.equal(content, 'Hello')
|
||||
done()
|
||||
})
|
||||
w.loadURL('file://' + path.join(fixtures, 'api', 'native-window-open-blank.html'))
|
||||
})
|
||||
|
||||
it('opens window of same domain with cross-scripting enabled', (done) => {
|
||||
ipcMain.once('answer', (event, content) => {
|
||||
assert.equal(content, 'Hello')
|
||||
done()
|
||||
})
|
||||
w.loadURL('file://' + path.join(fixtures, 'api', 'native-window-open-file.html'))
|
||||
})
|
||||
|
||||
if (process.platform !== 'win32' || process.execPath.toLowerCase().indexOf('\\out\\d\\') === -1) {
|
||||
it('loads native addons correctly after reload', (done) => {
|
||||
ipcMain.once('answer', (event, content) => {
|
||||
assert.equal(content, 'function')
|
||||
ipcMain.once('answer', (event, content) => {
|
||||
assert.equal(content, 'function')
|
||||
done()
|
||||
})
|
||||
w.reload()
|
||||
})
|
||||
w.loadURL('file://' + path.join(fixtures, 'api', 'native-window-open-native-addon.html'))
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('nativeWindowOpen + contextIsolation options', () => {
|
||||
beforeEach(() => {
|
||||
w.destroy()
|
||||
w = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
nativeWindowOpen: true,
|
||||
contextIsolation: true,
|
||||
preload: path.join(fixtures, 'api', 'native-window-open-isolated-preload.js')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('opens window with cross-scripting enabled from isolated context', (done) => {
|
||||
ipcMain.once('answer', (event, content) => {
|
||||
assert.equal(content, 'Hello')
|
||||
done()
|
||||
})
|
||||
w.loadURL('file://' + path.join(fixtures, 'api', 'native-window-open-isolated.html'))
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -1214,6 +1344,60 @@ describe('BrowserWindow module', function () {
|
|||
})
|
||||
w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-empty-string.html'))
|
||||
})
|
||||
|
||||
it('emits for each close attempt', function (done) {
|
||||
var beforeUnloadCount = 0
|
||||
w.on('onbeforeunload', function () {
|
||||
beforeUnloadCount++
|
||||
if (beforeUnloadCount < 3) {
|
||||
w.close()
|
||||
} else if (beforeUnloadCount === 3) {
|
||||
done()
|
||||
}
|
||||
})
|
||||
w.webContents.once('did-finish-load', function () {
|
||||
w.close()
|
||||
})
|
||||
w.loadURL('file://' + path.join(fixtures, 'api', 'beforeunload-false-prevent3.html'))
|
||||
})
|
||||
|
||||
it('emits for each reload attempt', function (done) {
|
||||
var beforeUnloadCount = 0
|
||||
w.on('onbeforeunload', function () {
|
||||
beforeUnloadCount++
|
||||
if (beforeUnloadCount < 3) {
|
||||
w.reload()
|
||||
} else if (beforeUnloadCount === 3) {
|
||||
done()
|
||||
}
|
||||
})
|
||||
w.webContents.once('did-finish-load', function () {
|
||||
w.webContents.once('did-finish-load', function () {
|
||||
assert.fail('Reload was not prevented')
|
||||
})
|
||||
w.reload()
|
||||
})
|
||||
w.loadURL('file://' + path.join(fixtures, 'api', 'beforeunload-false-prevent3.html'))
|
||||
})
|
||||
|
||||
it('emits for each navigation attempt', function (done) {
|
||||
var beforeUnloadCount = 0
|
||||
w.on('onbeforeunload', function () {
|
||||
beforeUnloadCount++
|
||||
if (beforeUnloadCount < 3) {
|
||||
w.loadURL('about:blank')
|
||||
} else if (beforeUnloadCount === 3) {
|
||||
done()
|
||||
}
|
||||
})
|
||||
w.webContents.once('did-finish-load', function () {
|
||||
w.webContents.once('did-finish-load', function () {
|
||||
assert.fail('Navigation was not prevented')
|
||||
})
|
||||
w.loadURL('about:blank')
|
||||
})
|
||||
w.loadURL('file://' + path.join(fixtures, 'api', 'beforeunload-false-prevent3.html'))
|
||||
})
|
||||
})
|
||||
|
||||
describe('new-window event', function () {
|
||||
|
@ -2171,6 +2355,8 @@ describe('BrowserWindow module', function () {
|
|||
beforeEach(function () {
|
||||
if (w != null) w.destroy()
|
||||
w = new BrowserWindow({
|
||||
width: 100,
|
||||
height: 100,
|
||||
show: false,
|
||||
webPreferences: {
|
||||
backgroundThrottling: false,
|
||||
|
@ -2179,9 +2365,12 @@ describe('BrowserWindow module', function () {
|
|||
})
|
||||
})
|
||||
|
||||
it('creates offscreen window', function (done) {
|
||||
w.webContents.once('paint', function (event, rect, data, size) {
|
||||
it('creates offscreen window with correct size', function (done) {
|
||||
w.webContents.once('paint', function (event, rect, data) {
|
||||
assert.notEqual(data.length, 0)
|
||||
let size = data.getSize()
|
||||
assertWithinDelta(size.width, 100, 2, 'width')
|
||||
assertWithinDelta(size.height, 100, 2, 'height')
|
||||
done()
|
||||
})
|
||||
w.loadURL('file://' + fixtures + '/api/offscreen-rendering.html')
|
||||
|
@ -2202,7 +2391,7 @@ describe('BrowserWindow module', function () {
|
|||
|
||||
describe('window.webContents.isPainting()', function () {
|
||||
it('returns whether is currently painting', function (done) {
|
||||
w.webContents.once('paint', function (event, rect, data, size) {
|
||||
w.webContents.once('paint', function (event, rect, data) {
|
||||
assert.equal(w.webContents.isPainting(), true)
|
||||
done()
|
||||
})
|
||||
|
@ -2226,7 +2415,7 @@ describe('BrowserWindow module', function () {
|
|||
w.webContents.on('dom-ready', function () {
|
||||
w.webContents.stopPainting()
|
||||
w.webContents.startPainting()
|
||||
w.webContents.once('paint', function (event, rect, data, size) {
|
||||
w.webContents.once('paint', function (event, rect, data) {
|
||||
assert.equal(w.webContents.isPainting(), true)
|
||||
done()
|
||||
})
|
||||
|
@ -2237,7 +2426,7 @@ describe('BrowserWindow module', function () {
|
|||
|
||||
describe('window.webContents.getFrameRate()', function () {
|
||||
it('has default frame rate', function (done) {
|
||||
w.webContents.once('paint', function (event, rect, data, size) {
|
||||
w.webContents.once('paint', function (event, rect, data) {
|
||||
assert.equal(w.webContents.getFrameRate(), 60)
|
||||
done()
|
||||
})
|
||||
|
@ -2249,7 +2438,7 @@ describe('BrowserWindow module', function () {
|
|||
it('sets custom frame rate', function (done) {
|
||||
w.webContents.on('dom-ready', function () {
|
||||
w.webContents.setFrameRate(30)
|
||||
w.webContents.once('paint', function (event, rect, data, size) {
|
||||
w.webContents.once('paint', function (event, rect, data) {
|
||||
assert.equal(w.webContents.getFrameRate(), 30)
|
||||
done()
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue