chore: finish replacing assert with expect in tests (#18215)
* spec: replace assert with expect in api-browser-view-spec.js * spec: replace assert with expect in api-touch-bar-spec.js * spec: replace assert with expect in api-web-frame-spec.js * spec: replace assert with expect in api-web-contents-view-spec.js * spec: replace assert with expect in security-warnings-spec.js * spec: replace assert with expect in api-menu-item-spec.js * spec: replace assert with expect in api-web-request-spec.js * spec: replace assert with expect in api-remote-spec.js * spec: replace assert with expect in api-session-spec.js * spec: replace assert with expect in api-system-preferences-spec.js * spec: replace assert with expect in api-browser-window-spec.js * spec: replace assert with expect in webview-spec.js * spec: replace assert with expect in api-net-spec.js * spec: replace assert with expect in api-protocol-spec.js * spec: replace assert with expect api-web-contents-spec.js * spec: replace assert with expect in api-shell-spec.js * spec: replace assert with expect in modules-spec.js * spec: replace assert with expect in chromium-spec.js * spec: replace assert with expect in api-crash-reporter-spec.js * spec: replace assert with expect in asar-spec.js * spec: rename assert-helpers to expect-helpers * address PR feedback
This commit is contained in:
parent
dbb8617214
commit
5a7b56b042
22 changed files with 1546 additions and 1591 deletions
|
@ -1,6 +1,5 @@
|
|||
'use strict'
|
||||
|
||||
const assert = require('assert')
|
||||
const ChildProcess = require('child_process')
|
||||
const fs = require('fs')
|
||||
const os = require('os')
|
||||
|
@ -146,15 +145,15 @@ describe('webContents module', () => {
|
|||
if (isCi) return done()
|
||||
|
||||
const specWebContents = remote.getCurrentWebContents()
|
||||
assert.strictEqual(specWebContents.id, webContents.getFocusedWebContents().id)
|
||||
expect(specWebContents.id).to.equal(webContents.getFocusedWebContents().id)
|
||||
|
||||
specWebContents.once('devtools-opened', () => {
|
||||
assert.strictEqual(specWebContents.devToolsWebContents.id, webContents.getFocusedWebContents().id)
|
||||
expect(specWebContents.devToolsWebContents.id).to.equal(webContents.getFocusedWebContents().id)
|
||||
specWebContents.closeDevTools()
|
||||
})
|
||||
|
||||
specWebContents.once('devtools-closed', () => {
|
||||
assert.strictEqual(specWebContents.id, webContents.getFocusedWebContents().id)
|
||||
expect(specWebContents.id).to.equal(webContents.getFocusedWebContents().id)
|
||||
done()
|
||||
})
|
||||
|
||||
|
@ -165,16 +164,16 @@ describe('webContents module', () => {
|
|||
const specWebContents = w.webContents
|
||||
|
||||
specWebContents.once('devtools-opened', () => {
|
||||
assert.doesNotThrow(() => {
|
||||
expect(() => {
|
||||
webContents.getFocusedWebContents()
|
||||
})
|
||||
}).to.not.throw()
|
||||
specWebContents.closeDevTools()
|
||||
})
|
||||
|
||||
specWebContents.once('devtools-closed', () => {
|
||||
assert.doesNotThrow(() => {
|
||||
expect(() => {
|
||||
webContents.getFocusedWebContents()
|
||||
})
|
||||
}).to.not.throw()
|
||||
done()
|
||||
})
|
||||
|
||||
|
@ -200,7 +199,7 @@ describe('webContents module', () => {
|
|||
describe('isFocused() API', () => {
|
||||
it('returns false when the window is hidden', () => {
|
||||
BrowserWindow.getAllWindows().forEach((window) => {
|
||||
assert.strictEqual(!window.isVisible() && window.webContents.isFocused(), false)
|
||||
expect(!window.isVisible() && window.webContents.isFocused()).to.be.false()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -217,8 +216,7 @@ describe('webContents module', () => {
|
|||
oscillator.start()
|
||||
let p = emittedOnce(webContents, '-audio-state-changed')
|
||||
await context.resume()
|
||||
const [, audible] = await p
|
||||
assert(webContents.isCurrentlyAudible() === audible)
|
||||
await p
|
||||
expect(webContents.isCurrentlyAudible()).to.be.true()
|
||||
p = emittedOnce(webContents, '-audio-state-changed')
|
||||
oscillator.stop()
|
||||
|
@ -233,7 +231,7 @@ describe('webContents module', () => {
|
|||
it('should not crash when called for devTools webContents', (done) => {
|
||||
w.webContents.openDevTools()
|
||||
w.webContents.once('devtools-opened', () => {
|
||||
assert(!w.devToolsWebContents.getWebPreferences())
|
||||
expect(w.devToolsWebContents.getWebPreferences()).to.be.null()
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
@ -244,18 +242,18 @@ describe('webContents module', () => {
|
|||
const focused = emittedOnce(w, 'focus')
|
||||
w.show()
|
||||
await focused
|
||||
assert.strictEqual(w.isFocused(), true)
|
||||
expect(w.isFocused()).to.be.true()
|
||||
const devtoolsOpened = emittedOnce(w.webContents, 'devtools-opened')
|
||||
w.webContents.openDevTools({ mode: 'detach', activate: true })
|
||||
await devtoolsOpened
|
||||
assert.strictEqual(w.isFocused(), false)
|
||||
expect(w.isFocused()).to.be.false()
|
||||
})
|
||||
|
||||
it('can show window without activation', async () => {
|
||||
const devtoolsOpened = emittedOnce(w.webContents, 'devtools-opened')
|
||||
w.webContents.openDevTools({ mode: 'detach', activate: false })
|
||||
await devtoolsOpened
|
||||
assert.strictEqual(w.isDevToolsOpened(), true)
|
||||
expect(w.isDevToolsOpened()).to.be.true()
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -268,7 +266,7 @@ describe('webContents module', () => {
|
|||
ipcRenderer.sendSync('prevent-next-input-event', 'a', w.webContents.id)
|
||||
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'a' })
|
||||
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'b' })
|
||||
assert.strictEqual(await keyDown, 'b')
|
||||
expect(await keyDown).to.equal('b')
|
||||
})
|
||||
|
||||
it('has the correct properties', async () => {
|
||||
|
@ -289,14 +287,14 @@ describe('webContents module', () => {
|
|||
})
|
||||
const [, input] = await p
|
||||
|
||||
assert.strictEqual(input.type, opts.type)
|
||||
assert.strictEqual(input.key, opts.key)
|
||||
assert.strictEqual(input.code, opts.code)
|
||||
assert.strictEqual(input.isAutoRepeat, opts.isAutoRepeat)
|
||||
assert.strictEqual(input.shift, opts.shift)
|
||||
assert.strictEqual(input.control, opts.control)
|
||||
assert.strictEqual(input.alt, opts.alt)
|
||||
assert.strictEqual(input.meta, opts.meta)
|
||||
expect(input.type).to.equal(opts.type)
|
||||
expect(input.key).to.equal(opts.key)
|
||||
expect(input.code).to.equal(opts.code)
|
||||
expect(input.isAutoRepeat).to.equal(opts.isAutoRepeat)
|
||||
expect(input.shift).to.equal(opts.shift)
|
||||
expect(input.control).to.equal(opts.control)
|
||||
expect(input.alt).to.equal(opts.alt)
|
||||
expect(input.meta).to.equal(opts.meta)
|
||||
}
|
||||
await testBeforeInput({
|
||||
type: 'keyDown',
|
||||
|
@ -449,12 +447,12 @@ describe('webContents module', () => {
|
|||
|
||||
it('can send keydown events', (done) => {
|
||||
ipcMain.once('keydown', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
|
||||
assert.strictEqual(key, 'a')
|
||||
assert.strictEqual(code, 'KeyA')
|
||||
assert.strictEqual(keyCode, 65)
|
||||
assert.strictEqual(shiftKey, false)
|
||||
assert.strictEqual(ctrlKey, false)
|
||||
assert.strictEqual(altKey, false)
|
||||
expect(key).to.equal('a')
|
||||
expect(code).to.equal('KeyA')
|
||||
expect(keyCode).to.equal(65)
|
||||
expect(shiftKey).to.be.false()
|
||||
expect(ctrlKey).to.be.false()
|
||||
expect(altKey).to.be.false()
|
||||
done()
|
||||
})
|
||||
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'A' })
|
||||
|
@ -462,12 +460,12 @@ describe('webContents module', () => {
|
|||
|
||||
it('can send keydown events with modifiers', (done) => {
|
||||
ipcMain.once('keydown', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
|
||||
assert.strictEqual(key, 'Z')
|
||||
assert.strictEqual(code, 'KeyZ')
|
||||
assert.strictEqual(keyCode, 90)
|
||||
assert.strictEqual(shiftKey, true)
|
||||
assert.strictEqual(ctrlKey, true)
|
||||
assert.strictEqual(altKey, false)
|
||||
expect(key).to.equal('Z')
|
||||
expect(code).to.equal('KeyZ')
|
||||
expect(keyCode).to.equal(90)
|
||||
expect(shiftKey).to.be.true()
|
||||
expect(ctrlKey).to.be.true()
|
||||
expect(altKey).to.be.false()
|
||||
done()
|
||||
})
|
||||
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'Z', modifiers: ['shift', 'ctrl'] })
|
||||
|
@ -475,12 +473,12 @@ describe('webContents module', () => {
|
|||
|
||||
it('can send keydown events with special keys', (done) => {
|
||||
ipcMain.once('keydown', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
|
||||
assert.strictEqual(key, 'Tab')
|
||||
assert.strictEqual(code, 'Tab')
|
||||
assert.strictEqual(keyCode, 9)
|
||||
assert.strictEqual(shiftKey, false)
|
||||
assert.strictEqual(ctrlKey, false)
|
||||
assert.strictEqual(altKey, true)
|
||||
expect(key).to.equal('Tab')
|
||||
expect(code).to.equal('Tab')
|
||||
expect(keyCode).to.equal(9)
|
||||
expect(shiftKey).to.be.false()
|
||||
expect(ctrlKey).to.be.false()
|
||||
expect(altKey).to.be.true()
|
||||
done()
|
||||
})
|
||||
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'Tab', modifiers: ['alt'] })
|
||||
|
@ -488,12 +486,12 @@ describe('webContents module', () => {
|
|||
|
||||
it('can send char events', (done) => {
|
||||
ipcMain.once('keypress', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
|
||||
assert.strictEqual(key, 'a')
|
||||
assert.strictEqual(code, 'KeyA')
|
||||
assert.strictEqual(keyCode, 65)
|
||||
assert.strictEqual(shiftKey, false)
|
||||
assert.strictEqual(ctrlKey, false)
|
||||
assert.strictEqual(altKey, false)
|
||||
expect(key).to.equal('a')
|
||||
expect(code).to.equal('KeyA')
|
||||
expect(keyCode).to.equal(65)
|
||||
expect(shiftKey).to.be.false()
|
||||
expect(ctrlKey).to.be.false()
|
||||
expect(altKey).to.be.false()
|
||||
done()
|
||||
})
|
||||
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'A' })
|
||||
|
@ -502,12 +500,12 @@ describe('webContents module', () => {
|
|||
|
||||
it('can send char events with modifiers', (done) => {
|
||||
ipcMain.once('keypress', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
|
||||
assert.strictEqual(key, 'Z')
|
||||
assert.strictEqual(code, 'KeyZ')
|
||||
assert.strictEqual(keyCode, 90)
|
||||
assert.strictEqual(shiftKey, true)
|
||||
assert.strictEqual(ctrlKey, true)
|
||||
assert.strictEqual(altKey, false)
|
||||
expect(key).to.equal('Z')
|
||||
expect(code).to.equal('KeyZ')
|
||||
expect(keyCode).to.equal(90)
|
||||
expect(shiftKey).to.be.true()
|
||||
expect(ctrlKey).to.be.true()
|
||||
expect(altKey).to.be.false()
|
||||
done()
|
||||
})
|
||||
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'Z' })
|
||||
|
@ -530,18 +528,18 @@ describe('webContents module', () => {
|
|||
|
||||
describe('startDrag({file, icon})', () => {
|
||||
it('throws errors for a missing file or a missing/empty icon', () => {
|
||||
assert.throws(() => {
|
||||
expect(() => {
|
||||
w.webContents.startDrag({ icon: path.join(fixtures, 'assets', 'logo.png') })
|
||||
}, /Must specify either 'file' or 'files' option/)
|
||||
}).to.throw(`Must specify either 'file' or 'files' option`)
|
||||
|
||||
assert.throws(() => {
|
||||
expect(() => {
|
||||
w.webContents.startDrag({ file: __filename })
|
||||
}, /Must specify 'icon' option/)
|
||||
}).to.throw(`Must specify 'icon' option`)
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
assert.throws(() => {
|
||||
expect(() => {
|
||||
w.webContents.startDrag({ file: __filename, icon: __filename })
|
||||
}, /Must specify non-empty 'icon' option/)
|
||||
}).to.throw(`Must specify non-empty 'icon' option`)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -550,8 +548,8 @@ describe('webContents module', () => {
|
|||
describe('when the web contents is hidden', () => {
|
||||
it('does not blur the focused window', (done) => {
|
||||
ipcMain.once('answer', (event, parentFocused, childFocused) => {
|
||||
assert.strictEqual(parentFocused, true)
|
||||
assert.strictEqual(childFocused, false)
|
||||
expect(parentFocused).to.be.true()
|
||||
expect(childFocused).to.be.false()
|
||||
done()
|
||||
})
|
||||
w.show()
|
||||
|
@ -562,11 +560,10 @@ describe('webContents module', () => {
|
|||
|
||||
describe('getOSProcessId()', () => {
|
||||
it('returns a valid procress id', async () => {
|
||||
assert.strictEqual(w.webContents.getOSProcessId(), 0)
|
||||
expect(w.webContents.getOSProcessId()).to.equal(0)
|
||||
|
||||
await w.loadURL('about:blank')
|
||||
const pid = w.webContents.getOSProcessId()
|
||||
expect(pid).to.be.above(0)
|
||||
expect(w.webContents.getOSProcessId()).to.be.above(0)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -620,7 +617,7 @@ describe('webContents module', () => {
|
|||
})
|
||||
ipcMain.on('host1-zoom-level', (e, zoomLevel) => {
|
||||
const expectedZoomLevel = hostZoomMap.host1
|
||||
assert.strictEqual(zoomLevel, expectedZoomLevel)
|
||||
expect(zoomLevel).to.equal(expectedZoomLevel)
|
||||
if (finalNavigation) {
|
||||
done()
|
||||
} else {
|
||||
|
@ -629,7 +626,7 @@ describe('webContents module', () => {
|
|||
})
|
||||
ipcMain.once('host2-zoom-level', (e, zoomLevel) => {
|
||||
const expectedZoomLevel = hostZoomMap.host2
|
||||
assert.strictEqual(zoomLevel, expectedZoomLevel)
|
||||
expect(zoomLevel).to.equal(expectedZoomLevel)
|
||||
finalNavigation = true
|
||||
w.webContents.goBack()
|
||||
})
|
||||
|
@ -642,10 +639,10 @@ describe('webContents module', () => {
|
|||
})
|
||||
w2.webContents.on('did-finish-load', () => {
|
||||
const zoomLevel1 = w.webContents.getZoomLevel()
|
||||
assert.strictEqual(zoomLevel1, hostZoomMap.host3)
|
||||
expect(zoomLevel1).to.equal(hostZoomMap.host3)
|
||||
|
||||
const zoomLevel2 = w2.webContents.getZoomLevel()
|
||||
assert.strictEqual(zoomLevel1, zoomLevel2)
|
||||
expect(zoomLevel1).to.equal(zoomLevel2)
|
||||
w2.setClosable(true)
|
||||
w2.close()
|
||||
done()
|
||||
|
@ -671,11 +668,11 @@ describe('webContents module', () => {
|
|||
if (error) return done(error)
|
||||
w2.webContents.on('did-finish-load', () => {
|
||||
const zoomLevel1 = w.webContents.getZoomLevel()
|
||||
assert.strictEqual(zoomLevel1, hostZoomMap.host3)
|
||||
expect(zoomLevel1).to.equal(hostZoomMap.host3)
|
||||
|
||||
const zoomLevel2 = w2.webContents.getZoomLevel()
|
||||
assert.strictEqual(zoomLevel2, 0)
|
||||
assert.notStrictEqual(zoomLevel1, zoomLevel2)
|
||||
expect(zoomLevel2).to.equal(0)
|
||||
expect(zoomLevel1).to.not.equal(zoomLevel2)
|
||||
|
||||
protocol.unregisterProtocol(zoomScheme, (error) => {
|
||||
if (error) return done(error)
|
||||
|
@ -704,7 +701,7 @@ describe('webContents module', () => {
|
|||
w.webContents.on('did-frame-finish-load', (e, isMainFrame) => {
|
||||
if (!isMainFrame) {
|
||||
const zoomLevel = w.webContents.getZoomLevel()
|
||||
assert.strictEqual(zoomLevel, 2.0)
|
||||
expect(zoomLevel).to.equal(2.0)
|
||||
|
||||
w.webContents.setZoomLevel(0)
|
||||
server.close()
|
||||
|
@ -725,11 +722,11 @@ describe('webContents module', () => {
|
|||
})
|
||||
w2.webContents.on('did-finish-load', () => {
|
||||
const zoomLevel1 = w.webContents.getZoomLevel()
|
||||
assert.strictEqual(zoomLevel1, finalZoomLevel)
|
||||
expect(zoomLevel1).to.equal(finalZoomLevel)
|
||||
|
||||
const zoomLevel2 = w2.webContents.getZoomLevel()
|
||||
assert.strictEqual(zoomLevel2, 0)
|
||||
assert.notStrictEqual(zoomLevel1, zoomLevel2)
|
||||
expect(zoomLevel2).to.equal(0)
|
||||
expect(zoomLevel1).to.not.equal(zoomLevel2)
|
||||
|
||||
w2.setClosable(true)
|
||||
w2.close()
|
||||
|
@ -754,12 +751,12 @@ describe('webContents module', () => {
|
|||
w.webContents.executeJavaScript(source)
|
||||
} else {
|
||||
const zoomLevel = w.webContents.getZoomLevel()
|
||||
assert.strictEqual(zoomLevel, 0)
|
||||
expect(zoomLevel).to.equal(0)
|
||||
done()
|
||||
}
|
||||
})
|
||||
ipcMain.once('zoom-level-set', (e, zoomLevel) => {
|
||||
assert.strictEqual(zoomLevel, 0.6)
|
||||
expect(zoomLevel).to.equal(0.6)
|
||||
w.loadFile(path.join(fixtures, 'pages', 'd.html'))
|
||||
initialNavigation = false
|
||||
})
|
||||
|
@ -777,7 +774,7 @@ describe('webContents module', () => {
|
|||
]
|
||||
policies.forEach((policy) => {
|
||||
w.webContents.setWebRTCIPHandlingPolicy(policy)
|
||||
assert.strictEqual(w.webContents.getWebRTCIPHandlingPolicy(), policy)
|
||||
expect(w.webContents.getWebRTCIPHandlingPolicy()).to.equal(policy)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -788,7 +785,7 @@ describe('webContents module', () => {
|
|||
done()
|
||||
})
|
||||
w.webContents.on('will-prevent-unload', (e) => {
|
||||
assert.fail('should not have fired')
|
||||
expect.fail('should not have fired')
|
||||
})
|
||||
w.loadFile(path.join(fixtures, 'api', 'close-beforeunload-undefined.html'))
|
||||
})
|
||||
|
@ -840,7 +837,7 @@ describe('webContents module', () => {
|
|||
it('does not emit current-render-view-deleted when speculative RVHs are deleted', (done) => {
|
||||
let currentRenderViewDeletedEmitted = false
|
||||
w.webContents.once('destroyed', () => {
|
||||
assert.strictEqual(currentRenderViewDeletedEmitted, false, 'current-render-view-deleted was emitted')
|
||||
expect(currentRenderViewDeletedEmitted).to.be.false('current-render-view-deleted was emitted')
|
||||
done()
|
||||
})
|
||||
const renderViewDeletedHandler = () => {
|
||||
|
@ -857,7 +854,7 @@ describe('webContents module', () => {
|
|||
it('emits current-render-view-deleted if the current RVHs are deleted', (done) => {
|
||||
let currentRenderViewDeletedEmitted = false
|
||||
w.webContents.once('destroyed', () => {
|
||||
assert.strictEqual(currentRenderViewDeletedEmitted, true, 'current-render-view-deleted wasn\'t emitted')
|
||||
expect(currentRenderViewDeletedEmitted).to.be.true('current-render-view-deleted wasn\'t emitted')
|
||||
done()
|
||||
})
|
||||
w.webContents.on('current-render-view-deleted', () => {
|
||||
|
@ -873,7 +870,7 @@ describe('webContents module', () => {
|
|||
let rvhDeletedCount = 0
|
||||
w.webContents.once('destroyed', () => {
|
||||
const expectedRenderViewDeletedEventCount = 3 // 1 speculative upon redirection + 2 upon window close.
|
||||
assert.strictEqual(rvhDeletedCount, expectedRenderViewDeletedEventCount, 'render-view-deleted wasn\'t emitted the expected nr. of times')
|
||||
expect(rvhDeletedCount).to.equal(expectedRenderViewDeletedEventCount, 'render-view-deleted wasn\'t emitted the expected nr. of times')
|
||||
done()
|
||||
})
|
||||
w.webContents.on('render-view-deleted', () => {
|
||||
|
@ -888,8 +885,10 @@ describe('webContents module', () => {
|
|||
|
||||
describe('setIgnoreMenuShortcuts(ignore)', () => {
|
||||
it('does not throw', () => {
|
||||
assert.strictEqual(w.webContents.setIgnoreMenuShortcuts(true), undefined)
|
||||
assert.strictEqual(w.webContents.setIgnoreMenuShortcuts(false), undefined)
|
||||
expect(() => {
|
||||
w.webContents.setIgnoreMenuShortcuts(true)
|
||||
w.webContents.setIgnoreMenuShortcuts(false)
|
||||
}).to.not.throw()
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -975,10 +974,10 @@ describe('webContents module', () => {
|
|||
w.webContents.on('did-change-theme-color', (e, color) => {
|
||||
if (count === 0) {
|
||||
count += 1
|
||||
assert.strictEqual(color, '#FFEEDD')
|
||||
expect(color).to.equal('#FFEEDD')
|
||||
w.loadFile(path.join(fixtures, 'pages', 'base-page.html'))
|
||||
} else if (count === 1) {
|
||||
assert.strictEqual(color, null)
|
||||
expect(color).to.be.null()
|
||||
done()
|
||||
}
|
||||
})
|
||||
|
@ -1030,7 +1029,7 @@ describe('webContents module', () => {
|
|||
it('propagates referrer information to new target=_blank windows', (done) => {
|
||||
const server = http.createServer((req, res) => {
|
||||
if (req.url === '/should_have_referrer') {
|
||||
assert.strictEqual(req.headers.referer, 'http://127.0.0.1:' + server.address().port + '/')
|
||||
expect(req.headers.referer).to.equal(`http://127.0.0.1:${server.address().port}/`)
|
||||
return done()
|
||||
}
|
||||
res.end('<a id="a" href="/should_have_referrer" target="_blank">link</a>')
|
||||
|
@ -1039,8 +1038,8 @@ describe('webContents module', () => {
|
|||
const url = 'http://127.0.0.1:' + server.address().port + '/'
|
||||
w.webContents.once('did-finish-load', () => {
|
||||
w.webContents.once('new-window', (event, newUrl, frameName, disposition, options, features, referrer) => {
|
||||
assert.strictEqual(referrer.url, url)
|
||||
assert.strictEqual(referrer.policy, 'no-referrer-when-downgrade')
|
||||
expect(referrer.url).to.equal(url)
|
||||
expect(referrer.policy).to.equal('no-referrer-when-downgrade')
|
||||
})
|
||||
w.webContents.executeJavaScript('a.click()')
|
||||
})
|
||||
|
@ -1053,7 +1052,7 @@ describe('webContents module', () => {
|
|||
xit('propagates referrer information to windows opened with window.open', (done) => {
|
||||
const server = http.createServer((req, res) => {
|
||||
if (req.url === '/should_have_referrer') {
|
||||
assert.strictEqual(req.headers.referer, 'http://127.0.0.1:' + server.address().port + '/')
|
||||
expect(req.headers.referer).to.equal(`http://127.0.0.1:${server.address().port}/`)
|
||||
return done()
|
||||
}
|
||||
res.end('')
|
||||
|
@ -1062,8 +1061,8 @@ describe('webContents module', () => {
|
|||
const url = 'http://127.0.0.1:' + server.address().port + '/'
|
||||
w.webContents.once('did-finish-load', () => {
|
||||
w.webContents.once('new-window', (event, newUrl, frameName, disposition, options, features, referrer) => {
|
||||
assert.strictEqual(referrer.url, url)
|
||||
assert.strictEqual(referrer.policy, 'no-referrer-when-downgrade')
|
||||
expect(referrer.url).to.equal(url)
|
||||
expect(referrer.policy).to.equal('no-referrer-when-downgrade')
|
||||
})
|
||||
w.webContents.executeJavaScript('window.open(location.href + "should_have_referrer")')
|
||||
})
|
||||
|
@ -1083,7 +1082,7 @@ describe('webContents module', () => {
|
|||
})
|
||||
await w.loadURL('about:blank')
|
||||
const result = await w.webContents.executeJavaScript('37 + 5')
|
||||
assert.strictEqual(result, 42)
|
||||
expect(result).to.equal(42)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -1280,7 +1279,7 @@ describe('webContents module', () => {
|
|||
})
|
||||
await w.loadURL('data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E')
|
||||
const printers = w.webContents.getPrinters()
|
||||
assert.strictEqual(Array.isArray(printers), true)
|
||||
expect(printers).to.be.an('array')
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -1304,8 +1303,7 @@ describe('webContents module', () => {
|
|||
})
|
||||
await w.loadURL('data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E')
|
||||
const data = await w.webContents.printToPDF({})
|
||||
assert.strictEqual(data instanceof Buffer, true)
|
||||
assert.notStrictEqual(data.length, 0)
|
||||
expect(data).to.be.an.instanceof(Buffer).that.is.not.empty()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue