refactor: add prefer-const to .eslintrc + fix errors (#14880)

This commit is contained in:
Milan Burda
2018-10-02 03:56:31 +02:00
committed by Samuel Attard
parent 07161a8452
commit 3ad3ade828
47 changed files with 239 additions and 238 deletions

View File

@@ -116,12 +116,12 @@ describe('BrowserView module', () => {
w.setBrowserView(view)
expect(view.id).to.not.be.null()
let view2 = w.getBrowserView()
const view2 = w.getBrowserView()
expect(view2.webContents.id).to.equal(view.webContents.id)
})
it('returns null if none is set', () => {
let view = w.getBrowserView()
const view = w.getBrowserView()
expect(view).to.be.null()
})
})
@@ -145,7 +145,7 @@ describe('BrowserView module', () => {
w.setBrowserView(view)
expect(view.id).to.not.be.null()
let view2 = BrowserView.fromId(view.id)
const view2 = BrowserView.fromId(view.id)
expect(view2.webContents.id).to.equal(view.webContents.id)
})
})
@@ -156,7 +156,7 @@ describe('BrowserView module', () => {
w.setBrowserView(view)
expect(view.id).to.not.be.null()
let view2 = BrowserView.fromWebContents(view.webContents)
const view2 = BrowserView.fromWebContents(view.webContents)
expect(view2.webContents.id).to.equal(view.webContents.id)
})
})

View File

@@ -129,7 +129,7 @@ describe('BrowserWindow with affinity module', () => {
nodeIntegration: false
})
]).then(args => {
let w1 = args[1]
const w1 = args[1]
return Promise.all([
testNodeIntegration(false),
w1,
@@ -169,7 +169,7 @@ describe('BrowserWindow with affinity module', () => {
nodeIntegration: true
})
]).then(args => {
let w1 = args[1]
const w1 = args[1]
return Promise.all([
testNodeIntegration(true),
w1,

View File

@@ -75,7 +75,7 @@ describe('BrowserWindow module', () => {
if (data) body += data
})
req.on('end', () => {
let parsedData = qs.parse(body)
const parsedData = qs.parse(body)
fs.readFile(filePath, (err, data) => {
if (err) return
if (parsedData.username === 'test' &&
@@ -187,7 +187,7 @@ describe('BrowserWindow module', () => {
function * genNavigationEvent () {
let eventOptions = null
while ((eventOptions = events.shift()) && events.length) {
let w = new BrowserWindow({ show: false })
const w = new BrowserWindow({ show: false })
eventOptions.id = w.id
eventOptions.responseEvent = responseEvent
ipcRenderer.send('test-webcontents-navigation-observer', eventOptions)
@@ -195,7 +195,7 @@ describe('BrowserWindow module', () => {
}
}
let gen = genNavigationEvent()
const gen = genNavigationEvent()
ipcRenderer.on(responseEvent, () => {
if (!gen.next().value) done()
})
@@ -1399,7 +1399,7 @@ describe('BrowserWindow module', () => {
describe('"sandbox" option', () => {
function waitForEvents (emitter, events, callback) {
let count = events.length
for (let event of events) {
for (const event of events) {
emitter.once(event, () => {
if (!--count) callback()
})
@@ -1473,7 +1473,7 @@ describe('BrowserWindow module', () => {
preload: preload
}
})
let htmlPath = path.join(fixtures, 'api', 'sandbox.html?exit-event')
const htmlPath = path.join(fixtures, 'api', 'sandbox.html?exit-event')
const pageUrl = 'file://' + htmlPath
w.loadURL(pageUrl)
ipcMain.once('answer', function (event, url) {
@@ -1496,7 +1496,7 @@ describe('BrowserWindow module', () => {
}
})
ipcRenderer.send('set-web-preferences-on-next-new-window', w.webContents.id, 'preload', preload)
let htmlPath = path.join(fixtures, 'api', 'sandbox.html?window-open')
const htmlPath = path.join(fixtures, 'api', 'sandbox.html?window-open')
const pageUrl = 'file://' + htmlPath
w.loadURL(pageUrl)
w.webContents.once('new-window', (e, url, frameName, disposition, options) => {
@@ -2763,7 +2763,7 @@ describe('BrowserWindow module', () => {
// dynamically.
it('can be changed with hasShadow option', () => {
w.destroy()
let hasShadow = process.platform !== 'darwin'
const hasShadow = process.platform !== 'darwin'
w = new BrowserWindow({ show: false, hasShadow: hasShadow })
assert.strictEqual(w.hasShadow(), hasShadow)
})
@@ -2964,7 +2964,7 @@ describe('BrowserWindow module', () => {
c.close()
})
it('disables parent window recursively', () => {
let c2 = new BrowserWindow({ show: false, parent: w, modal: true })
const c2 = new BrowserWindow({ show: false, parent: w, modal: true })
c.show()
assert.strictEqual(w.isEnabled(), false)
c2.show()
@@ -3435,7 +3435,7 @@ describe('BrowserWindow module', () => {
it('creates offscreen window with correct size', (done) => {
w.webContents.once('paint', function (event, rect, data) {
assert.notStrictEqual(data.length, 0)
let size = data.getSize()
const size = data.getSize()
assertWithinDelta(size.width, 100, 2, 'width')
assertWithinDelta(size.height, 100, 2, 'height')
done()
@@ -3450,7 +3450,7 @@ describe('BrowserWindow module', () => {
})
it('is false for regular window', () => {
let c = new BrowserWindow({ show: false })
const c = new BrowserWindow({ show: false })
assert.strictEqual(c.webContents.isOffscreen(), false)
c.destroy()
})

View File

@@ -412,7 +412,7 @@ const waitForCrashReport = () => {
const startServer = ({ callback, processType, done }) => {
let called = false
let server = http.createServer((req, res) => {
const server = http.createServer((req, res) => {
const form = new multiparty.Form()
form.parse(req, (error, fields) => {
if (error) throw error

View File

@@ -71,7 +71,7 @@ describe('deprecations', () => {
deprecations.setHandler(m => { msg = m })
const prop = 'itMustGo'
let o = { [prop]: 0 }
const o = { [prop]: 0 }
deprecate.removeProperty(o, prop)
@@ -88,7 +88,7 @@ describe('deprecations', () => {
const key = 'foo'
const val = 'bar'
let o = { [key]: val }
const o = { [key]: val }
deprecate.removeProperty(o, key)
for (let i = 0; i < 3; ++i) {
@@ -104,7 +104,7 @@ describe('deprecations', () => {
const oldProp = 'dingyOldName'
const newProp = 'shinyNewName'
let o = { [oldProp]: 0 }
const o = { [oldProp]: 0 }
deprecate.renameProperty(o, oldProp, newProp)
expect(msg).to.be.a('string')

View File

@@ -49,10 +49,10 @@ describe('MenuItems', () => {
})
describe('MenuItem group properties', () => {
let template = []
const template = []
const findRadioGroups = (template) => {
let groups = []
const groups = []
let cur = null
for (let i = 0; i <= template.length; i++) {
if (cur && ((i === template.length) || (template[i].type !== 'radio'))) {
@@ -68,7 +68,7 @@ describe('MenuItems', () => {
// returns array of checked menuitems in [begin,end)
const findChecked = (menuItems, begin, end) => {
let checked = []
const checked = []
for (let i = begin; i < end; i++) {
if (menuItems[i].checked) checked.push(i)
}
@@ -107,7 +107,7 @@ describe('MenuItems', () => {
it('should assign groupId automatically', () => {
const menu = Menu.buildFromTemplate(template)
let usedGroupIds = new Set()
const usedGroupIds = new Set()
const groups = findRadioGroups(template)
groups.forEach(g => {
const groupId = menu.items[g.begin].groupId
@@ -143,7 +143,7 @@ describe('MenuItems', () => {
describe('MenuItem role execution', () => {
it('does not try to execute roles without a valid role property', () => {
let win = new BrowserWindow({ show: false, width: 200, height: 200 })
let item = new MenuItem({ role: 'asdfghjkl' })
const item = new MenuItem({ role: 'asdfghjkl' })
const canExecute = roles.execute(item.role, win, win.webContents)
expect(canExecute).to.be.false()
@@ -153,7 +153,7 @@ describe('MenuItems', () => {
it('executes roles with native role functions', () => {
let win = new BrowserWindow({ show: false, width: 200, height: 200 })
let item = new MenuItem({ role: 'reload' })
const item = new MenuItem({ role: 'reload' })
const canExecute = roles.execute(item.role, win, win.webContents)
expect(canExecute).to.be.true()
@@ -163,7 +163,7 @@ describe('MenuItems', () => {
it('execute roles with non-native role functions', () => {
let win = new BrowserWindow({ show: false, width: 200, height: 200 })
let item = new MenuItem({ role: 'resetzoom' })
const item = new MenuItem({ role: 'resetzoom' })
const canExecute = roles.execute(item.role, win, win.webContents)
expect(canExecute).to.be.true()
@@ -229,7 +229,7 @@ describe('MenuItems', () => {
'zoomout'
]
for (let role in roleList) {
for (const role in roleList) {
const item = new MenuItem({ role })
expect(item.getDefaultRoleAccelerator()).to.be.undefined()
}
@@ -258,7 +258,7 @@ describe('MenuItems', () => {
'zoomout': 'Zoom Out'
}
for (let role in roleList) {
for (const role in roleList) {
const item = new MenuItem({ role })
expect(item.label).to.equal(roleList[role])
}
@@ -287,7 +287,7 @@ describe('MenuItems', () => {
'zoomout': 'CommandOrControl+-'
}
for (let role in roleList) {
for (const role in roleList) {
const item = new MenuItem({ role })
expect(item.getDefaultRoleAccelerator()).to.equal(roleList[role])
}

View File

@@ -97,7 +97,7 @@ describe('netLog module', () => {
return
}
let appProcess = ChildProcess.spawn(remote.process.execPath,
const appProcess = ChildProcess.spawn(remote.process.execPath,
[appPath, `--log-net-log=${dumpFile}`], {
env: {
TEST_REQUEST_URL: server.url
@@ -116,7 +116,7 @@ describe('netLog module', () => {
return
}
let appProcess = ChildProcess.spawn(remote.process.execPath,
const appProcess = ChildProcess.spawn(remote.process.execPath,
[appPath, `--log-net-log=${dumpFile}`], {
env: {
TEST_REQUEST_URL: server.url,
@@ -142,7 +142,7 @@ describe('netLog module', () => {
return
}
let appProcess = ChildProcess.spawn(remote.process.execPath,
const appProcess = ChildProcess.spawn(remote.process.execPath,
[appPath], {
env: {
TEST_REQUEST_URL: server.url,

View File

@@ -12,7 +12,7 @@ const { session } = remote
function randomBuffer (size, start, end) {
start = start || 0
end = end || 255
let range = 1 + end - start
const range = 1 + end - start
const buffer = Buffer.allocUnsafe(size)
for (let i = 0; i < size; ++i) {
buffer[i] = start + Math.floor(Math.random() * range)
@@ -21,7 +21,7 @@ function randomBuffer (size, start, end) {
}
function randomString (length) {
let buffer = randomBuffer(length, '0'.charCodeAt(0), 'z'.charCodeAt(0))
const buffer = randomBuffer(length, '0'.charCodeAt(0), 'z'.charCodeAt(0))
return buffer.toString()
}
@@ -209,8 +209,8 @@ describe('net module', () => {
let chunkIndex = 0
const chunkCount = 100
let sentChunks = []
let receivedChunks = []
const sentChunks = []
const receivedChunks = []
urlRequest.on('response', (response) => {
assert.strictEqual(response.statusCode, 200)
response.pause()
@@ -218,8 +218,8 @@ describe('net module', () => {
receivedChunks.push(chunk)
})
response.on('end', () => {
let sentData = Buffer.concat(sentChunks)
let receivedData = Buffer.concat(receivedChunks)
const sentData = Buffer.concat(sentChunks)
const receivedData = Buffer.concat(receivedChunks)
assert.strictEqual(sentData.toString(), receivedData.toString())
assert.strictEqual(chunkIndex, chunkCount)
done()
@@ -285,14 +285,14 @@ describe('net module', () => {
requestResponseEventEmitted = true
const statusCode = response.statusCode
assert.strictEqual(statusCode, 200)
let buffers = []
const buffers = []
response.pause()
response.on('data', (chunk) => {
buffers.push(chunk)
responseDataEventEmitted = true
})
response.on('end', () => {
let receivedBodyData = Buffer.concat(buffers)
const receivedBodyData = Buffer.concat(buffers)
assert(receivedBodyData.toString() === bodyData)
responseEndEventEmitted = true
maybeDone(done)
@@ -907,7 +907,7 @@ describe('net module', () => {
assert.fail('Request should not be intercepted by the default session')
})
let customSession = session.fromPartition(customPartitionName, { cache: false })
const customSession = session.fromPartition(customPartitionName, { cache: false })
let requestIsIntercepted = false
customSession.webRequest.onBeforeRequest((details, callback) => {
if (details.url === `${server.url}${requestUrl}`) {
@@ -1189,7 +1189,7 @@ describe('net module', () => {
assert.fail('Request should not be intercepted by the default session')
})
let customSession = session.fromPartition(customPartitionName, {
const customSession = session.fromPartition(customPartitionName, {
cache: false
})
let requestIsIntercepted = false
@@ -1260,7 +1260,7 @@ describe('net module', () => {
})
const serverUrl = url.parse(server.url)
let options = {
const options = {
port: serverUrl.port,
hostname: '127.0.0.1',
headers: {}
@@ -1312,7 +1312,7 @@ describe('net module', () => {
}
})
let nodeRequest = http.request(`${server.url}${nodeRequestUrl}`)
const nodeRequest = http.request(`${server.url}${nodeRequestUrl}`)
nodeRequest.on('response', (nodeResponse) => {
const netRequest = net.request(`${server.url}${netRequestUrl}`)
netRequest.on('response', (netResponse) => {
@@ -1470,7 +1470,7 @@ describe('net module', () => {
it('should not emit any event after close', (done) => {
const requestUrl = '/requestUrl'
let bodyData = randomString(kOneKiloByte)
const bodyData = randomString(kOneKiloByte)
server.on('request', (request, response) => {
switch (request.url) {
case requestUrl:

View File

@@ -62,10 +62,10 @@ const skip = process.platform !== 'linux' ||
}
function unmarshalDBusNotifyHints (dbusHints) {
let o = {}
for (let hint of dbusHints) {
let key = hint[0]
let value = hint[1][1][0]
const o = {}
for (const hint of dbusHints) {
const key = hint[0]
const value = hint[1][1][0]
o[key] = value
}
return o
@@ -102,11 +102,11 @@ const skip = process.platform !== 'linux' ||
const calls = await getCalls()
expect(calls).to.be.an('array').of.lengthOf.at.least(1)
let lastCall = calls[calls.length - 1]
let methodName = lastCall[1]
const lastCall = calls[calls.length - 1]
const methodName = lastCall[1]
expect(methodName).to.equal('Notify')
let args = unmarshalDBusNotifyArgs(lastCall[2])
const args = unmarshalDBusNotifyArgs(lastCall[2])
expect(args).to.deep.equal({
app_name: appName,
replaces_id: 0,

View File

@@ -1036,7 +1036,7 @@ describe('protocol module', () => {
})
it('can access files through the FileSystem API', (done) => {
let filePath = path.join(__dirname, 'fixtures', 'pages', 'filesystem.html')
const filePath = path.join(__dirname, 'fixtures', 'pages', 'filesystem.html')
const handler = (request, callback) => callback({ path: filePath })
protocol.registerFileProtocol(standardScheme, handler, (error) => {
if (error) return done(error)
@@ -1047,7 +1047,7 @@ describe('protocol module', () => {
})
it('registers secure, when {secure: true}', (done) => {
let filePath = path.join(__dirname, 'fixtures', 'pages', 'cache-storage.html')
const filePath = path.join(__dirname, 'fixtures', 'pages', 'cache-storage.html')
const handler = (request, callback) => callback({ path: filePath })
ipcMain.once('success', () => done())
ipcMain.once('failure', (event, err) => done(err))

View File

@@ -228,7 +228,7 @@ describe('remote module', () => {
})
it('is referenced by its members', () => {
let stringify = remote.getGlobal('JSON').stringify
const stringify = remote.getGlobal('JSON').stringify
global.gc()
stringify({})
})
@@ -451,13 +451,13 @@ describe('remote module', () => {
assert.strictEqual(derived.method(), 'method')
assert.strictEqual(derived.readonly, 'readonly')
assert(!derived.hasOwnProperty('method'))
let proto = Object.getPrototypeOf(derived)
const proto = Object.getPrototypeOf(derived)
assert(!proto.hasOwnProperty('method'))
assert(Object.getPrototypeOf(proto).hasOwnProperty('method'))
})
it('is referenced by methods in prototype chain', () => {
let method = derived.method
const method = derived.method
derived = null
global.gc()
assert.strictEqual(method(), 'method')
@@ -474,7 +474,7 @@ describe('remote module', () => {
})
it('throws custom errors from the main process', () => {
let err = new Error('error')
const err = new Error('error')
err.cause = new Error('cause')
err.prop = 'error prop'
try {

View File

@@ -537,7 +537,7 @@ describe('session module', () => {
if (request.method === 'GET') {
callback({ data: content, mimeType: 'text/html' })
} else if (request.method === 'POST') {
let uuid = request.uploadData[1].blobUUID
const uuid = request.uploadData[1].blobUUID
assert(uuid)
session.defaultSession.getBlobData(uuid, (result) => {
assert.strictEqual(result.toString(), postData)
@@ -648,7 +648,7 @@ describe('session module', () => {
const fixtures = path.join(__dirname, 'fixtures')
const downloadFilePath = path.join(fixtures, 'logo.png')
const rangeServer = http.createServer((req, res) => {
let options = { root: fixtures }
const options = { root: fixtures }
send(req, req.url, options)
.on('error', (error) => { done(error) }).pipe(res)
})

View File

@@ -11,7 +11,7 @@ describe('systemPreferences module', () => {
})
it('should return a non-empty string', () => {
let accentColor = systemPreferences.getAccentColor()
const accentColor = systemPreferences.getAccentColor()
assert.notStrictEqual(accentColor, null)
assert(accentColor.length > 0)
})

View File

@@ -103,7 +103,7 @@ describe('webContents module', () => {
describe('setDevToolsWebContents() API', () => {
it('sets arbitry webContents as devtools', (done) => {
let devtools = new BrowserWindow({ show: false })
const devtools = new BrowserWindow({ show: false })
devtools.webContents.once('dom-ready', () => {
assert.ok(devtools.getURL().startsWith('chrome-devtools://devtools'))
devtools.webContents.executeJavaScript('InspectorFrontendHost.constructor.name', (name) => {
@@ -756,7 +756,7 @@ describe('webContents module', () => {
}
}
let gen = genNavigationEvent()
const gen = genNavigationEvent()
ipcRenderer.on(responseEvent, () => {
if (!gen.next().value) done()
})

View File

@@ -34,7 +34,7 @@ describe('chromium feature', () => {
const appPath = path.join(__dirname, 'fixtures', 'api', 'locale-check')
const electronPath = remote.getGlobal('process').execPath
let output = ''
let appProcess = ChildProcess.spawn(electronPath, [appPath, `--lang=${locale}`])
const appProcess = ChildProcess.spawn(electronPath, [appPath, `--lang=${locale}`])
appProcess.stdout.on('data', (data) => { output += data })
appProcess.stdout.on('end', () => {
@@ -175,7 +175,7 @@ describe('chromium feature', () => {
describe('navigator.languages', (done) => {
it('should return the system locale only', () => {
let appLocale = app.getLocale()
const appLocale = app.getLocale()
assert.strictEqual(navigator.languages.length, 1)
assert.strictEqual(navigator.languages[0], appLocale)
})
@@ -294,7 +294,7 @@ describe('chromium feature', () => {
})
it('accepts "nodeIntegration" as feature', (done) => {
let b
let b = null
listener = (event) => {
assert.strictEqual(event.data.isProcessGlobalUndefined, true)
b.close()
@@ -305,7 +305,7 @@ describe('chromium feature', () => {
})
it('inherit options of parent window', (done) => {
let b
let b = null
listener = (event) => {
const ref1 = remote.getCurrentWindow().getSize()
const width = ref1[0]
@@ -339,7 +339,7 @@ describe('chromium feature', () => {
}
it('disables node integration when it is disabled on the parent window', (done) => {
let b
let b = null
listener = (event) => {
assert.strictEqual(event.data.isProcessGlobalUndefined, true)
b.close()
@@ -359,7 +359,7 @@ describe('chromium feature', () => {
})
it('disables webviewTag when node integration is disabled on the parent window', (done) => {
let b
let b = null
listener = (event) => {
assert.strictEqual(event.data.isWebViewUndefined, true)
b.close()
@@ -380,7 +380,7 @@ describe('chromium feature', () => {
// TODO(codebytere): re-enable this test
xit('disables node integration when it is disabled on the parent window for chrome devtools URLs', (done) => {
let b
let b = null
app.once('web-contents-created', (event, contents) => {
contents.once('did-finish-load', () => {
contents.executeJavaScript('typeof process').then((typeofProcessGlobal) => {
@@ -394,7 +394,7 @@ describe('chromium feature', () => {
})
it('disables JavaScript when it is disabled on the parent window', (done) => {
let b
let b = null
app.once('web-contents-created', (event, contents) => {
contents.once('did-finish-load', () => {
app.once('browser-window-created', (event, window) => {
@@ -419,7 +419,7 @@ describe('chromium feature', () => {
})
it('disables the <webview> tag when it is disabled on the parent window', (done) => {
let b
let b = null
listener = (event) => {
assert.strictEqual(event.data.isWebViewGlobalUndefined, true)
b.close()
@@ -439,7 +439,7 @@ describe('chromium feature', () => {
})
it('does not override child options', (done) => {
let b
let b = null
const size = {
width: 350,
height: 450
@@ -476,7 +476,7 @@ describe('chromium feature', () => {
})
it('defines a window.location getter', (done) => {
let b
let b = null
let targetURL
if (process.platform === 'win32') {
targetURL = `file:///${fixtures.replace(/\\/g, '/')}/pages/base-page.html`
@@ -494,7 +494,7 @@ describe('chromium feature', () => {
})
it('defines a window.location setter', (done) => {
let b
let b = null
app.once('browser-window-created', (event, { webContents }) => {
webContents.once('did-finish-load', () => {
// When it loads, redirect
@@ -510,14 +510,14 @@ describe('chromium feature', () => {
})
it('open a blank page when no URL is specified', (done) => {
let b
let b = null
app.once('browser-window-created', (event, { webContents }) => {
webContents.once('did-finish-load', () => {
const { location } = b
b.close()
assert.strictEqual(location, 'about:blank')
let c
let c = null
app.once('browser-window-created', (event, { webContents }) => {
webContents.once('did-finish-load', () => {
const { location } = c
@@ -543,7 +543,7 @@ describe('chromium feature', () => {
})
it('sets the window title to the specified frameName', (done) => {
let b
let b = null
app.once('browser-window-created', (event, createdWindow) => {
assert.strictEqual(createdWindow.getTitle(), 'hello')
b.close()
@@ -553,7 +553,7 @@ describe('chromium feature', () => {
})
it('does not throw an exception when the frameName is a built-in object property', (done) => {
let b
let b = null
app.once('browser-window-created', (event, createdWindow) => {
assert.strictEqual(createdWindow.getTitle(), '__proto__')
b.close()
@@ -563,7 +563,7 @@ describe('chromium feature', () => {
})
it('does not throw an exception when the features include webPreferences', () => {
let b
let b = null
assert.doesNotThrow(() => {
b = window.open('', '', 'webPreferences=')
})
@@ -572,7 +572,7 @@ describe('chromium feature', () => {
})
describe('window.opener', () => {
let url = `file://${fixtures}/pages/window-opener.html`
const url = `file://${fixtures}/pages/window-opener.html`
it('is null for main window', (done) => {
w = new BrowserWindow({ show: false })
w.webContents.once('ipc-message', (event, args) => {
@@ -583,7 +583,7 @@ describe('chromium feature', () => {
})
it('is not null for window opened by window.open', (done) => {
let b
let b = null
listener = (event) => {
assert.strictEqual(event.data, 'object')
b.close()
@@ -596,7 +596,7 @@ describe('chromium feature', () => {
describe('window.opener access from BrowserWindow', () => {
const scheme = 'other'
let url = `${scheme}://${fixtures}/pages/window-opener-location.html`
const url = `${scheme}://${fixtures}/pages/window-opener-location.html`
let w = null
before((done) => {
@@ -720,7 +720,7 @@ describe('chromium feature', () => {
describe('window.postMessage', () => {
it('sets the source and origin correctly', (done) => {
let b
let b = null
listener = (event) => {
window.removeEventListener('message', listener)
b.close()
@@ -751,7 +751,7 @@ describe('chromium feature', () => {
describe('window.opener.postMessage', () => {
it('sets source and origin correctly', (done) => {
let b
let b = null
listener = (event) => {
window.removeEventListener('message', listener)
b.close()
@@ -803,7 +803,7 @@ describe('chromium feature', () => {
})
it('delivers messages that match the origin', (done) => {
let b
let b = null
listener = (event) => {
window.removeEventListener('message', listener)
b.close()
@@ -856,7 +856,7 @@ describe('chromium feature', () => {
})
it('Worker has no node integration by default', (done) => {
let worker = new Worker('../fixtures/workers/worker_node.js')
const worker = new Worker('../fixtures/workers/worker_node.js')
worker.onmessage = (event) => {
assert.strictEqual(event.data, 'undefined undefined undefined undefined')
worker.terminate()
@@ -865,7 +865,7 @@ describe('chromium feature', () => {
})
it('Worker has node integration with nodeIntegrationInWorker', (done) => {
let webview = new WebView()
const webview = new WebView()
webview.addEventListener('ipc-message', (e) => {
assert.strictEqual(e.channel, 'object function object function')
webview.remove()
@@ -887,7 +887,7 @@ describe('chromium feature', () => {
})
it('SharedWorker has no node integration by default', (done) => {
let worker = new SharedWorker('../fixtures/workers/shared_worker_node.js')
const worker = new SharedWorker('../fixtures/workers/shared_worker_node.js')
worker.port.onmessage = (event) => {
assert.strictEqual(event.data, 'undefined undefined undefined undefined')
done()
@@ -895,7 +895,7 @@ describe('chromium feature', () => {
})
it('SharedWorker has node integration with nodeIntegrationInWorker', (done) => {
let webview = new WebView()
const webview = new WebView()
webview.addEventListener('console-message', (e) => {
console.log(e)
})
@@ -944,7 +944,7 @@ describe('chromium feature', () => {
let contents = null
before((done) => {
const handler = (request, callback) => {
let parsedUrl = url.parse(request.url)
const parsedUrl = url.parse(request.url)
let filename
switch (parsedUrl.pathname) {
case '/localStorage' : filename = 'local_storage.html'; break

View File

@@ -15,7 +15,7 @@ let currentWindowSandboxed = false
app.once('ready', () => {
function testWindow (isSandboxed, callback) {
currentWindowSandboxed = isSandboxed
let currentWindow = new BrowserWindow({
const currentWindow = new BrowserWindow({
show: false,
webPreferences: {
preload: path.join(__dirname, 'electron-app-mixed-sandbox-preload.js'),

View File

@@ -8,7 +8,7 @@ process.on('uncaughtException', () => {
})
app.once('ready', () => {
let lastArg = process.argv[process.argv.length - 1]
const lastArg = process.argv[process.argv.length - 1]
const client = net.connect(socketPath)
client.once('connect', () => {
client.end(String(lastArg === '--second'))

View File

@@ -1,5 +1,5 @@
self.onconnect = function (event) {
let port = event.ports[0]
const port = event.ports[0]
port.start()
port.postMessage([typeof process, typeof setImmediate, typeof global, typeof Buffer].join(' '))
}

View File

@@ -131,7 +131,7 @@ describe('modules support', () => {
describe('when the path is outside the resources path', () => {
it('includes paths outside of the resources path', () => {
let modulePath = path.resolve('/foo')
const modulePath = path.resolve('/foo')
assert.deepStrictEqual(Module._nodeModulePaths(modulePath), [
path.join(modulePath, 'node_modules'),
path.resolve('/node_modules')

View File

@@ -331,10 +331,10 @@ describe('node feature', () => {
const key = 'q90K9yBqhWZnAMCMTOJfPQ=='
const cipherText = '{"error_code":114,"error_message":"Tham số không hợp lệ","data":null}'
for (let i = 0; i < 10000; ++i) {
let iv = Buffer.from('0'.repeat(32), 'hex')
let input = Buffer.from(data, 'base64')
let decipher = crypto.createDecipheriv('aes-128-cbc', Buffer.from(key, 'base64'), iv)
let result = Buffer.concat([decipher.update(input), decipher.final()]).toString('utf8')
const iv = Buffer.from('0'.repeat(32), 'hex')
const input = Buffer.from(data, 'base64')
const decipher = crypto.createDecipheriv('aes-128-cbc', Buffer.from(key, 'base64'), iv)
const result = Buffer.concat([decipher.update(input), decipher.final()]).toString('utf8')
assert.strictEqual(cipherText, result)
}
})

View File

@@ -56,7 +56,7 @@ if (process.platform !== 'darwin') {
// Write output to file if OUTPUT_TO_FILE is defined.
const outputToFile = process.env.OUTPUT_TO_FILE
const print = function (_, args) {
let output = util.format.apply(null, args)
const output = util.format.apply(null, args)
if (outputToFile) {
fs.appendFileSync(outputToFile, output + '\n')
} else {
@@ -398,7 +398,7 @@ ipcMain.on('test-webcontents-navigation-observer', (event, options) => {
})
ipcMain.on('test-browserwindow-destroy', (event, testOptions) => {
let focusListener = (event, win) => win.id
const focusListener = (event, win) => win.id
app.on('browser-window-focus', focusListener)
const windowCount = 3
const windowOptions = {

View File

@@ -987,7 +987,7 @@ describe('<webview> tag', function () {
describe('found-in-page event', () => {
it('emits when a request is made', (done) => {
let requestId = null
let activeMatchOrdinal = []
const activeMatchOrdinal = []
const listener = (e) => {
assert.strictEqual(e.result.requestId, requestId)
assert.strictEqual(e.result.matches, 3)
@@ -1157,7 +1157,7 @@ describe('<webview> tag', function () {
it('inherits the parent window visibility state and receives visibilitychange events', async () => {
const w = await openTheWindow({ show: false })
w.loadFile(path.join(fixtures, 'pages', 'webview-visibilitychange.html'))
let [, visibilityState, hidden] = await emittedOnce(ipcMain, 'pong')
const [, visibilityState, hidden] = await emittedOnce(ipcMain, 'pong')
assert.strictEqual(visibilityState, 'hidden')
assert.strictEqual(hidden, true)