Merge pull request #14613 from electron/update-standard

chore: update to standard 12 and fix CI
This commit is contained in:
John Kleinschmidt 2018-09-14 10:26:15 -04:00 committed by GitHub
commit 451b1782ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
201 changed files with 4482 additions and 2943 deletions

View file

@ -119,6 +119,7 @@ build-steps: &build-steps
if [ "$RUN_TESTS" != "false" ]; then
cd src
ninja -C out/Default third_party/electron_node:headers
export ELECTRON_OUT_DIR=Default
(cd electron && npm run test -- --ci --enable-logging)
fi
- <<: *notify-slack-failure
@ -195,6 +196,7 @@ mac-build-steps: &mac-build-steps
if [ "$RUN_TESTS" != "false" ]; then
cd src
ninja -C out/Default third_party/electron_node:headers
export ELECTRON_OUT_DIR=Default
(cd electron && npm run test -- --ci --enable-logging)
fi
- <<: *notify-slack-failure

View file

@ -4,6 +4,7 @@ image: libcc-20-vs2017-15.7.4
environment:
GIT_CACHE_PATH: C:\Users\electron\libcc_cache
DISABLE_CRASH_REPORTER_TESTS: true
ELECTRON_OUT_DIR: Default
build_script:
- ps: >-
if(($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME -split "/")[0] -eq ($env:APPVEYOR_REPO_NAME -split "/")[0]) {

View file

@ -28,8 +28,7 @@ desktopCapturer.getSources({types: ['window', 'screen']}, (error, sources) => {
maxHeight: 720
}
}
})
.then((stream) => handleStream(stream))
}).then((stream) => handleStream(stream))
.catch((e) => handleError(e))
return
}

View file

@ -253,7 +253,7 @@ const {remote} = require('electron')
const { Menu, MenuItem } = remote
const menu = new Menu()
menu.append(new MenuItem({label: 'MenuItem1', click() { console.log('item 1 clicked') }}))
menu.append(new MenuItem({ label: 'MenuItem1', click() { console.log('item 1 clicked') } })))
menu.append(new MenuItem({ type: 'separator' }))
menu.append(new MenuItem({ label: 'MenuItem2', type: 'checkbox', checked: true }))

View file

@ -32,13 +32,13 @@ app.start().then(function () {
return app.browserWindow.isVisible()
}).then(function (isVisible) {
// Verify the window is visible
assert.equal(isVisible, true)
assert.strictEqual(isVisible, true)
}).then(function () {
// Get the window's title
return app.client.getTitle()
}).then(function (title) {
// Verify the window's title
assert.equal(title, 'My App')
assert.strictEqual(title, 'My App')
}).catch(function (error) {
// Log any failures
console.error('Test failed', error.message)

2604
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -29,8 +29,8 @@
"request": "^2.88.0",
"semver": "^5.5.0",
"serve": "^6.5.8",
"standard": "^10.0.0",
"standard-markdown": "^4.0.0",
"standard": "^12.0.0",
"standard-markdown": "^5.0.0",
"sumchecker": "^2.0.2",
"temp": "^0.8.3"
},

File diff suppressed because it is too large Load diff

View file

@ -129,7 +129,7 @@ describe('crashReporter module', () => {
const dumps = files.filter((file) => /\.dmp$/.test(file) && !existingDumpFiles.has(file))
if (!dumps.length) return
assert.equal(1, dumps.length)
assert.strictEqual(1, dumps.length)
dumpFile = path.join(crashesDir, dumps[0])
clearInterval(pollInterval)
// dump file should not be deleted when not uploading, so we wait
@ -200,14 +200,14 @@ describe('crashReporter module', () => {
it('returns the product name if one is specified', () => {
const name = crashReporter.getProductName()
const expectedName = (process.platform === 'darwin') ? 'Electron Test' : 'Zombies'
assert.equal(name, expectedName)
assert.strictEqual(name, expectedName)
})
})
describe('getTempDirectory', () => {
it('returns temp directory for app if one is specified', () => {
const tempDir = crashReporter.getTempDirectory()
assert.equal(tempDir, app.getPath('temp'))
assert.strictEqual(tempDir, app.getPath('temp'))
})
})
@ -244,7 +244,7 @@ describe('crashReporter module', () => {
} else {
dir = `${app.getPath('temp')}/Electron Test Crashes`
}
assert.equal(crashesDir, dir)
assert.strictEqual(crashesDir, dir)
})
})
@ -299,7 +299,7 @@ describe('crashReporter module', () => {
submitURL: 'http://127.0.0.1/crashes',
uploadToServer: true
})
assert.equal(crashReporter.getUploadToServer(), true)
assert.strictEqual(crashReporter.getUploadToServer(), true)
})
it('returns false when uploadToServer is set to false', function () {
if (process.platform !== 'darwin') {
@ -314,7 +314,7 @@ describe('crashReporter module', () => {
uploadToServer: true
})
crashReporter.setUploadToServer(false)
assert.equal(crashReporter.getUploadToServer(), false)
assert.strictEqual(crashReporter.getUploadToServer(), false)
})
})
@ -335,7 +335,7 @@ describe('crashReporter module', () => {
uploadToServer: true
})
crashReporter.setUploadToServer(false)
assert.equal(crashReporter.getUploadToServer(), false)
assert.strictEqual(crashReporter.getUploadToServer(), false)
})
it('sets uploadToServer true when called with true', function () {
if (process.platform !== 'darwin') {
@ -350,7 +350,7 @@ describe('crashReporter module', () => {
uploadToServer: false
})
crashReporter.setUploadToServer(true)
assert.equal(crashReporter.getUploadToServer(), true)
assert.strictEqual(crashReporter.getUploadToServer(), true)
})
})
@ -425,23 +425,23 @@ const startServer = ({callback, processType, done}) => {
if (error) throw error
if (called) return
called = true
assert.equal(fields.prod, 'Electron')
assert.equal(fields.ver, process.versions.electron)
assert.equal(fields.process_type, processType)
assert.equal(fields.platform, process.platform)
assert.equal(fields.extra1, 'extra1')
assert.equal(fields.extra2, 'extra2')
assert.equal(fields.extra3, undefined)
assert.equal(fields._productName, 'Zombies')
assert.equal(fields._companyName, 'Umbrella Corporation')
assert.equal(fields._version, app.getVersion())
assert.deepStrictEqual(String(fields.prod), 'Electron')
assert.strictEqual(String(fields.ver), process.versions.electron)
assert.strictEqual(String(fields.process_type), processType)
assert.strictEqual(String(fields.platform), process.platform)
assert.strictEqual(String(fields.extra1), 'extra1')
assert.strictEqual(String(fields.extra2), 'extra2')
assert.strictEqual(fields.extra3, undefined)
assert.strictEqual(String(fields._productName), 'Zombies')
assert.strictEqual(String(fields._companyName), 'Umbrella Corporation')
assert.strictEqual(String(fields._version), app.getVersion())
const reportId = 'abc-123-def-456-abc-789-abc-123-abcd'
res.end(reportId, () => {
waitForCrashReport().then(() => {
assert.equal(crashReporter.getLastCrashReport().id, reportId)
assert.notEqual(crashReporter.getUploadedReports().length, 0)
assert.equal(crashReporter.getUploadedReports()[0].id, reportId)
assert.strictEqual(crashReporter.getLastCrashReport().id, reportId)
assert.notStrictEqual(crashReporter.getUploadedReports().length, 0)
assert.strictEqual(crashReporter.getUploadedReports()[0].id, reportId)
req.socket.destroy()
done()
}, done)

View file

@ -62,7 +62,7 @@ describe('net module', () => {
server.on('request', (request, response) => {
switch (request.url) {
case requestUrl:
assert.equal(request.method, 'GET')
assert.strictEqual(request.method, 'GET')
response.end()
break
default:
@ -71,7 +71,7 @@ describe('net module', () => {
})
const urlRequest = net.request(`${server.url}${requestUrl}`)
urlRequest.on('response', (response) => {
assert.equal(response.statusCode, 200)
assert.strictEqual(response.statusCode, 200)
response.pause()
response.on('data', (chunk) => {
})
@ -88,7 +88,7 @@ describe('net module', () => {
server.on('request', (request, response) => {
switch (request.url) {
case requestUrl:
assert.equal(request.method, 'POST')
assert.strictEqual(request.method, 'POST')
response.end()
break
default:
@ -100,7 +100,7 @@ describe('net module', () => {
url: `${server.url}${requestUrl}`
})
urlRequest.on('response', (response) => {
assert.equal(response.statusCode, 200)
assert.strictEqual(response.statusCode, 200)
response.pause()
response.on('data', (chunk) => {
})
@ -118,7 +118,7 @@ describe('net module', () => {
server.on('request', (request, response) => {
switch (request.url) {
case requestUrl:
assert.equal(request.method, 'GET')
assert.strictEqual(request.method, 'GET')
response.write(bodyData)
response.end()
break
@ -129,13 +129,13 @@ describe('net module', () => {
const urlRequest = net.request(`${server.url}${requestUrl}`)
urlRequest.on('response', (response) => {
let expectedBodyData = ''
assert.equal(response.statusCode, 200)
assert.strictEqual(response.statusCode, 200)
response.pause()
response.on('data', (chunk) => {
expectedBodyData += chunk.toString()
})
response.on('end', () => {
assert.equal(expectedBodyData, bodyData)
assert.strictEqual(expectedBodyData, bodyData)
done()
})
response.resume()
@ -150,12 +150,12 @@ describe('net module', () => {
let postedBodyData = ''
switch (request.url) {
case requestUrl:
assert.equal(request.method, 'POST')
assert.strictEqual(request.method, 'POST')
request.on('data', (chunk) => {
postedBodyData += chunk.toString()
})
request.on('end', () => {
assert.equal(postedBodyData, bodyData)
assert.strictEqual(postedBodyData, bodyData)
response.end()
})
break
@ -168,7 +168,7 @@ describe('net module', () => {
url: `${server.url}${requestUrl}`
})
urlRequest.on('response', (response) => {
assert.equal(response.statusCode, 200)
assert.strictEqual(response.statusCode, 200)
response.pause()
response.on('data', (chunk) => {})
response.on('end', () => {
@ -188,8 +188,8 @@ describe('net module', () => {
response.statusCode = 200
response.statusMessage = 'OK'
response.chunkedEncoding = true
assert.equal(request.method, 'POST')
assert.equal(request.headers['transfer-encoding'], 'chunked')
assert.strictEqual(request.method, 'POST')
assert.strictEqual(request.headers['transfer-encoding'], 'chunked')
assert(!request.headers['content-length'])
request.on('data', (chunk) => {
response.write(chunk)
@ -212,7 +212,7 @@ describe('net module', () => {
let sentChunks = []
let receivedChunks = []
urlRequest.on('response', (response) => {
assert.equal(response.statusCode, 200)
assert.strictEqual(response.statusCode, 200)
response.pause()
response.on('data', (chunk) => {
receivedChunks.push(chunk)
@ -220,8 +220,8 @@ describe('net module', () => {
response.on('end', () => {
let sentData = Buffer.concat(sentChunks)
let receivedData = Buffer.concat(receivedChunks)
assert.equal(sentData.toString(), receivedData.toString())
assert.equal(chunkIndex, chunkCount)
assert.strictEqual(sentData.toString(), receivedData.toString())
assert.strictEqual(chunkIndex, chunkCount)
done()
})
response.resume()
@ -284,7 +284,7 @@ describe('net module', () => {
urlRequest.on('response', (response) => {
requestResponseEventEmitted = true
const statusCode = response.statusCode
assert.equal(statusCode, 200)
assert.strictEqual(statusCode, 200)
let buffers = []
response.pause()
response.on('data', (chunk) => {
@ -328,7 +328,7 @@ describe('net module', () => {
server.on('request', (request, response) => {
switch (request.url) {
case requestUrl:
assert.equal(request.headers[customHeaderName.toLowerCase()],
assert.strictEqual(request.headers[customHeaderName.toLowerCase()],
customHeaderValue)
response.statusCode = 200
response.statusMessage = 'OK'
@ -344,7 +344,7 @@ describe('net module', () => {
})
urlRequest.on('response', (response) => {
const statusCode = response.statusCode
assert.equal(statusCode, 200)
assert.strictEqual(statusCode, 200)
response.pause()
response.on('data', (chunk) => {
})
@ -354,14 +354,14 @@ describe('net module', () => {
response.resume()
})
urlRequest.setHeader(customHeaderName, customHeaderValue)
assert.equal(urlRequest.getHeader(customHeaderName),
assert.strictEqual(urlRequest.getHeader(customHeaderName),
customHeaderValue)
assert.equal(urlRequest.getHeader(customHeaderName.toLowerCase()),
assert.strictEqual(urlRequest.getHeader(customHeaderName.toLowerCase()),
customHeaderValue)
urlRequest.write('')
assert.equal(urlRequest.getHeader(customHeaderName),
assert.strictEqual(urlRequest.getHeader(customHeaderName),
customHeaderValue)
assert.equal(urlRequest.getHeader(customHeaderName.toLowerCase()),
assert.strictEqual(urlRequest.getHeader(customHeaderName.toLowerCase()),
customHeaderValue)
urlRequest.end()
})
@ -373,14 +373,14 @@ describe('net module', () => {
server.on('request', (request, response) => {
switch (request.url) {
case requestUrl:
assert.equal(request.headers[customHeaderName.toLowerCase()],
assert.strictEqual(request.headers[customHeaderName.toLowerCase()],
customHeaderValue.toString())
response.statusCode = 200
response.statusMessage = 'OK'
response.end()
break
default:
assert.equal(request.url, requestUrl)
assert.strictEqual(request.url, requestUrl)
}
})
const urlRequest = net.request({
@ -389,7 +389,7 @@ describe('net module', () => {
})
urlRequest.on('response', (response) => {
const statusCode = response.statusCode
assert.equal(statusCode, 200)
assert.strictEqual(statusCode, 200)
response.pause()
response.on('end', () => {
done()
@ -397,14 +397,14 @@ describe('net module', () => {
response.resume()
})
urlRequest.setHeader(customHeaderName, customHeaderValue)
assert.equal(urlRequest.getHeader(customHeaderName),
assert.strictEqual(urlRequest.getHeader(customHeaderName),
customHeaderValue)
assert.equal(urlRequest.getHeader(customHeaderName.toLowerCase()),
assert.strictEqual(urlRequest.getHeader(customHeaderName.toLowerCase()),
customHeaderValue)
urlRequest.write('')
assert.equal(urlRequest.getHeader(customHeaderName),
assert.strictEqual(urlRequest.getHeader(customHeaderName),
customHeaderValue)
assert.equal(urlRequest.getHeader(customHeaderName.toLowerCase()),
assert.strictEqual(urlRequest.getHeader(customHeaderName.toLowerCase()),
customHeaderValue)
urlRequest.end()
})
@ -431,7 +431,7 @@ describe('net module', () => {
})
urlRequest.on('response', (response) => {
const statusCode = response.statusCode
assert.equal(statusCode, 200)
assert.strictEqual(statusCode, 200)
response.pause()
response.on('data', (chunk) => {
})
@ -470,7 +470,7 @@ describe('net module', () => {
})
urlRequest.on('response', (response) => {
const statusCode = response.statusCode
assert.equal(statusCode, 200)
assert.strictEqual(statusCode, 200)
response.pause()
response.on('data', (chunk) => {
})
@ -480,7 +480,7 @@ describe('net module', () => {
response.resume()
})
urlRequest.setHeader(customHeaderName, customHeaderValue)
assert.equal(urlRequest.getHeader(customHeaderName),
assert.strictEqual(urlRequest.getHeader(customHeaderName),
customHeaderValue)
urlRequest.removeHeader(customHeaderName)
assert(!urlRequest.getHeader(customHeaderName))
@ -495,7 +495,7 @@ describe('net module', () => {
server.on('request', (request, response) => {
switch (request.url) {
case requestUrl:
assert.equal(request.headers[customHeaderName.toLowerCase()],
assert.strictEqual(request.headers[customHeaderName.toLowerCase()],
customHeaderValue)
response.statusCode = 200
response.statusMessage = 'OK'
@ -511,7 +511,7 @@ describe('net module', () => {
})
urlRequest.on('response', (response) => {
const statusCode = response.statusCode
assert.equal(statusCode, 200)
assert.strictEqual(statusCode, 200)
response.pause()
response.on('data', (chunk) => {
})
@ -521,13 +521,13 @@ describe('net module', () => {
response.resume()
})
urlRequest.setHeader(customHeaderName, customHeaderValue)
assert.equal(urlRequest.getHeader(customHeaderName),
assert.strictEqual(urlRequest.getHeader(customHeaderName),
customHeaderValue)
urlRequest.write('')
assert.throws(() => {
urlRequest.removeHeader(customHeaderName)
})
assert.equal(urlRequest.getHeader(customHeaderName),
assert.strictEqual(urlRequest.getHeader(customHeaderName),
customHeaderValue)
urlRequest.end()
})
@ -540,7 +540,7 @@ describe('net module', () => {
server.on('request', (request, response) => {
switch (request.url) {
case requestUrl:
assert.equal(request.headers[cookieHeaderName.toLowerCase()],
assert.strictEqual(request.headers[cookieHeaderName.toLowerCase()],
cookieHeaderValue)
response.statusCode = 200
response.statusMessage = 'OK'
@ -563,7 +563,7 @@ describe('net module', () => {
})
urlRequest.on('response', (response) => {
const statusCode = response.statusCode
assert.equal(statusCode, 200)
assert.strictEqual(statusCode, 200)
response.pause()
response.on('data', (chunk) => {})
response.on('end', () => {
@ -572,7 +572,7 @@ describe('net module', () => {
response.resume()
})
urlRequest.setHeader(cookieHeaderName, cookieHeaderValue)
assert.equal(urlRequest.getHeader(cookieHeaderName),
assert.strictEqual(urlRequest.getHeader(cookieHeaderName),
cookieHeaderValue)
urlRequest.end()
})
@ -746,7 +746,7 @@ describe('net module', () => {
urlRequest.on('response', (response) => {
requestResponseEventEmitted = true
const statusCode = response.statusCode
assert.equal(statusCode, 200)
assert.strictEqual(statusCode, 200)
response.pause()
response.on('data', (chunk) => {
})
@ -825,7 +825,7 @@ describe('net module', () => {
setTimeout(() => {
assert(requestFinishEventEmitted)
assert(requestReceivedByServer)
assert.equal(requestAbortEventCount, 1)
assert.strictEqual(requestAbortEventCount, 1)
assert(requestCloseEventEmitted)
done()
}, 500)
@ -873,7 +873,7 @@ describe('net module', () => {
const urlRequest = net.request(`${server.url}${requestUrl}`)
urlRequest.on('response', (response) => {
assert.equal(response.statusCode, 200)
assert.strictEqual(response.statusCode, 200)
response.pause()
response.on('data', (chunk) => {
})
@ -929,7 +929,7 @@ describe('net module', () => {
session: customSession
})
urlRequest.on('response', (response) => {
assert.equal(response.statusCode, 200)
assert.strictEqual(response.statusCode, 200)
response.pause()
response.on('data', (chunk) => {
})
@ -995,7 +995,7 @@ describe('net module', () => {
url: `${server.url}${requestUrl}`
})
urlRequest.on('response', (response) => {
assert.equal(response.statusCode, 200)
assert.strictEqual(response.statusCode, 200)
done()
})
urlRequest.end()
@ -1027,7 +1027,7 @@ describe('net module', () => {
url: `${server.url}${requestUrl}`
})
urlRequest.on('response', (response) => {
assert.equal(response.statusCode, 200)
assert.strictEqual(response.statusCode, 200)
done()
})
urlRequest.end()
@ -1055,7 +1055,7 @@ describe('net module', () => {
redirect: 'error'
})
urlRequest.on('error', (error) => {
assert.equal(error.message, 'Request cannot follow redirect with the current redirect mode')
assert.strictEqual(error.message, 'Request cannot follow redirect with the current redirect mode')
})
urlRequest.on('close', () => {
done()
@ -1091,8 +1091,8 @@ describe('net module', () => {
redirect: 'manual'
})
urlRequest.on('response', (response) => {
assert.equal(response.statusCode, 200)
assert.equal(redirectCount, 2)
assert.strictEqual(response.statusCode, 200)
assert.strictEqual(redirectCount, 2)
done()
})
urlRequest.on('redirect', (status, method, url) => {
@ -1132,7 +1132,7 @@ describe('net module', () => {
redirect: 'manual'
})
urlRequest.on('response', (response) => {
assert.equal(response.statusCode, 200)
assert.strictEqual(response.statusCode, 200)
response.pause()
response.on('data', (chunk) => {
})
@ -1142,7 +1142,7 @@ describe('net module', () => {
response.resume()
})
urlRequest.on('close', () => {
assert.equal(redirectCount, 1)
assert.strictEqual(redirectCount, 1)
done()
})
urlRequest.on('redirect', (status, method, url) => {
@ -1211,7 +1211,7 @@ describe('net module', () => {
partition: customPartitionName
})
urlRequest.on('response', (response) => {
assert.equal(response.statusCode, 200)
assert.strictEqual(response.statusCode, 200)
response.pause()
response.on('data', (chunk) => {
})
@ -1247,8 +1247,8 @@ describe('net module', () => {
server.on('request', (request, response) => {
switch (request.url) {
case requestUrl:
assert.equal(request.method, 'GET')
assert.equal(request.headers[customHeaderName.toLowerCase()],
assert.strictEqual(request.method, 'GET')
assert.strictEqual(request.headers[customHeaderName.toLowerCase()],
customHeaderValue)
response.statusCode = 200
response.statusMessage = 'OK'
@ -1268,7 +1268,7 @@ describe('net module', () => {
options.headers[customHeaderName] = customHeaderValue
const urlRequest = net.request(options)
urlRequest.on('response', (response) => {
assert.equal(response.statusCode, 200)
assert.strictEqual(response.statusCode, 200)
response.pause()
response.on('data', (chunk) => {
})
@ -1303,7 +1303,7 @@ describe('net module', () => {
if (chunk) {
receivedBodyData += chunk.toString()
}
assert.equal(receivedBodyData, bodyData)
assert.strictEqual(receivedBodyData, bodyData)
response.end()
})
break
@ -1316,7 +1316,7 @@ describe('net module', () => {
nodeRequest.on('response', (nodeResponse) => {
const netRequest = net.request(`${server.url}${netRequestUrl}`)
netRequest.on('response', (netResponse) => {
assert.equal(netResponse.statusCode, 200)
assert.strictEqual(netResponse.statusCode, 200)
netResponse.pause()
netResponse.on('data', (chunk) => {})
netResponse.on('end', () => {
@ -1380,13 +1380,13 @@ describe('net module', () => {
urlRequest.on('response', (response) => {
const statusCode = response.statusCode
assert(typeof statusCode === 'number')
assert.equal(statusCode, 200)
assert.strictEqual(statusCode, 200)
const statusMessage = response.statusMessage
assert(typeof statusMessage === 'string')
assert.equal(statusMessage, 'OK')
assert.strictEqual(statusMessage, 'OK')
const headers = response.headers
assert(typeof headers === 'object')
assert.deepEqual(headers[customHeaderName.toLowerCase()],
assert.deepStrictEqual(headers[customHeaderName.toLowerCase()],
[customHeaderValue])
const httpVersion = response.httpVersion
assert(typeof httpVersion === 'string')
@ -1429,7 +1429,7 @@ describe('net module', () => {
if (chunk) {
receivedBodyData += chunk.toString()
}
assert.equal(receivedBodyData, bodyData)
assert.strictEqual(receivedBodyData, bodyData)
response.end()
})
break
@ -1491,7 +1491,7 @@ describe('net module', () => {
urlRequest.on('response', (response) => {
assert(!requestCloseEventEmitted)
const statusCode = response.statusCode
assert.equal(statusCode, 200)
assert.strictEqual(statusCode, 200)
response.pause()
response.on('data', () => {
})

View file

@ -59,9 +59,9 @@ describe('protocol module', () => {
it('throws error when scheme is already registered', (done) => {
protocol.registerStringProtocol(protocolName, emptyHandler, (error) => {
assert.equal(error, null)
assert.strictEqual(error, null)
protocol.registerBufferProtocol(protocolName, emptyHandler, (error) => {
assert.notEqual(error, null)
assert.notStrictEqual(error, null)
done()
})
})
@ -83,7 +83,7 @@ describe('protocol module', () => {
url: protocolName + '://fake-host',
cache: false,
success: (data) => {
assert.equal(data, text)
assert.strictEqual(data, text)
done()
},
error: (xhr, errorType, error) => done(error)
@ -99,7 +99,7 @@ describe('protocol module', () => {
cache: false,
success: () => done('request succeeded but it should not'),
error: (xhr, errorType) => {
assert.equal(errorType, 'error')
assert.strictEqual(errorType, 'error')
return done()
}
})
@ -116,7 +116,7 @@ describe('protocol module', () => {
url: protocolName + '://fake-host',
cache: false,
success: (data) => {
assert.equal(data, text)
assert.strictEqual(data, text)
done()
},
error: (xhr, errorType, error) => done(error)
@ -128,7 +128,7 @@ describe('protocol module', () => {
describe('protocol.unregisterProtocol', () => {
it('returns error when scheme does not exist', (done) => {
protocol.unregisterProtocol('not-exist', (error) => {
assert.notEqual(error, null)
assert.notStrictEqual(error, null)
done()
})
})
@ -143,7 +143,7 @@ describe('protocol module', () => {
url: protocolName + '://fake-host',
cache: false,
success: (data) => {
assert.equal(data, text)
assert.strictEqual(data, text)
done()
},
error: (xhr, errorType, error) => done(error)
@ -159,8 +159,8 @@ describe('protocol module', () => {
url: protocolName + '://fake-host',
cache: false,
success: (data, status, request) => {
assert.equal(data, text)
assert.equal(request.getResponseHeader('Access-Control-Allow-Origin'), '*')
assert.strictEqual(data, text)
assert.strictEqual(request.getResponseHeader('Access-Control-Allow-Origin'), '*')
done()
},
error: (xhr, errorType, error) => done(error)
@ -181,7 +181,7 @@ describe('protocol module', () => {
url: protocolName + '://fake-host',
cache: false,
success: (data) => {
assert.equal(data, text)
assert.strictEqual(data, text)
done()
},
error: (xhr, errorType, error) => done(error)
@ -198,7 +198,7 @@ describe('protocol module', () => {
cache: false,
success: () => done('request succeeded but it should not'),
error: (xhr, errorType) => {
assert.equal(errorType, 'error')
assert.strictEqual(errorType, 'error')
done()
}
})
@ -216,7 +216,7 @@ describe('protocol module', () => {
url: protocolName + '://fake-host',
cache: false,
success: (data) => {
assert.equal(data, text)
assert.strictEqual(data, text)
done()
},
error: (xhr, errorType, error) => done(error)
@ -232,8 +232,8 @@ describe('protocol module', () => {
url: protocolName + '://fake-host',
cache: false,
success: (data, status, request) => {
assert.equal(data, text)
assert.equal(request.getResponseHeader('Access-Control-Allow-Origin'), '*')
assert.strictEqual(data, text)
assert.strictEqual(request.getResponseHeader('Access-Control-Allow-Origin'), '*')
done()
},
error: (xhr, errorType, error) => done(error)
@ -254,7 +254,7 @@ describe('protocol module', () => {
url: protocolName + '://fake-host',
cache: false,
success: (data) => {
assert.equal(data, text)
assert.strictEqual(data, text)
done()
},
error: (xhr, errorType, error) => done(error)
@ -271,7 +271,7 @@ describe('protocol module', () => {
cache: false,
success: () => done('request succeeded but it should not'),
error: (xhr, errorType) => {
assert.equal(errorType, 'error')
assert.strictEqual(errorType, 'error')
done()
}
})
@ -293,7 +293,7 @@ describe('protocol module', () => {
url: protocolName + '://fake-host',
cache: false,
success: (data) => {
assert.equal(data, String(fileContent))
assert.strictEqual(data, String(fileContent))
return done()
},
error: (xhr, errorType, error) => done(error)
@ -309,8 +309,8 @@ describe('protocol module', () => {
url: protocolName + '://fake-host',
cache: false,
success: (data, status, request) => {
assert.equal(data, String(fileContent))
assert.equal(request.getResponseHeader('Access-Control-Allow-Origin'), '*')
assert.strictEqual(data, String(fileContent))
assert.strictEqual(request.getResponseHeader('Access-Control-Allow-Origin'), '*')
done()
},
error: (xhr, errorType, error) => {
@ -328,7 +328,7 @@ describe('protocol module', () => {
url: protocolName + '://fake-host',
cache: false,
success: (data) => {
assert.equal(data, String(fileContent))
assert.strictEqual(data, String(fileContent))
done()
},
error: (xhr, errorType, error) => done(error)
@ -344,7 +344,7 @@ describe('protocol module', () => {
url: protocolName + '://fake-host',
cache: false,
success: (data) => {
assert.equal(data, String(normalContent))
assert.strictEqual(data, String(normalContent))
done()
},
error: (xhr, errorType, error) => done(error)
@ -362,7 +362,7 @@ describe('protocol module', () => {
cache: false,
success: () => done('request succeeded but it should not'),
error: (xhr, errorType) => {
assert.equal(errorType, 'error')
assert.strictEqual(errorType, 'error')
done()
}
})
@ -378,7 +378,7 @@ describe('protocol module', () => {
cache: false,
success: () => done('request succeeded but it should not'),
error: (xhr, errorType) => {
assert.equal(errorType, 'error')
assert.strictEqual(errorType, 'error')
done()
}
})
@ -389,7 +389,7 @@ describe('protocol module', () => {
describe('protocol.registerHttpProtocol', () => {
it('sends url as response', (done) => {
const server = http.createServer((req, res) => {
assert.notEqual(req.headers.accept, '')
assert.notStrictEqual(req.headers.accept, '')
res.end(text)
server.close()
})
@ -403,7 +403,7 @@ describe('protocol module', () => {
url: protocolName + '://fake-host',
cache: false,
success: (data) => {
assert.equal(data, text)
assert.strictEqual(data, text)
done()
},
error: (xhr, errorType, error) => done(error)
@ -421,7 +421,7 @@ describe('protocol module', () => {
cache: false,
success: () => done('request succeeded but it should not'),
error: (xhr, errorType) => {
assert.equal(errorType, 'error')
assert.strictEqual(errorType, 'error')
done()
}
})
@ -439,7 +439,7 @@ describe('protocol module', () => {
done('request succeeded but it should not')
},
error: (xhr, errorType) => {
assert.equal(errorType, 'error')
assert.strictEqual(errorType, 'error')
done()
}
})
@ -466,7 +466,7 @@ describe('protocol module', () => {
if (error) return done(error)
contents = webContents.create({})
contents.on('did-finish-load', () => {
assert.equal(contents.getURL(), url)
assert.strictEqual(contents.getURL(), url)
server.close()
contents.destroy()
done()
@ -486,7 +486,7 @@ describe('protocol module', () => {
url: protocolName + '://fake-host',
cache: false,
success: (data) => {
assert.equal(data, text)
assert.strictEqual(data, text)
done()
},
error: (xhr, errorType, error) => {
@ -504,8 +504,8 @@ describe('protocol module', () => {
url: protocolName + '://fake-host',
cache: false,
success: (data, _, request) => {
assert.equal(request.status, 200)
assert.equal(data, text)
assert.strictEqual(request.status, 200)
assert.strictEqual(data, text)
done()
},
error: (xhr, errorType, error) => {
@ -528,9 +528,9 @@ describe('protocol module', () => {
url: protocolName + '://fake-host',
cache: false,
success: (data, _, request) => {
assert.equal(request.status, 200)
assert.equal(request.getResponseHeader('x-electron'), 'a,b')
assert.equal(data, text)
assert.strictEqual(request.status, 200)
assert.strictEqual(request.getResponseHeader('x-electron'), 'a,b')
assert.strictEqual(data, text)
done()
},
error: (xhr, errorType, error) => {
@ -551,8 +551,8 @@ describe('protocol module', () => {
url: protocolName + '://fake-host',
cache: false,
success: (data, _, request) => {
assert.equal(request.status, 204)
assert.equal(data, undefined)
assert.strictEqual(request.status, 204)
assert.strictEqual(data, undefined)
done()
},
error: (xhr, errorType, error) => {
@ -580,7 +580,7 @@ describe('protocol module', () => {
},
cache: false,
success: (data) => {
assert.equal(data['x-return-headers'], 'yes')
assert.strictEqual(data['x-return-headers'], 'yes')
done()
},
error: (xhr, errorType, error) => {
@ -594,35 +594,35 @@ describe('protocol module', () => {
describe('protocol.isProtocolHandled', () => {
it('returns true for about:', (done) => {
protocol.isProtocolHandled('about', (result) => {
assert.equal(result, true)
assert.strictEqual(result, true)
done()
})
})
it('returns true for file:', (done) => {
protocol.isProtocolHandled('file', (result) => {
assert.equal(result, true)
assert.strictEqual(result, true)
done()
})
})
it('returns true for http:', (done) => {
protocol.isProtocolHandled('http', (result) => {
assert.equal(result, true)
assert.strictEqual(result, true)
done()
})
})
it('returns true for https:', (done) => {
protocol.isProtocolHandled('https', (result) => {
assert.equal(result, true)
assert.strictEqual(result, true)
done()
})
})
it('returns false when scheme is not registered', (done) => {
protocol.isProtocolHandled('no-exist', (result) => {
assert.equal(result, false)
assert.strictEqual(result, false)
done()
})
})
@ -630,9 +630,9 @@ describe('protocol module', () => {
it('returns true for custom protocol', (done) => {
const emptyHandler = (request, callback) => callback()
protocol.registerStringProtocol(protocolName, emptyHandler, (error) => {
assert.equal(error, null)
assert.strictEqual(error, null)
protocol.isProtocolHandled(protocolName, (result) => {
assert.equal(result, true)
assert.strictEqual(result, true)
done()
})
})
@ -641,9 +641,9 @@ describe('protocol module', () => {
it('returns true for intercepted protocol', (done) => {
const emptyHandler = (request, callback) => callback()
protocol.interceptStringProtocol('http', emptyHandler, (error) => {
assert.equal(error, null)
assert.strictEqual(error, null)
protocol.isProtocolHandled('http', (result) => {
assert.equal(result, true)
assert.strictEqual(result, true)
done()
})
})
@ -654,9 +654,9 @@ describe('protocol module', () => {
const emptyHandler = (request, callback) => callback()
it('throws error when scheme is already intercepted', (done) => {
protocol.interceptStringProtocol('http', emptyHandler, (error) => {
assert.equal(error, null)
assert.strictEqual(error, null)
protocol.interceptBufferProtocol('http', emptyHandler, (error) => {
assert.notEqual(error, null)
assert.notStrictEqual(error, null)
done()
})
})
@ -677,7 +677,7 @@ describe('protocol module', () => {
url: 'http://fake-host',
cache: false,
success: (data) => {
assert.equal(data, text)
assert.strictEqual(data, text)
done()
},
error: (xhr, errorType, error) => done(error)
@ -693,7 +693,7 @@ describe('protocol module', () => {
cache: false,
success: () => done('request succeeded but it should not'),
error: (xhr, errorType) => {
assert.equal(errorType, 'error')
assert.strictEqual(errorType, 'error')
done()
}
})
@ -710,7 +710,7 @@ describe('protocol module', () => {
url: 'http://fake-host',
cache: false,
success: (data) => {
assert.equal(data, text)
assert.strictEqual(data, text)
done()
},
error: (xhr, errorType, error) => done(error)
@ -731,8 +731,8 @@ describe('protocol module', () => {
url: 'http://fake-host',
cache: false,
success: (data) => {
assert.equal(typeof data, 'object')
assert.equal(data.value, 1)
assert.strictEqual(typeof data, 'object')
assert.strictEqual(data.value, 1)
done()
},
error: (xhr, errorType, error) => done(error)
@ -753,7 +753,7 @@ describe('protocol module', () => {
type: 'POST',
data: postData,
success: (data) => {
assert.deepEqual(qs.parse(data), postData)
assert.deepStrictEqual({ ...qs.parse(data) }, postData)
done()
},
error: (xhr, errorType, error) => done(error)
@ -771,7 +771,7 @@ describe('protocol module', () => {
url: 'http://fake-host',
cache: false,
success: (data) => {
assert.equal(data, text)
assert.strictEqual(data, text)
done()
},
error: (xhr, errorType, error) => done(error)
@ -792,7 +792,7 @@ describe('protocol module', () => {
type: 'POST',
data: postData,
success: (data) => {
assert.equal(data, $.param(postData))
assert.strictEqual(data, $.param(postData))
done()
},
error: (xhr, errorType, error) => done(error)
@ -836,7 +836,7 @@ describe('protocol module', () => {
type: 'POST',
data: postData,
success: (data) => {
assert.deepEqual(qs.parse(data), postData)
assert.deepStrictEqual({ ...qs.parse(data) }, postData)
done()
},
error: (xhr, errorType, error) => done(error)
@ -848,7 +848,7 @@ describe('protocol module', () => {
it('can use custom session', (done) => {
const customSession = session.fromPartition('custom-ses', { cache: false })
customSession.webRequest.onBeforeRequest((details, callback) => {
assert.equal(details.url, 'http://fake-host/')
assert.strictEqual(details.url, 'http://fake-host/')
callback({ cancel: true })
})
const handler = (request, callback) => {
@ -878,7 +878,7 @@ describe('protocol module', () => {
url: 'http://fake-host',
cache: false,
success: (data) => {
assert.equal(data, text)
assert.strictEqual(data, text)
done()
},
error: (xhr, errorType, error) => {
@ -900,7 +900,7 @@ describe('protocol module', () => {
type: 'POST',
data: postData,
success: (data) => {
assert.deepEqual(qs.parse(data), postData)
assert.deepStrictEqual({ ...qs.parse(data) }, postData)
done()
},
error: (xhr, errorType, error) => {
@ -923,7 +923,7 @@ describe('protocol module', () => {
})
}, 300)
} else {
assert.equal(request.url.indexOf('http://fake-redirect'), 0)
assert.strictEqual(request.url.indexOf('http://fake-redirect'), 0)
callback(getStream(1, 'redirect'))
}
}
@ -933,7 +933,7 @@ describe('protocol module', () => {
url: 'http://fake-host',
cache: false,
success: (data) => {
assert.equal(data, 'redirect')
assert.strictEqual(data, 'redirect')
done()
},
error: (xhr, errorType, error) => {
@ -947,14 +947,14 @@ describe('protocol module', () => {
describe('protocol.uninterceptProtocol', () => {
it('returns error when scheme does not exist', (done) => {
protocol.uninterceptProtocol('not-exist', (error) => {
assert.notEqual(error, null)
assert.notStrictEqual(error, null)
done()
})
})
it('returns error when scheme is not intercepted', (done) => {
protocol.uninterceptProtocol('http', (error) => {
assert.notEqual(error, null)
assert.notStrictEqual(error, null)
done()
})
})

View file

@ -3,6 +3,7 @@
const assert = require('assert')
const path = require('path')
const { closeWindow } = require('./window-helpers')
const { resolveGetters } = require('./assert-helpers')
const { remote } = require('electron')
@ -11,7 +12,7 @@ const comparePaths = (path1, path2) => {
path1 = path1.toLowerCase()
path2 = path2.toLowerCase()
}
assert.equal(path1, path2)
assert.strictEqual(path1, path2)
}
describe('remote module', () => {
@ -25,23 +26,23 @@ describe('remote module', () => {
it('should returns same object for the same module', () => {
const dialog1 = remote.require('electron')
const dialog2 = remote.require('electron')
assert.equal(dialog1, dialog2)
assert.strictEqual(dialog1, dialog2)
})
it('should work when object contains id property', () => {
const a = remote.require(path.join(fixtures, 'module', 'id.js'))
assert.equal(a.id, 1127)
assert.strictEqual(a.id, 1127)
})
it('should work when object has no prototype', () => {
const a = remote.require(path.join(fixtures, 'module', 'no-prototype.js'))
assert.equal(a.foo.constructor.name, '')
assert.equal(a.foo.bar, 'baz')
assert.equal(a.foo.baz, false)
assert.equal(a.bar, 1234)
assert.equal(a.anonymous.constructor.name, '')
assert.equal(a.getConstructorName(Object.create(null)), '')
assert.equal(a.getConstructorName(new (class {})()), '')
assert.strictEqual(a.foo.constructor.name, '')
assert.strictEqual(a.foo.bar, 'baz')
assert.strictEqual(a.foo.baz, false)
assert.strictEqual(a.bar, 1234)
assert.strictEqual(a.anonymous.constructor.name, '')
assert.strictEqual(a.getConstructorName(Object.create(null)), '')
assert.strictEqual(a.getConstructorName(new (class {})()), '')
})
it('should search module from the user app', () => {
@ -51,41 +52,41 @@ describe('remote module', () => {
it('should work with function properties', () => {
let a = remote.require(path.join(fixtures, 'module', 'export-function-with-properties.js'))
assert.equal(typeof a, 'function')
assert.equal(a.bar, 'baz')
assert.strictEqual(typeof a, 'function')
assert.strictEqual(a.bar, 'baz')
a = remote.require(path.join(fixtures, 'module', 'function-with-properties.js'))
assert.equal(typeof a, 'object')
assert.equal(a.foo(), 'hello')
assert.equal(a.foo.bar, 'baz')
assert.equal(a.foo.nested.prop, 'yes')
assert.equal(a.foo.method1(), 'world')
assert.equal(a.foo.method1.prop1(), 123)
assert.strictEqual(typeof a, 'object')
assert.strictEqual(a.foo(), 'hello')
assert.strictEqual(a.foo.bar, 'baz')
assert.strictEqual(a.foo.nested.prop, 'yes')
assert.strictEqual(a.foo.method1(), 'world')
assert.strictEqual(a.foo.method1.prop1(), 123)
assert.ok(Object.keys(a.foo).includes('bar'))
assert.ok(Object.keys(a.foo).includes('nested'))
assert.ok(Object.keys(a.foo).includes('method1'))
a = remote.require(path.join(fixtures, 'module', 'function-with-missing-properties.js')).setup()
assert.equal(a.bar(), true)
assert.equal(a.bar.baz, undefined)
assert.strictEqual(a.bar(), true)
assert.strictEqual(a.bar.baz, undefined)
})
it('should work with static class members', () => {
const a = remote.require(path.join(fixtures, 'module', 'remote-static.js'))
assert.equal(typeof a.Foo, 'function')
assert.equal(a.Foo.foo(), 3)
assert.equal(a.Foo.bar, 'baz')
assert.strictEqual(typeof a.Foo, 'function')
assert.strictEqual(a.Foo.foo(), 3)
assert.strictEqual(a.Foo.bar, 'baz')
const foo = new a.Foo()
assert.equal(foo.baz(), 123)
assert.strictEqual(foo.baz(), 123)
})
it('includes the length of functions specified as arguments', () => {
const a = remote.require(path.join(fixtures, 'module', 'function-with-args.js'))
assert.equal(a((a, b, c, d, f) => {}), 5)
assert.equal(a((a) => {}), 1)
assert.equal(a((...args) => {}), 0)
assert.strictEqual(a((a, b, c, d, f) => {}), 5)
assert.strictEqual(a((a) => {}), 1)
assert.strictEqual(a((...args) => {}), 0)
})
it('handles circular references in arrays and objects', () => {
@ -94,7 +95,7 @@ describe('remote module', () => {
let arrayA = ['foo']
const arrayB = [arrayA, 'bar']
arrayA.push(arrayB)
assert.deepEqual(a.returnArgs(arrayA, arrayB), [
assert.deepStrictEqual(a.returnArgs(arrayA, arrayB), [
['foo', [null, 'bar']],
[['foo', null], 'bar']
])
@ -102,40 +103,40 @@ describe('remote module', () => {
let objectA = { foo: 'bar' }
const objectB = { baz: objectA }
objectA.objectB = objectB
assert.deepEqual(a.returnArgs(objectA, objectB), [
assert.deepStrictEqual(a.returnArgs(objectA, objectB), [
{ foo: 'bar', objectB: { baz: null } },
{ baz: { foo: 'bar', objectB: null } }
])
arrayA = [1, 2, 3]
assert.deepEqual(a.returnArgs({foo: arrayA}, {bar: arrayA}), [
assert.deepStrictEqual(a.returnArgs({ foo: arrayA }, { bar: arrayA }), [
{ foo: [1, 2, 3] },
{ bar: [1, 2, 3] }
])
objectA = { foo: 'bar' }
assert.deepEqual(a.returnArgs({foo: objectA}, {bar: objectA}), [
assert.deepStrictEqual(a.returnArgs({ foo: objectA }, { bar: objectA }), [
{ foo: { foo: 'bar' } },
{ bar: { foo: 'bar' } }
])
arrayA = []
arrayA.push(arrayA)
assert.deepEqual(a.returnArgs(arrayA), [
assert.deepStrictEqual(a.returnArgs(arrayA), [
[null]
])
objectA = {}
objectA.foo = objectA
objectA.bar = 'baz'
assert.deepEqual(a.returnArgs(objectA), [
assert.deepStrictEqual(a.returnArgs(objectA), [
{ foo: null, bar: 'baz' }
])
objectA = {}
objectA.foo = { bar: objectA }
objectA.bar = 'baz'
assert.deepEqual(a.returnArgs(objectA), [
assert.deepStrictEqual(a.returnArgs(objectA), [
{ foo: { bar: null }, bar: 'baz' }
])
})
@ -146,16 +147,16 @@ describe('remote module', () => {
const buf = Buffer.from('test')
const call = remote.require(path.join(fixtures, 'module', 'call.js'))
const result = call.call(remote.createFunctionWithReturnValue(buf))
assert.equal(result.constructor.name, 'Buffer')
assert.strictEqual(result.constructor.name, 'Buffer')
})
})
describe('remote modules', () => {
it('includes browser process modules as properties', () => {
assert.equal(typeof remote.app.getPath, 'function')
assert.equal(typeof remote.webContents.getFocusedWebContents, 'function')
assert.equal(typeof remote.clipboard.readText, 'function')
assert.equal(typeof remote.shell.openExternal, 'function')
assert.strictEqual(typeof remote.app.getPath, 'function')
assert.strictEqual(typeof remote.webContents.getFocusedWebContents, 'function')
assert.strictEqual(typeof remote.clipboard.readText, 'function')
assert.strictEqual(typeof remote.shell.openExternal, 'function')
})
it('returns toString() of original function via toString()', () => {
@ -163,29 +164,29 @@ describe('remote module', () => {
assert(readText.toString().startsWith('function'))
const { functionWithToStringProperty } = remote.require(path.join(fixtures, 'module', 'to-string-non-function.js'))
assert.equal(functionWithToStringProperty.toString, 'hello')
assert.strictEqual(functionWithToStringProperty.toString, 'hello')
})
})
describe('remote object in renderer', () => {
it('can change its properties', () => {
const property = remote.require(path.join(fixtures, 'module', 'property.js'))
assert.equal(property.property, 1127)
assert.strictEqual(property.property, 1127)
property.property = null
assert.equal(property.property, null)
assert.strictEqual(property.property, null)
property.property = undefined
assert.equal(property.property, undefined)
assert.strictEqual(property.property, undefined)
property.property = 1007
assert.equal(property.property, 1007)
assert.strictEqual(property.property, 1007)
assert.equal(property.getFunctionProperty(), 'foo-browser')
assert.strictEqual(property.getFunctionProperty(), 'foo-browser')
property.func.property = 'bar'
assert.equal(property.getFunctionProperty(), 'bar-browser')
assert.strictEqual(property.getFunctionProperty(), 'bar-browser')
property.func.property = 'foo' // revert back
const property2 = remote.require(path.join(fixtures, 'module', 'property.js'))
assert.equal(property2.property, 1007)
assert.strictEqual(property2.property, 1007)
property.property = 1127
})
@ -213,17 +214,17 @@ describe('remote module', () => {
it('can construct an object from its member', () => {
const call = remote.require(path.join(fixtures, 'module', 'call.js'))
const obj = new call.constructor()
assert.equal(obj.test, 'test')
assert.strictEqual(obj.test, 'test')
})
it('can reassign and delete its member functions', () => {
const remoteFunctions = remote.require(path.join(fixtures, 'module', 'function.js'))
assert.equal(remoteFunctions.aFunction(), 1127)
assert.strictEqual(remoteFunctions.aFunction(), 1127)
remoteFunctions.aFunction = () => { return 1234 }
assert.equal(remoteFunctions.aFunction(), 1234)
assert.strictEqual(remoteFunctions.aFunction(), 1234)
assert.equal(delete remoteFunctions.aFunction, true)
assert.strictEqual(delete remoteFunctions.aFunction, true)
})
it('is referenced by its members', () => {
@ -249,13 +250,13 @@ describe('remote module', () => {
it('keeps its constructor name for objects', () => {
const buf = Buffer.from('test')
assert.equal(printName.print(buf), 'Buffer')
assert.strictEqual(printName.print(buf), 'Buffer')
})
it('supports instanceof Date', () => {
const now = new Date()
assert.equal(printName.print(now), 'Date')
assert.deepEqual(printName.echo(now), now)
assert.strictEqual(printName.print(now), 'Date')
assert.deepStrictEqual(printName.echo(now), now)
})
it('supports instanceof Buffer', () => {
@ -274,89 +275,89 @@ describe('remote module', () => {
const view = new DataView(buffer)
view.setFloat64(0, Math.PI)
assert.deepEqual(printName.echo(buffer), buffer)
assert.equal(printName.print(buffer), 'ArrayBuffer')
assert.deepStrictEqual(printName.echo(buffer), buffer)
assert.strictEqual(printName.print(buffer), 'ArrayBuffer')
})
it('supports instanceof Int8Array', () => {
const values = [1, 2, 3, 4]
assert.deepEqual(printName.typedArray('Int8Array', values), values)
assert.deepStrictEqual([...printName.typedArray('Int8Array', values)], values)
const int8values = new Int8Array(values)
assert.deepEqual(printName.typedArray('Int8Array', int8values), int8values)
assert.equal(printName.print(int8values), 'Int8Array')
assert.deepStrictEqual(printName.typedArray('Int8Array', int8values), int8values)
assert.strictEqual(printName.print(int8values), 'Int8Array')
})
it('supports instanceof Uint8Array', () => {
const values = [1, 2, 3, 4]
assert.deepEqual(printName.typedArray('Uint8Array', values), values)
assert.deepStrictEqual([...printName.typedArray('Uint8Array', values)], values)
const uint8values = new Uint8Array(values)
assert.deepEqual(printName.typedArray('Uint8Array', uint8values), uint8values)
assert.equal(printName.print(uint8values), 'Uint8Array')
assert.deepStrictEqual(printName.typedArray('Uint8Array', uint8values), uint8values)
assert.strictEqual(printName.print(uint8values), 'Uint8Array')
})
it('supports instanceof Uint8ClampedArray', () => {
const values = [1, 2, 3, 4]
assert.deepEqual(printName.typedArray('Uint8ClampedArray', values), values)
assert.deepStrictEqual([...printName.typedArray('Uint8ClampedArray', values)], values)
const uint8values = new Uint8ClampedArray(values)
assert.deepEqual(printName.typedArray('Uint8ClampedArray', uint8values), uint8values)
assert.equal(printName.print(uint8values), 'Uint8ClampedArray')
assert.deepStrictEqual(printName.typedArray('Uint8ClampedArray', uint8values), uint8values)
assert.strictEqual(printName.print(uint8values), 'Uint8ClampedArray')
})
it('supports instanceof Int16Array', () => {
const values = [0x1234, 0x2345, 0x3456, 0x4567]
assert.deepEqual(printName.typedArray('Int16Array', values), values)
assert.deepStrictEqual([...printName.typedArray('Int16Array', values)], values)
const int16values = new Int16Array(values)
assert.deepEqual(printName.typedArray('Int16Array', int16values), int16values)
assert.equal(printName.print(int16values), 'Int16Array')
assert.deepStrictEqual(printName.typedArray('Int16Array', int16values), int16values)
assert.strictEqual(printName.print(int16values), 'Int16Array')
})
it('supports instanceof Uint16Array', () => {
const values = [0x1234, 0x2345, 0x3456, 0x4567]
assert.deepEqual(printName.typedArray('Uint16Array', values), values)
assert.deepStrictEqual([...printName.typedArray('Uint16Array', values)], values)
const uint16values = new Uint16Array(values)
assert.deepEqual(printName.typedArray('Uint16Array', uint16values), uint16values)
assert.equal(printName.print(uint16values), 'Uint16Array')
assert.deepStrictEqual(printName.typedArray('Uint16Array', uint16values), uint16values)
assert.strictEqual(printName.print(uint16values), 'Uint16Array')
})
it('supports instanceof Int32Array', () => {
const values = [0x12345678, 0x23456789]
assert.deepEqual(printName.typedArray('Int32Array', values), values)
assert.deepStrictEqual([...printName.typedArray('Int32Array', values)], values)
const int32values = new Int32Array(values)
assert.deepEqual(printName.typedArray('Int32Array', int32values), int32values)
assert.equal(printName.print(int32values), 'Int32Array')
assert.deepStrictEqual(printName.typedArray('Int32Array', int32values), int32values)
assert.strictEqual(printName.print(int32values), 'Int32Array')
})
it('supports instanceof Uint32Array', () => {
const values = [0x12345678, 0x23456789]
assert.deepEqual(printName.typedArray('Uint32Array', values), values)
assert.deepStrictEqual([...printName.typedArray('Uint32Array', values)], values)
const uint32values = new Uint32Array(values)
assert.deepEqual(printName.typedArray('Uint32Array', uint32values), uint32values)
assert.equal(printName.print(uint32values), 'Uint32Array')
assert.deepStrictEqual(printName.typedArray('Uint32Array', uint32values), uint32values)
assert.strictEqual(printName.print(uint32values), 'Uint32Array')
})
it('supports instanceof Float32Array', () => {
const values = [0.5, 1.0, 1.5]
assert.deepEqual(printName.typedArray('Float32Array', values), values)
assert.deepStrictEqual([...printName.typedArray('Float32Array', values)], values)
const float32values = new Float32Array()
assert.deepEqual(printName.typedArray('Float32Array', float32values), float32values)
assert.equal(printName.print(float32values), 'Float32Array')
assert.deepStrictEqual(printName.typedArray('Float32Array', float32values), float32values)
assert.strictEqual(printName.print(float32values), 'Float32Array')
})
it('supports instanceof Float64Array', () => {
const values = [0.5, 1.0, 1.5]
assert.deepEqual(printName.typedArray('Float64Array', values), values)
assert.deepStrictEqual([...printName.typedArray('Float64Array', values)], values)
const float64values = new Float64Array([0.5, 1.0, 1.5])
assert.deepEqual(printName.typedArray('Float64Array', float64values), float64values)
assert.equal(printName.print(float64values), 'Float64Array')
assert.deepStrictEqual(printName.typedArray('Float64Array', float64values), float64values)
assert.strictEqual(printName.print(float64values), 'Float64Array')
})
})
@ -364,7 +365,7 @@ describe('remote module', () => {
it('can be used as promise in each side', (done) => {
const promise = remote.require(path.join(fixtures, 'module', 'promise.js'))
promise.twicePromise(Promise.resolve(1234)).then((value) => {
assert.equal(value, 2468)
assert.strictEqual(value, 2468)
done()
})
})
@ -372,7 +373,7 @@ describe('remote module', () => {
it('handles rejections via catch(onRejected)', (done) => {
const promise = remote.require(path.join(fixtures, 'module', 'rejected-promise.js'))
promise.reject(Promise.resolve(1234)).catch((error) => {
assert.equal(error.message, 'rejected')
assert.strictEqual(error.message, 'rejected')
done()
})
})
@ -380,7 +381,7 @@ describe('remote module', () => {
it('handles rejections via then(onFulfilled, onRejected)', (done) => {
const promise = remote.require(path.join(fixtures, 'module', 'rejected-promise.js'))
promise.reject(Promise.resolve(1234)).then(() => {}, (error) => {
assert.equal(error.message, 'rejected')
assert.strictEqual(error.message, 'rejected')
done()
})
})
@ -394,7 +395,7 @@ describe('remote module', () => {
promise.reject().then(() => {
done(new Error('Promise was not rejected'))
}).catch((error) => {
assert.equal(error.message, 'rejected')
assert.strictEqual(error.message, 'rejected')
done()
})
})
@ -402,7 +403,7 @@ describe('remote module', () => {
it('emits unhandled rejection events in the renderer process', (done) => {
window.addEventListener('unhandledrejection', function (event) {
event.preventDefault()
assert.equal(event.reason.message, 'rejected')
assert.strictEqual(event.reason.message, 'rejected')
done()
})
@ -427,17 +428,17 @@ describe('remote module', () => {
let derived = cl.derived
it('can get methods', () => {
assert.equal(base.method(), 'method')
assert.strictEqual(base.method(), 'method')
})
it('can get properties', () => {
assert.equal(base.readonly, 'readonly')
assert.strictEqual(base.readonly, 'readonly')
})
it('can change properties', () => {
assert.equal(base.value, 'old')
assert.strictEqual(base.value, 'old')
base.value = 'new'
assert.equal(base.value, 'new')
assert.strictEqual(base.value, 'new')
base.value = 'old'
})
@ -447,8 +448,8 @@ describe('remote module', () => {
})
it('keeps prototype chain in derived class', () => {
assert.equal(derived.method(), 'method')
assert.equal(derived.readonly, 'readonly')
assert.strictEqual(derived.method(), 'method')
assert.strictEqual(derived.readonly, 'readonly')
assert(!derived.hasOwnProperty('method'))
let proto = Object.getPrototypeOf(derived)
assert(!proto.hasOwnProperty('method'))
@ -459,7 +460,7 @@ describe('remote module', () => {
let method = derived.method
derived = null
global.gc()
assert.equal(method(), 'method')
assert.strictEqual(method(), 'method')
})
})
@ -480,7 +481,7 @@ describe('remote module', () => {
throwFunction(err)
} catch (error) {
assert.ok(error.from)
assert.deepEqual(error.cause, err)
assert.deepStrictEqual(error.cause, ...resolveGetters(err))
}
})
})

View file

@ -5,15 +5,15 @@ describe('screen module', () => {
describe('screen.getCursorScreenPoint()', () => {
it('returns a point object', () => {
const point = screen.getCursorScreenPoint()
assert.equal(typeof point.x, 'number')
assert.equal(typeof point.y, 'number')
assert.strictEqual(typeof point.x, 'number')
assert.strictEqual(typeof point.y, 'number')
})
})
describe('screen.getPrimaryDisplay()', () => {
it('returns a display object', () => {
const display = screen.getPrimaryDisplay()
assert.equal(typeof display.scaleFactor, 'number')
assert.strictEqual(typeof display.scaleFactor, 'number')
assert(display.size.width > 0)
assert(display.size.height > 0)
})

View file

@ -40,13 +40,13 @@ describe('session module', () => {
describe('session.defaultSession', () => {
it('returns the default session', () => {
assert.equal(session.defaultSession, session.fromPartition(''))
assert.strictEqual(session.defaultSession, session.fromPartition(''))
})
})
describe('session.fromPartition(partition, options)', () => {
it('returns existing session with same partition', () => {
assert.equal(session.fromPartition('test'), session.fromPartition('test'))
assert.strictEqual(session.fromPartition('test'), session.fromPartition('test'))
})
it('created session is ref-counted', () => {
@ -54,10 +54,10 @@ describe('session module', () => {
const userAgent = 'test-agent'
const ses1 = session.fromPartition(partition)
ses1.setUserAgent(userAgent)
assert.equal(ses1.getUserAgent(), userAgent)
assert.strictEqual(ses1.getUserAgent(), userAgent)
ses1.destroy()
const ses2 = session.fromPartition(partition)
assert.notEqual(ses2.getUserAgent(), userAgent)
assert.notStrictEqual(ses2.getUserAgent(), userAgent)
})
})
@ -97,7 +97,7 @@ describe('session module', () => {
value: '1'
}, (error) => {
assert(error, 'Should have an error')
assert.equal(error.message, 'Setting cookie failed')
assert.strictEqual(error.message, 'Setting cookie failed')
done()
})
})
@ -157,10 +157,10 @@ describe('session module', () => {
if (error) return done(error)
session.defaultSession.cookies.get({ url: origin }, (error, list) => {
if (error) return done(error)
assert.equal(list.length, 1)
assert.equal(list[0].name, 'custom')
assert.equal(list[0].value, '1')
assert.equal(list[0].domain, 'fake-host')
assert.strictEqual(list.length, 1)
assert.strictEqual(list[0].name, 'custom')
assert.strictEqual(list[0].value, '1')
assert.strictEqual(list[0].domain, 'fake-host')
done()
})
})
@ -170,16 +170,16 @@ describe('session module', () => {
const { cookies } = session.fromPartition('cookies-changed')
cookies.once('changed', (event, cookie, cause, removed) => {
assert.equal(cookie.name, 'foo')
assert.equal(cookie.value, 'bar')
assert.equal(cause, 'explicit')
assert.equal(removed, false)
assert.strictEqual(cookie.name, 'foo')
assert.strictEqual(cookie.value, 'bar')
assert.strictEqual(cause, 'explicit')
assert.strictEqual(removed, false)
cookies.once('changed', (event, cookie, cause, removed) => {
assert.equal(cookie.name, 'foo')
assert.equal(cookie.value, 'bar')
assert.equal(cause, 'explicit')
assert.equal(removed, true)
assert.strictEqual(cookie.name, 'foo')
assert.strictEqual(cookie.value, 'bar')
assert.strictEqual(cause, 'explicit')
assert.strictEqual(removed, true)
done()
})
@ -218,7 +218,7 @@ describe('session module', () => {
it('clears localstorage data', (done) => {
ipcMain.on('count', (event, count) => {
ipcMain.removeAllListeners('count')
assert.equal(count, 0)
assert.strictEqual(count, 0)
done()
})
w.loadFile(path.join(fixtures, 'api', 'localstorage.html'))
@ -265,9 +265,9 @@ describe('session module', () => {
ipcRenderer.sendSync('set-download-option', false, true)
w.loadURL(url)
ipcRenderer.once('download-error', (event, downloadUrl, filename, error) => {
assert.equal(downloadUrl, url)
assert.equal(filename, 'mockFile.txt')
assert.equal(error, 'Object has been destroyed')
assert.strictEqual(downloadUrl, url)
assert.strictEqual(filename, 'mockFile.txt')
assert.strictEqual(error, 'Object has been destroyed')
done()
})
})
@ -296,19 +296,19 @@ describe('session module', () => {
const assertDownload = (event, state, url, mimeType,
receivedBytes, totalBytes, disposition,
filename, port, savePath, isCustom) => {
assert.equal(state, 'completed')
assert.equal(filename, 'mock.pdf')
assert.strictEqual(state, 'completed')
assert.strictEqual(filename, 'mock.pdf')
assert.ok(path.isAbsolute(savePath))
assert.ok(isPathEqual(savePath, path.join(__dirname, 'fixtures', 'mock.pdf')))
if (isCustom) {
assert.equal(url, `${protocolName}://item`)
assert.strictEqual(url, `${protocolName}://item`)
} else {
assert.equal(url, `http://127.0.0.1:${port}/`)
assert.strictEqual(url, `http://127.0.0.1:${port}/`)
}
assert.equal(mimeType, 'application/pdf')
assert.equal(receivedBytes, mockPDF.length)
assert.equal(totalBytes, mockPDF.length)
assert.equal(disposition, contentDisposition)
assert.strictEqual(mimeType, 'application/pdf')
assert.strictEqual(receivedBytes, mockPDF.length)
assert.strictEqual(totalBytes, mockPDF.length)
assert.strictEqual(disposition, contentDisposition)
assert(fs.existsSync(downloadFilePath))
fs.unlinkSync(downloadFilePath)
}
@ -384,12 +384,12 @@ describe('session module', () => {
mimeType, receivedBytes,
totalBytes, disposition,
filename) => {
assert.equal(state, 'cancelled')
assert.equal(filename, 'mock.pdf')
assert.equal(mimeType, 'application/pdf')
assert.equal(receivedBytes, 0)
assert.equal(totalBytes, mockPDF.length)
assert.equal(disposition, contentDisposition)
assert.strictEqual(state, 'cancelled')
assert.strictEqual(filename, 'mock.pdf')
assert.strictEqual(mimeType, 'application/pdf')
assert.strictEqual(receivedBytes, 0)
assert.strictEqual(totalBytes, mockPDF.length)
assert.strictEqual(disposition, contentDisposition)
done()
})
})
@ -410,12 +410,12 @@ describe('session module', () => {
mimeType, receivedBytes,
totalBytes, disposition,
filename) => {
assert.equal(state, 'cancelled')
assert.equal(filename, 'download.pdf')
assert.equal(mimeType, 'application/pdf')
assert.equal(receivedBytes, 0)
assert.equal(totalBytes, mockPDF.length)
assert.equal(disposition, contentDisposition)
assert.strictEqual(state, 'cancelled')
assert.strictEqual(filename, 'download.pdf')
assert.strictEqual(mimeType, 'application/pdf')
assert.strictEqual(receivedBytes, 0)
assert.strictEqual(totalBytes, mockPDF.length)
assert.strictEqual(disposition, contentDisposition)
done()
})
})
@ -425,7 +425,7 @@ describe('session module', () => {
it('does not display a save dialog and reports the done state as interrupted', (done) => {
ipcRenderer.sendSync('set-download-option', false, false)
ipcRenderer.once('download-done', (event, state) => {
assert.equal(state, 'interrupted')
assert.strictEqual(state, 'interrupted')
done()
})
w.webContents.downloadURL(`file://${path.join(__dirname, 'does-not-exist.txt')}`)
@ -461,9 +461,9 @@ describe('session module', () => {
it('does not affect defaultSession', (done) => {
protocol.isProtocolHandled(protocolName, (result) => {
assert.equal(result, false)
assert.strictEqual(result, false)
partitionProtocol.isProtocolHandled(protocolName, (result) => {
assert.equal(result, true)
assert.strictEqual(result, true)
done()
})
})
@ -480,7 +480,7 @@ describe('session module', () => {
const config = { proxyRules: 'http=myproxy:80' }
session.defaultSession.setProxy(config, () => {
session.defaultSession.resolveProxy('http://localhost', (proxy) => {
assert.equal(proxy, 'PROXY myproxy:80')
assert.strictEqual(proxy, 'PROXY myproxy:80')
done()
})
})
@ -493,7 +493,7 @@ describe('session module', () => {
}
session.defaultSession.setProxy(config, () => {
session.defaultSession.resolveProxy('http://localhost', (proxy) => {
assert.equal(proxy, 'DIRECT')
assert.strictEqual(proxy, 'DIRECT')
done()
})
})
@ -540,7 +540,7 @@ describe('session module', () => {
let uuid = request.uploadData[1].blobUUID
assert(uuid)
session.defaultSession.getBlobData(uuid, (result) => {
assert.equal(result.toString(), postData)
assert.strictEqual(result.toString(), postData)
done()
})
}
@ -587,7 +587,7 @@ describe('session module', () => {
})
w.webContents.once('did-finish-load', () => {
assert.equal(w.webContents.getTitle(), 'hello')
assert.strictEqual(w.webContents.getTitle(), 'hello')
done()
})
w.loadURL(`https://127.0.0.1:${server.address().port}`)
@ -595,23 +595,23 @@ describe('session module', () => {
it('rejects the request when the callback is called with -2', (done) => {
session.defaultSession.setCertificateVerifyProc(({ hostname, certificate, verificationResult }, callback) => {
assert.equal(hostname, '127.0.0.1')
assert.equal(certificate.issuerName, 'Intermediate CA')
assert.equal(certificate.subjectName, 'localhost')
assert.equal(certificate.issuer.commonName, 'Intermediate CA')
assert.equal(certificate.subject.commonName, 'localhost')
assert.equal(certificate.issuerCert.issuer.commonName, 'Root CA')
assert.equal(certificate.issuerCert.subject.commonName, 'Intermediate CA')
assert.equal(certificate.issuerCert.issuerCert.issuer.commonName, 'Root CA')
assert.equal(certificate.issuerCert.issuerCert.subject.commonName, 'Root CA')
assert.equal(certificate.issuerCert.issuerCert.issuerCert, undefined)
assert.strictEqual(hostname, '127.0.0.1')
assert.strictEqual(certificate.issuerName, 'Intermediate CA')
assert.strictEqual(certificate.subjectName, 'localhost')
assert.strictEqual(certificate.issuer.commonName, 'Intermediate CA')
assert.strictEqual(certificate.subject.commonName, 'localhost')
assert.strictEqual(certificate.issuerCert.issuer.commonName, 'Root CA')
assert.strictEqual(certificate.issuerCert.subject.commonName, 'Intermediate CA')
assert.strictEqual(certificate.issuerCert.issuerCert.issuer.commonName, 'Root CA')
assert.strictEqual(certificate.issuerCert.issuerCert.subject.commonName, 'Root CA')
assert.strictEqual(certificate.issuerCert.issuerCert.issuerCert, undefined)
assert(['net::ERR_CERT_AUTHORITY_INVALID', 'net::ERR_CERT_COMMON_NAME_INVALID'].includes(verificationResult), verificationResult)
callback(-2)
})
const url = `https://127.0.0.1:${server.address().port}`
w.webContents.once('did-finish-load', () => {
assert.equal(w.webContents.getTitle(), url)
assert.strictEqual(w.webContents.getTitle(), url)
done()
})
w.loadURL(url)
@ -634,12 +634,12 @@ describe('session module', () => {
mimeType, receivedBytes,
totalBytes, filename,
savePath) => {
assert.equal(state, 'interrupted')
assert.deepEqual(urlChain, ['http://127.0.0.1/'])
assert.equal(mimeType, 'application/pdf')
assert.equal(receivedBytes, 0)
assert.equal(totalBytes, 5242880)
assert.equal(savePath, filePath)
assert.strictEqual(state, 'interrupted')
assert.deepStrictEqual(urlChain, ['http://127.0.0.1/'])
assert.strictEqual(mimeType, 'application/pdf')
assert.strictEqual(receivedBytes, 0)
assert.strictEqual(totalBytes, 5242880)
assert.strictEqual(savePath, filePath)
done()
})
})
@ -673,13 +673,13 @@ describe('session module', () => {
ipcRenderer.sendSync('set-download-option', false, false, downloadFilePath)
w.webContents.session.createInterruptedDownload(options)
} else {
assert.equal(state, 'completed')
assert.equal(filename, 'logo.png')
assert.equal(savePath, downloadFilePath)
assert.equal(url, downloadUrl)
assert.equal(mimeType, 'image/png')
assert.equal(receivedBytes, 14022)
assert.equal(totalBytes, 14022)
assert.strictEqual(state, 'completed')
assert.strictEqual(filename, 'logo.png')
assert.strictEqual(savePath, downloadFilePath)
assert.strictEqual(url, downloadUrl)
assert.strictEqual(mimeType, 'image/png')
assert.strictEqual(receivedBytes, 14022)
assert.strictEqual(totalBytes, 14022)
assert(fs.existsSync(downloadFilePath))
fs.unlinkSync(downloadFilePath)
rangeServer.close()
@ -719,8 +719,8 @@ describe('session module', () => {
})
request.on('login', (info, callback) => {
attempt += 1
assert.equal(info.scheme, 'basic')
assert.equal(info.realm, 'Restricted')
assert.strictEqual(info.scheme, 'basic')
assert.strictEqual(info.realm, 'Restricted')
callback('test', 'test')
})
request.on('response', (response) => {
@ -730,7 +730,7 @@ describe('session module', () => {
data += chunk
})
response.on('end', () => {
assert.equal(data, 'authenticated')
assert.strictEqual(data, 'authenticated')
ses.clearAuthCache({ type: 'password' }, () => {
issueLoginRequest(attempt)
})
@ -756,8 +756,8 @@ describe('session module', () => {
webview = new WebView()
webview.addEventListener('ipc-message', (e) => {
assert.equal(e.channel, 'message')
assert.deepEqual(e.args, ['SecurityError'])
assert.strictEqual(e.channel, 'message')
assert.deepStrictEqual(e.args, ['SecurityError'])
done()
})
webview.src = `file://${fixtures}/pages/permissions/midi-sysex.html`

View file

@ -32,7 +32,7 @@ describe('shell module', () => {
it('reads all properties of a shortcut', () => {
const shortcut = shell.readShortcutLink(path.join(fixtures, 'assets', 'shortcut.lnk'))
assert.deepEqual(shortcut, shortcutOptions)
assert.deepStrictEqual(shortcut, shortcutOptions)
})
})
@ -44,28 +44,28 @@ describe('shell module', () => {
})
it('writes the shortcut', () => {
assert.equal(shell.writeShortcutLink(tmpShortcut, {target: 'C:\\'}), true)
assert.equal(fs.existsSync(tmpShortcut), true)
assert.strictEqual(shell.writeShortcutLink(tmpShortcut, { target: 'C:\\' }), true)
assert.strictEqual(fs.existsSync(tmpShortcut), true)
})
it('correctly sets the fields', () => {
assert.equal(shell.writeShortcutLink(tmpShortcut, shortcutOptions), true)
assert.deepEqual(shell.readShortcutLink(tmpShortcut), shortcutOptions)
assert.strictEqual(shell.writeShortcutLink(tmpShortcut, shortcutOptions), true)
assert.deepStrictEqual(shell.readShortcutLink(tmpShortcut), shortcutOptions)
})
it('updates the shortcut', () => {
assert.equal(shell.writeShortcutLink(tmpShortcut, 'update', shortcutOptions), false)
assert.equal(shell.writeShortcutLink(tmpShortcut, 'create', shortcutOptions), true)
assert.deepEqual(shell.readShortcutLink(tmpShortcut), shortcutOptions)
assert.strictEqual(shell.writeShortcutLink(tmpShortcut, 'update', shortcutOptions), false)
assert.strictEqual(shell.writeShortcutLink(tmpShortcut, 'create', shortcutOptions), true)
assert.deepStrictEqual(shell.readShortcutLink(tmpShortcut), shortcutOptions)
const change = { target: 'D:\\' }
assert.equal(shell.writeShortcutLink(tmpShortcut, 'update', change), true)
assert.deepEqual(shell.readShortcutLink(tmpShortcut), Object.assign(shortcutOptions, change))
assert.strictEqual(shell.writeShortcutLink(tmpShortcut, 'update', change), true)
assert.deepStrictEqual(shell.readShortcutLink(tmpShortcut), Object.assign(shortcutOptions, change))
})
it('replaces the shortcut', () => {
assert.equal(shell.writeShortcutLink(tmpShortcut, 'replace', shortcutOptions), false)
assert.equal(shell.writeShortcutLink(tmpShortcut, 'create', shortcutOptions), true)
assert.deepEqual(shell.readShortcutLink(tmpShortcut), shortcutOptions)
assert.strictEqual(shell.writeShortcutLink(tmpShortcut, 'replace', shortcutOptions), false)
assert.strictEqual(shell.writeShortcutLink(tmpShortcut, 'create', shortcutOptions), true)
assert.deepStrictEqual(shell.readShortcutLink(tmpShortcut), shortcutOptions)
const change = {
target: 'D:\\',
description: 'description2',
@ -75,8 +75,8 @@ describe('shell module', () => {
icon: 'icon2',
iconIndex: 2
}
assert.equal(shell.writeShortcutLink(tmpShortcut, 'replace', change), true)
assert.deepEqual(shell.readShortcutLink(tmpShortcut), change)
assert.strictEqual(shell.writeShortcutLink(tmpShortcut, 'replace', change), true)
assert.deepStrictEqual(shell.readShortcutLink(tmpShortcut), change)
})
})
})

View file

@ -12,7 +12,7 @@ describe('systemPreferences module', () => {
it('should return a non-empty string', () => {
let accentColor = systemPreferences.getAccentColor()
assert.notEqual(accentColor, null)
assert.notStrictEqual(accentColor, null)
assert(accentColor.length > 0)
})
})
@ -31,7 +31,7 @@ describe('systemPreferences module', () => {
})
it('returns a hex RGB color string', () => {
assert.equal(/^#[0-9A-F]{6}$/i.test(systemPreferences.getColor('window')), true)
assert.strictEqual(/^#[0-9A-F]{6}$/i.test(systemPreferences.getColor('window')), true)
})
})
@ -57,7 +57,7 @@ describe('systemPreferences module', () => {
for (const userDefault of defaultsMap) {
const { key, value: expectedValue, type } = userDefault
const actualValue = systemPreferences.getUserDefault(key, type)
assert.deepEqual(actualValue, expectedValue)
assert.deepStrictEqual(actualValue, expectedValue)
}
})
@ -86,7 +86,7 @@ describe('systemPreferences module', () => {
it('returns values for known user defaults', () => {
const locale = systemPreferences.getUserDefault('AppleLocale', 'string')
assert.equal(typeof locale, 'string')
assert.strictEqual(typeof locale, 'string')
assert(locale.length > 0)
const languages = systemPreferences.getUserDefault('AppleLanguages', 'array')
@ -95,15 +95,15 @@ describe('systemPreferences module', () => {
})
it('returns values for unknown user defaults', () => {
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'boolean'), false)
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'integer'), 0)
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'float'), 0)
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'double'), 0)
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'string'), '')
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'url'), '')
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'badtype'), undefined)
assert.deepEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'array'), [])
assert.deepEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'dictionary'), {})
assert.strictEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'boolean'), false)
assert.strictEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'integer'), 0)
assert.strictEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'float'), 0)
assert.strictEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'double'), 0)
assert.strictEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'string'), '')
assert.strictEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'url'), '')
assert.strictEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'badtype'), undefined)
assert.deepStrictEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'array'), [])
assert.deepStrictEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'dictionary'), {})
})
})
@ -130,7 +130,7 @@ describe('systemPreferences module', () => {
for (const [type, value] of TEST_CASES) {
systemPreferences.setUserDefault(KEY, type, value)
const retrievedValue = systemPreferences.getUserDefault(KEY, type)
assert.deepEqual(retrievedValue, value)
assert.deepStrictEqual(retrievedValue, value)
}
})
@ -160,7 +160,7 @@ describe('systemPreferences module', () => {
const KEY = 'SystemPreferencesTest'
systemPreferences.setUserDefault(KEY, 'string', 'foo')
systemPreferences.removeUserDefault(KEY)
assert.equal(systemPreferences.getUserDefault(KEY, 'string'), '')
assert.strictEqual(systemPreferences.getUserDefault(KEY, 'string'), '')
})
it('does not throw for missing keys', () => {
@ -170,7 +170,7 @@ describe('systemPreferences module', () => {
describe('systemPreferences.isInvertedColorScheme()', () => {
it('returns a boolean', () => {
assert.equal(typeof systemPreferences.isInvertedColorScheme(), 'boolean')
assert.strictEqual(typeof systemPreferences.isInvertedColorScheme(), 'boolean')
})
})
})

View file

@ -44,9 +44,9 @@ describe('webContents module', () => {
})
assert.ok(all.length >= 4)
assert.equal(all[0].getType(), 'window')
assert.equal(all[all.length - 2].getType(), 'remote')
assert.equal(all[all.length - 1].getType(), 'webview')
assert.strictEqual(all[0].getType(), 'window')
assert.strictEqual(all[all.length - 2].getType(), 'remote')
assert.strictEqual(all[all.length - 1].getType(), 'webview')
done()
})
@ -61,15 +61,15 @@ describe('webContents module', () => {
if (isCi) return done()
const specWebContents = remote.getCurrentWebContents()
assert.equal(specWebContents.id, webContents.getFocusedWebContents().id)
assert.strictEqual(specWebContents.id, webContents.getFocusedWebContents().id)
specWebContents.once('devtools-opened', () => {
assert.equal(specWebContents.devToolsWebContents.id, webContents.getFocusedWebContents().id)
assert.strictEqual(specWebContents.devToolsWebContents.id, webContents.getFocusedWebContents().id)
specWebContents.closeDevTools()
})
specWebContents.once('devtools-closed', () => {
assert.equal(specWebContents.id, webContents.getFocusedWebContents().id)
assert.strictEqual(specWebContents.id, webContents.getFocusedWebContents().id)
done()
})
@ -117,7 +117,7 @@ describe('webContents module', () => {
describe('isFocused() API', () => {
it('returns false when the window is hidden', () => {
BrowserWindow.getAllWindows().forEach((window) => {
assert.equal(!window.isVisible() && window.webContents.isFocused(), false)
assert.strictEqual(!window.isVisible() && window.webContents.isFocused(), false)
})
})
})
@ -159,7 +159,7 @@ describe('webContents module', () => {
w.loadFile(path.join(fixtures, 'pages', 'key-events.html'))
w.webContents.once('did-finish-load', () => {
ipcMain.once('keydown', (event, key) => {
assert.equal(key, 'b')
assert.strictEqual(key, 'b')
done()
})
@ -175,14 +175,14 @@ describe('webContents module', () => {
const testBeforeInput = (opts) => {
return new Promise((resolve, reject) => {
w.webContents.once('before-input-event', (event, input) => {
assert.equal(input.type, opts.type)
assert.equal(input.key, opts.key)
assert.equal(input.code, opts.code)
assert.equal(input.isAutoRepeat, opts.isAutoRepeat)
assert.equal(input.shift, opts.shift)
assert.equal(input.control, opts.control)
assert.equal(input.alt, opts.alt)
assert.equal(input.meta, opts.meta)
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)
resolve()
})
@ -262,12 +262,12 @@ describe('webContents module', () => {
it('can send keydown events', (done) => {
ipcMain.once('keydown', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
assert.equal(key, 'a')
assert.equal(code, 'KeyA')
assert.equal(keyCode, 65)
assert.equal(shiftKey, false)
assert.equal(ctrlKey, false)
assert.equal(altKey, false)
assert.strictEqual(key, 'a')
assert.strictEqual(code, 'KeyA')
assert.strictEqual(keyCode, 65)
assert.strictEqual(shiftKey, false)
assert.strictEqual(ctrlKey, false)
assert.strictEqual(altKey, false)
done()
})
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'A' })
@ -275,12 +275,12 @@ describe('webContents module', () => {
it('can send keydown events with modifiers', (done) => {
ipcMain.once('keydown', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
assert.equal(key, 'Z')
assert.equal(code, 'KeyZ')
assert.equal(keyCode, 90)
assert.equal(shiftKey, true)
assert.equal(ctrlKey, true)
assert.equal(altKey, false)
assert.strictEqual(key, 'Z')
assert.strictEqual(code, 'KeyZ')
assert.strictEqual(keyCode, 90)
assert.strictEqual(shiftKey, true)
assert.strictEqual(ctrlKey, true)
assert.strictEqual(altKey, false)
done()
})
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'Z', modifiers: ['shift', 'ctrl'] })
@ -288,12 +288,12 @@ describe('webContents module', () => {
it('can send keydown events with special keys', (done) => {
ipcMain.once('keydown', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
assert.equal(key, 'Tab')
assert.equal(code, 'Tab')
assert.equal(keyCode, 9)
assert.equal(shiftKey, false)
assert.equal(ctrlKey, false)
assert.equal(altKey, true)
assert.strictEqual(key, 'Tab')
assert.strictEqual(code, 'Tab')
assert.strictEqual(keyCode, 9)
assert.strictEqual(shiftKey, false)
assert.strictEqual(ctrlKey, false)
assert.strictEqual(altKey, true)
done()
})
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'Tab', modifiers: ['alt'] })
@ -301,12 +301,12 @@ describe('webContents module', () => {
it('can send char events', (done) => {
ipcMain.once('keypress', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
assert.equal(key, 'a')
assert.equal(code, 'KeyA')
assert.equal(keyCode, 65)
assert.equal(shiftKey, false)
assert.equal(ctrlKey, false)
assert.equal(altKey, false)
assert.strictEqual(key, 'a')
assert.strictEqual(code, 'KeyA')
assert.strictEqual(keyCode, 65)
assert.strictEqual(shiftKey, false)
assert.strictEqual(ctrlKey, false)
assert.strictEqual(altKey, false)
done()
})
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'A' })
@ -315,12 +315,12 @@ describe('webContents module', () => {
it('can send char events with modifiers', (done) => {
ipcMain.once('keypress', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
assert.equal(key, 'Z')
assert.equal(code, 'KeyZ')
assert.equal(keyCode, 90)
assert.equal(shiftKey, true)
assert.equal(ctrlKey, true)
assert.equal(altKey, false)
assert.strictEqual(key, 'Z')
assert.strictEqual(code, 'KeyZ')
assert.strictEqual(keyCode, 90)
assert.strictEqual(shiftKey, true)
assert.strictEqual(ctrlKey, true)
assert.strictEqual(altKey, false)
done()
})
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'Z' })
@ -332,7 +332,7 @@ describe('webContents module', () => {
w.loadURL('about:blank')
w.webContents.insertCSS('body { background-repeat: round; }')
w.webContents.executeJavaScript('window.getComputedStyle(document.body).getPropertyValue("background-repeat")', (result) => {
assert.equal(result, 'round')
assert.strictEqual(result, 'round')
done()
})
})
@ -367,8 +367,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.equal(parentFocused, true)
assert.equal(childFocused, false)
assert.strictEqual(parentFocused, true)
assert.strictEqual(childFocused, false)
done()
})
w.show()
@ -383,7 +383,7 @@ describe('webContents module', () => {
w.webContents.once('did-finish-load', () => {
const pid = w.webContents.getOSProcessId()
assert.equal(typeof pid, 'number')
assert.strictEqual(typeof pid, 'number')
assert(pid > 0, `pid ${pid} is not greater than 0`)
done()
})
@ -424,10 +424,10 @@ describe('webContents module', () => {
w.loadURL('about:blank')
w.webContents.on('did-finish-load', () => {
w.webContents.getZoomLevel((zoomLevel) => {
assert.equal(zoomLevel, 0.0)
assert.strictEqual(zoomLevel, 0.0)
w.webContents.setZoomLevel(0.5)
w.webContents.getZoomLevel((zoomLevel) => {
assert.equal(zoomLevel, 0.5)
assert.strictEqual(zoomLevel, 0.5)
w.webContents.setZoomLevel(0)
done()
})
@ -444,7 +444,7 @@ describe('webContents module', () => {
})
ipcMain.on('host1-zoom-level', (e, zoomLevel) => {
const expectedZoomLevel = hostZoomMap.host1
assert.equal(zoomLevel, expectedZoomLevel)
assert.strictEqual(zoomLevel, expectedZoomLevel)
if (finalNavigation) {
done()
} else {
@ -453,7 +453,7 @@ describe('webContents module', () => {
})
ipcMain.once('host2-zoom-level', (e, zoomLevel) => {
const expectedZoomLevel = hostZoomMap.host2
assert.equal(zoomLevel, expectedZoomLevel)
assert.strictEqual(zoomLevel, expectedZoomLevel)
finalNavigation = true
w.webContents.goBack()
})
@ -466,9 +466,9 @@ describe('webContents module', () => {
})
w2.webContents.on('did-finish-load', () => {
w.webContents.getZoomLevel((zoomLevel1) => {
assert.equal(zoomLevel1, hostZoomMap.host3)
assert.strictEqual(zoomLevel1, hostZoomMap.host3)
w2.webContents.getZoomLevel((zoomLevel2) => {
assert.equal(zoomLevel1, zoomLevel2)
assert.strictEqual(zoomLevel1, zoomLevel2)
w2.setClosable(true)
w2.close()
done()
@ -496,10 +496,10 @@ describe('webContents module', () => {
if (error) return done(error)
w2.webContents.on('did-finish-load', () => {
w.webContents.getZoomLevel((zoomLevel1) => {
assert.equal(zoomLevel1, hostZoomMap.host3)
assert.strictEqual(zoomLevel1, hostZoomMap.host3)
w2.webContents.getZoomLevel((zoomLevel2) => {
assert.equal(zoomLevel2, 0)
assert.notEqual(zoomLevel1, zoomLevel2)
assert.strictEqual(zoomLevel2, 0)
assert.notStrictEqual(zoomLevel1, zoomLevel2)
protocol.unregisterProtocol(zoomScheme, (error) => {
if (error) return done(error)
w2.setClosable(true)
@ -529,7 +529,7 @@ describe('webContents module', () => {
w.webContents.on('did-frame-finish-load', (e, isMainFrame) => {
if (!isMainFrame) {
w.webContents.getZoomLevel((zoomLevel) => {
assert.equal(zoomLevel, 2.0)
assert.strictEqual(zoomLevel, 2.0)
w.webContents.setZoomLevel(0)
server.close()
done()
@ -550,10 +550,10 @@ describe('webContents module', () => {
})
w2.webContents.on('did-finish-load', () => {
w.webContents.getZoomLevel((zoomLevel1) => {
assert.equal(zoomLevel1, finalZoomLevel)
assert.strictEqual(zoomLevel1, finalZoomLevel)
w2.webContents.getZoomLevel((zoomLevel2) => {
assert.equal(zoomLevel2, 0)
assert.notEqual(zoomLevel1, zoomLevel2)
assert.strictEqual(zoomLevel2, 0)
assert.notStrictEqual(zoomLevel1, zoomLevel2)
w2.setClosable(true)
w2.close()
done()
@ -579,13 +579,13 @@ describe('webContents module', () => {
w.webContents.executeJavaScript(source, () => {})
} else {
w.webContents.getZoomLevel((zoomLevel) => {
assert.equal(zoomLevel, 0)
assert.strictEqual(zoomLevel, 0)
done()
})
}
})
ipcMain.once('zoom-level-set', (e, zoomLevel) => {
assert.equal(zoomLevel, 0.6)
assert.strictEqual(zoomLevel, 0.6)
w.loadFile(path.join(fixtures, 'pages', 'd.html'))
initialNavigation = false
})
@ -603,7 +603,7 @@ describe('webContents module', () => {
]
policies.forEach((policy) => {
w.webContents.setWebRTCIPHandlingPolicy(policy)
assert.equal(w.webContents.getWebRTCIPHandlingPolicy(), policy)
assert.strictEqual(w.webContents.getWebRTCIPHandlingPolicy(), policy)
})
})
})
@ -635,8 +635,8 @@ describe('webContents module', () => {
describe('setIgnoreMenuShortcuts(ignore)', () => {
it('does not throw', () => {
assert.equal(w.webContents.setIgnoreMenuShortcuts(true), undefined)
assert.equal(w.webContents.setIgnoreMenuShortcuts(false), undefined)
assert.strictEqual(w.webContents.setIgnoreMenuShortcuts(true), undefined)
assert.strictEqual(w.webContents.setIgnoreMenuShortcuts(false), undefined)
})
})
@ -712,10 +712,10 @@ describe('webContents module', () => {
w.webContents.on('did-change-theme-color', (e, color) => {
if (count === 0) {
count += 1
assert.equal(color, '#FFEEDD')
assert.strictEqual(color, '#FFEEDD')
w.loadFile(path.join(fixtures, 'pages', 'base-page.html'))
} else if (count === 1) {
assert.equal(color, null)
assert.strictEqual(color, null)
done()
}
})
@ -739,7 +739,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.equal(req.headers.referer, 'http://127.0.0.1:' + server.address().port + '/')
assert.strictEqual(req.headers.referer, 'http://127.0.0.1:' + server.address().port + '/')
return done()
}
res.end('<a id="a" href="/should_have_referrer" target="_blank">link</a>')
@ -748,8 +748,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.equal(referrer.url, url)
assert.equal(referrer.policy, 'no-referrer-when-downgrade')
assert.strictEqual(referrer.url, url)
assert.strictEqual(referrer.policy, 'no-referrer-when-downgrade')
})
w.webContents.executeJavaScript('a.click()')
})
@ -762,7 +762,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.equal(req.headers.referer, 'http://127.0.0.1:' + server.address().port + '/')
assert.strictEqual(req.headers.referer, 'http://127.0.0.1:' + server.address().port + '/')
return done()
}
res.end('')
@ -771,8 +771,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.equal(referrer.url, url)
assert.equal(referrer.policy, 'no-referrer-when-downgrade')
assert.strictEqual(referrer.url, url)
assert.strictEqual(referrer.policy, 'no-referrer-when-downgrade')
})
w.webContents.executeJavaScript('window.open(location.href + "should_have_referrer")')
})
@ -792,7 +792,7 @@ describe('webContents module', () => {
})
w.webContents.once('did-finish-load', () => {
w.webContents.executeJavaScript('37 + 5', (result) => {
assert.equal(result, 42)
assert.strictEqual(result, 42)
done()
})
})

View file

@ -130,7 +130,7 @@ describe('webFrame module', function () {
}, function (error) {
if (error) return done(error)
ipcMain.once('response', function (event, status) {
assert.equal(status, expected)
assert.strictEqual(status, expected)
done()
})
w.loadURL(url)

View file

@ -67,7 +67,7 @@ describe('webRequest module', () => {
$.ajax({
url: `${defaultURL}nofilter/test`,
success: (data) => {
assert.equal(data, '/nofilter/test')
assert.strictEqual(data, '/nofilter/test')
$.ajax({
url: `${defaultURL}filter/test`,
success: () => done('unexpected success'),
@ -80,19 +80,19 @@ describe('webRequest module', () => {
it('receives details object', (done) => {
ses.webRequest.onBeforeRequest((details, callback) => {
assert.equal(typeof details.id, 'number')
assert.equal(typeof details.timestamp, 'number')
assert.equal(typeof details.webContentsId, 'number')
assert.equal(details.url, defaultURL)
assert.equal(details.method, 'GET')
assert.equal(details.resourceType, 'xhr')
assert.strictEqual(typeof details.id, 'number')
assert.strictEqual(typeof details.timestamp, 'number')
assert.strictEqual(typeof details.webContentsId, 'number')
assert.strictEqual(details.url, defaultURL)
assert.strictEqual(details.method, 'GET')
assert.strictEqual(details.resourceType, 'xhr')
assert(!details.uploadData)
callback({})
})
$.ajax({
url: defaultURL,
success: (data) => {
assert.equal(data, '/')
assert.strictEqual(data, '/')
done()
},
error: (xhr, errorType) => done(errorType)
@ -105,11 +105,11 @@ describe('webRequest module', () => {
type: 'string'
}
ses.webRequest.onBeforeRequest((details, callback) => {
assert.equal(details.url, defaultURL)
assert.equal(details.method, 'POST')
assert.equal(details.uploadData.length, 1)
assert.strictEqual(details.url, defaultURL)
assert.strictEqual(details.method, 'POST')
assert.strictEqual(details.uploadData.length, 1)
const data = qs.parse(details.uploadData[0].bytes.toString())
assert.deepEqual(data, postData)
assert.deepStrictEqual({ ...data }, postData)
callback({ cancel: true })
})
$.ajax({
@ -132,7 +132,7 @@ describe('webRequest module', () => {
$.ajax({
url: defaultURL,
success: (data) => {
assert.equal(data, '/redirect')
assert.strictEqual(data, '/redirect')
done()
},
error: (xhr, errorType) => done(errorType)
@ -147,15 +147,15 @@ describe('webRequest module', () => {
it('receives details object', (done) => {
ses.webRequest.onBeforeSendHeaders((details, callback) => {
assert.equal(typeof details.requestHeaders, 'object')
assert.equal(details.requestHeaders['Foo.Bar'], 'baz')
assert.strictEqual(typeof details.requestHeaders, 'object')
assert.strictEqual(details.requestHeaders['Foo.Bar'], 'baz')
callback({})
})
$.ajax({
url: defaultURL,
headers: { 'Foo.Bar': 'baz' },
success: (data) => {
assert.equal(data, '/')
assert.strictEqual(data, '/')
done()
},
error: (xhr, errorType) => done(errorType)
@ -171,7 +171,7 @@ describe('webRequest module', () => {
$.ajax({
url: defaultURL,
success: (data) => {
assert.equal(data, '/header/received')
assert.strictEqual(data, '/header/received')
done()
},
error: (xhr, errorType) => done(errorType)
@ -186,7 +186,7 @@ describe('webRequest module', () => {
callback({ requestHeaders: requestHeaders })
})
ses.webRequest.onSendHeaders((details) => {
assert.deepEqual(details.requestHeaders, requestHeaders)
assert.deepStrictEqual(details.requestHeaders, requestHeaders)
done()
})
$.ajax({
@ -203,12 +203,12 @@ describe('webRequest module', () => {
it('receives details object', (done) => {
ses.webRequest.onSendHeaders((details) => {
assert.equal(typeof details.requestHeaders, 'object')
assert.strictEqual(typeof details.requestHeaders, 'object')
})
$.ajax({
url: defaultURL,
success: (data) => {
assert.equal(data, '/')
assert.strictEqual(data, '/')
done()
},
error: (xhr, errorType) => done(errorType)
@ -223,15 +223,15 @@ describe('webRequest module', () => {
it('receives details object', (done) => {
ses.webRequest.onHeadersReceived((details, callback) => {
assert.equal(details.statusLine, 'HTTP/1.1 200 OK')
assert.equal(details.statusCode, 200)
assert.equal(details.responseHeaders['Custom'], 'Header')
assert.strictEqual(details.statusLine, 'HTTP/1.1 200 OK')
assert.strictEqual(details.statusCode, 200)
assert.deepStrictEqual(details.responseHeaders['Custom'], ['Header'])
callback({})
})
$.ajax({
url: defaultURL,
success: (data) => {
assert.equal(data, '/')
assert.strictEqual(data, '/')
done()
},
error: (xhr, errorType) => done(errorType)
@ -247,8 +247,8 @@ describe('webRequest module', () => {
$.ajax({
url: defaultURL,
success: (data, status, xhr) => {
assert.equal(xhr.getResponseHeader('Custom'), 'Changed')
assert.equal(data, '/')
assert.strictEqual(xhr.getResponseHeader('Custom'), 'Changed')
assert.strictEqual(data, '/')
done()
},
error: (xhr, errorType) => done(errorType)
@ -262,8 +262,8 @@ describe('webRequest module', () => {
$.ajax({
url: defaultURL,
success: (data, status, xhr) => {
assert.equal(xhr.getResponseHeader('Custom'), 'Header')
assert.equal(data, '/')
assert.strictEqual(xhr.getResponseHeader('Custom'), 'Header')
assert.strictEqual(data, '/')
done()
},
error: (xhr, errorType) => done(errorType)
@ -278,7 +278,7 @@ describe('webRequest module', () => {
$.ajax({
url: defaultURL + 'serverRedirect',
success: (data, status, xhr) => {
assert.equal(xhr.getResponseHeader('Custom'), 'Header')
assert.strictEqual(xhr.getResponseHeader('Custom'), 'Header')
done()
},
error: (xhr, errorType) => done(errorType)
@ -297,7 +297,7 @@ describe('webRequest module', () => {
url: defaultURL,
success: (data, status, xhr) => {},
error: (xhr, errorType) => {
assert.equal(xhr.getResponseHeader('Custom'), 'Header')
assert.strictEqual(xhr.getResponseHeader('Custom'), 'Header')
done()
}
})
@ -311,16 +311,16 @@ describe('webRequest module', () => {
it('receives details object', (done) => {
ses.webRequest.onResponseStarted((details) => {
assert.equal(typeof details.fromCache, 'boolean')
assert.equal(details.statusLine, 'HTTP/1.1 200 OK')
assert.equal(details.statusCode, 200)
assert.equal(details.responseHeaders['Custom'], 'Header')
assert.strictEqual(typeof details.fromCache, 'boolean')
assert.strictEqual(details.statusLine, 'HTTP/1.1 200 OK')
assert.strictEqual(details.statusCode, 200)
assert.deepStrictEqual(details.responseHeaders['Custom'], ['Header'])
})
$.ajax({
url: defaultURL,
success: (data, status, xhr) => {
assert.equal(xhr.getResponseHeader('Custom'), 'Header')
assert.equal(data, '/')
assert.strictEqual(xhr.getResponseHeader('Custom'), 'Header')
assert.strictEqual(data, '/')
done()
},
error: (xhr, errorType) => done(errorType)
@ -344,15 +344,15 @@ describe('webRequest module', () => {
}
})
ses.webRequest.onBeforeRedirect((details) => {
assert.equal(typeof details.fromCache, 'boolean')
assert.equal(details.statusLine, 'HTTP/1.1 307 Internal Redirect')
assert.equal(details.statusCode, 307)
assert.equal(details.redirectURL, redirectURL)
assert.strictEqual(typeof details.fromCache, 'boolean')
assert.strictEqual(details.statusLine, 'HTTP/1.1 307 Internal Redirect')
assert.strictEqual(details.statusCode, 307)
assert.strictEqual(details.redirectURL, redirectURL)
})
$.ajax({
url: defaultURL,
success: (data) => {
assert.equal(data, '/redirect')
assert.strictEqual(data, '/redirect')
done()
},
error: (xhr, errorType) => done(errorType)
@ -367,14 +367,14 @@ describe('webRequest module', () => {
it('receives details object', (done) => {
ses.webRequest.onCompleted((details) => {
assert.equal(typeof details.fromCache, 'boolean')
assert.equal(details.statusLine, 'HTTP/1.1 200 OK')
assert.equal(details.statusCode, 200)
assert.strictEqual(typeof details.fromCache, 'boolean')
assert.strictEqual(details.statusLine, 'HTTP/1.1 200 OK')
assert.strictEqual(details.statusCode, 200)
})
$.ajax({
url: defaultURL,
success: (data) => {
assert.equal(data, '/')
assert.strictEqual(data, '/')
done()
},
error: (xhr, errorType) => done(errorType)
@ -393,7 +393,7 @@ describe('webRequest module', () => {
callback({ cancel: true })
})
ses.webRequest.onErrorOccurred((details) => {
assert.equal(details.error, 'net::ERR_BLOCKED_BY_CLIENT')
assert.strictEqual(details.error, 'net::ERR_BLOCKED_BY_CLIENT')
done()
})
$.ajax({

View file

@ -18,7 +18,7 @@ describe('asar package', function () {
describe('node api', function () {
it('supports paths specified as a Buffer', function () {
var file = Buffer.from(path.join(fixtures, 'asar', 'a.asar', 'file1'))
assert.equal(fs.existsSync(file), true)
assert.strictEqual(fs.existsSync(file), true)
})
describe('fs.readFileSync', function () {
@ -32,30 +32,30 @@ describe('asar package', function () {
it('reads a normal file', function () {
var file1 = path.join(fixtures, 'asar', 'a.asar', 'file1')
assert.equal(fs.readFileSync(file1).toString().trim(), 'file1')
assert.strictEqual(fs.readFileSync(file1).toString().trim(), 'file1')
var file2 = path.join(fixtures, 'asar', 'a.asar', 'file2')
assert.equal(fs.readFileSync(file2).toString().trim(), 'file2')
assert.strictEqual(fs.readFileSync(file2).toString().trim(), 'file2')
var file3 = path.join(fixtures, 'asar', 'a.asar', 'file3')
assert.equal(fs.readFileSync(file3).toString().trim(), 'file3')
assert.strictEqual(fs.readFileSync(file3).toString().trim(), 'file3')
})
it('reads from a empty file', function () {
var file = path.join(fixtures, 'asar', 'empty.asar', 'file1')
var buffer = fs.readFileSync(file)
assert.equal(buffer.length, 0)
assert.equal(buffer.toString(), '')
assert.strictEqual(buffer.length, 0)
assert.strictEqual(buffer.toString(), '')
})
it('reads a linked file', function () {
var p = path.join(fixtures, 'asar', 'a.asar', 'link1')
assert.equal(fs.readFileSync(p).toString().trim(), 'file1')
assert.strictEqual(fs.readFileSync(p).toString().trim(), 'file1')
})
it('reads a file from linked directory', function () {
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'file1')
assert.equal(fs.readFileSync(p).toString().trim(), 'file1')
assert.strictEqual(fs.readFileSync(p).toString().trim(), 'file1')
p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1')
assert.equal(fs.readFileSync(p).toString().trim(), 'file1')
assert.strictEqual(fs.readFileSync(p).toString().trim(), 'file1')
})
it('throws ENOENT error when can not find file', function () {
@ -78,7 +78,7 @@ describe('asar package', function () {
it('reads a normal file with unpacked files', function () {
var p = path.join(fixtures, 'asar', 'unpack.asar', 'a.txt')
assert.equal(fs.readFileSync(p).toString().trim(), 'a')
assert.strictEqual(fs.readFileSync(p).toString().trim(), 'a')
})
})
@ -86,8 +86,8 @@ describe('asar package', function () {
it('reads a normal file', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
fs.readFile(p, function (err, content) {
assert.equal(err, null)
assert.equal(String(content).trim(), 'file1')
assert.strictEqual(err, null)
assert.strictEqual(String(content).trim(), 'file1')
done()
})
})
@ -95,8 +95,8 @@ describe('asar package', function () {
it('reads from a empty file', function (done) {
var p = path.join(fixtures, 'asar', 'empty.asar', 'file1')
fs.readFile(p, function (err, content) {
assert.equal(err, null)
assert.equal(String(content), '')
assert.strictEqual(err, null)
assert.strictEqual(String(content), '')
done()
})
})
@ -104,8 +104,8 @@ describe('asar package', function () {
it('reads from a empty file with encoding', function (done) {
var p = path.join(fixtures, 'asar', 'empty.asar', 'file1')
fs.readFile(p, 'utf8', function (err, content) {
assert.equal(err, null)
assert.equal(content, '')
assert.strictEqual(err, null)
assert.strictEqual(content, '')
done()
})
})
@ -113,8 +113,8 @@ describe('asar package', function () {
it('reads a linked file', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'link1')
fs.readFile(p, function (err, content) {
assert.equal(err, null)
assert.equal(String(content).trim(), 'file1')
assert.strictEqual(err, null)
assert.strictEqual(String(content).trim(), 'file1')
done()
})
})
@ -122,8 +122,8 @@ describe('asar package', function () {
it('reads a file from linked directory', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1')
fs.readFile(p, function (err, content) {
assert.equal(err, null)
assert.equal(String(content).trim(), 'file1')
assert.strictEqual(err, null)
assert.strictEqual(String(content).trim(), 'file1')
done()
})
})
@ -131,7 +131,7 @@ describe('asar package', function () {
it('throws ENOENT error when can not find file', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
fs.readFile(p, function (err) {
assert.equal(err.code, 'ENOENT')
assert.strictEqual(err.code, 'ENOENT')
done()
})
})
@ -147,10 +147,10 @@ describe('asar package', function () {
it('returns information of root', function () {
var p = path.join(fixtures, 'asar', 'a.asar')
var stats = fs.lstatSync(p)
assert.equal(stats.isFile(), false)
assert.equal(stats.isDirectory(), true)
assert.equal(stats.isSymbolicLink(), false)
assert.equal(stats.size, 0)
assert.strictEqual(stats.isFile(), false)
assert.strictEqual(stats.isDirectory(), true)
assert.strictEqual(stats.isSymbolicLink(), false)
assert.strictEqual(stats.size, 0)
})
it('returns information of a normal file', function () {
@ -160,10 +160,10 @@ describe('asar package', function () {
file = ref2[j]
p = path.join(fixtures, 'asar', 'a.asar', file)
stats = fs.lstatSync(p)
assert.equal(stats.isFile(), true)
assert.equal(stats.isDirectory(), false)
assert.equal(stats.isSymbolicLink(), false)
assert.equal(stats.size, 6)
assert.strictEqual(stats.isFile(), true)
assert.strictEqual(stats.isDirectory(), false)
assert.strictEqual(stats.isSymbolicLink(), false)
assert.strictEqual(stats.size, 6)
}
})
@ -174,10 +174,10 @@ describe('asar package', function () {
file = ref2[j]
p = path.join(fixtures, 'asar', 'a.asar', file)
stats = fs.lstatSync(p)
assert.equal(stats.isFile(), false)
assert.equal(stats.isDirectory(), true)
assert.equal(stats.isSymbolicLink(), false)
assert.equal(stats.size, 0)
assert.strictEqual(stats.isFile(), false)
assert.strictEqual(stats.isDirectory(), true)
assert.strictEqual(stats.isSymbolicLink(), false)
assert.strictEqual(stats.size, 0)
}
})
@ -188,10 +188,10 @@ describe('asar package', function () {
file = ref2[j]
p = path.join(fixtures, 'asar', 'a.asar', file)
stats = fs.lstatSync(p)
assert.equal(stats.isFile(), false)
assert.equal(stats.isDirectory(), false)
assert.equal(stats.isSymbolicLink(), true)
assert.equal(stats.size, 0)
assert.strictEqual(stats.isFile(), false)
assert.strictEqual(stats.isDirectory(), false)
assert.strictEqual(stats.isSymbolicLink(), true)
assert.strictEqual(stats.size, 0)
}
})
@ -202,10 +202,10 @@ describe('asar package', function () {
file = ref2[j]
p = path.join(fixtures, 'asar', 'a.asar', file)
stats = fs.lstatSync(p)
assert.equal(stats.isFile(), false)
assert.equal(stats.isDirectory(), false)
assert.equal(stats.isSymbolicLink(), true)
assert.equal(stats.size, 0)
assert.strictEqual(stats.isFile(), false)
assert.strictEqual(stats.isDirectory(), false)
assert.strictEqual(stats.isSymbolicLink(), true)
assert.strictEqual(stats.size, 0)
}
})
@ -232,11 +232,11 @@ describe('asar package', function () {
it('returns information of root', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar')
fs.lstat(p, function (err, stats) {
assert.equal(err, null)
assert.equal(stats.isFile(), false)
assert.equal(stats.isDirectory(), true)
assert.equal(stats.isSymbolicLink(), false)
assert.equal(stats.size, 0)
assert.strictEqual(err, null)
assert.strictEqual(stats.isFile(), false)
assert.strictEqual(stats.isDirectory(), true)
assert.strictEqual(stats.isSymbolicLink(), false)
assert.strictEqual(stats.size, 0)
done()
})
})
@ -244,11 +244,11 @@ describe('asar package', function () {
it('returns information of a normal file', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'file1')
fs.lstat(p, function (err, stats) {
assert.equal(err, null)
assert.equal(stats.isFile(), true)
assert.equal(stats.isDirectory(), false)
assert.equal(stats.isSymbolicLink(), false)
assert.equal(stats.size, 6)
assert.strictEqual(err, null)
assert.strictEqual(stats.isFile(), true)
assert.strictEqual(stats.isDirectory(), false)
assert.strictEqual(stats.isSymbolicLink(), false)
assert.strictEqual(stats.size, 6)
done()
})
})
@ -256,11 +256,11 @@ describe('asar package', function () {
it('returns information of a normal directory', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'dir1')
fs.lstat(p, function (err, stats) {
assert.equal(err, null)
assert.equal(stats.isFile(), false)
assert.equal(stats.isDirectory(), true)
assert.equal(stats.isSymbolicLink(), false)
assert.equal(stats.size, 0)
assert.strictEqual(err, null)
assert.strictEqual(stats.isFile(), false)
assert.strictEqual(stats.isDirectory(), true)
assert.strictEqual(stats.isSymbolicLink(), false)
assert.strictEqual(stats.size, 0)
done()
})
})
@ -268,11 +268,11 @@ describe('asar package', function () {
it('returns information of a linked file', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link1')
fs.lstat(p, function (err, stats) {
assert.equal(err, null)
assert.equal(stats.isFile(), false)
assert.equal(stats.isDirectory(), false)
assert.equal(stats.isSymbolicLink(), true)
assert.equal(stats.size, 0)
assert.strictEqual(err, null)
assert.strictEqual(stats.isFile(), false)
assert.strictEqual(stats.isDirectory(), false)
assert.strictEqual(stats.isSymbolicLink(), true)
assert.strictEqual(stats.size, 0)
done()
})
})
@ -280,11 +280,11 @@ describe('asar package', function () {
it('returns information of a linked directory', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2')
fs.lstat(p, function (err, stats) {
assert.equal(err, null)
assert.equal(stats.isFile(), false)
assert.equal(stats.isDirectory(), false)
assert.equal(stats.isSymbolicLink(), true)
assert.equal(stats.size, 0)
assert.strictEqual(err, null)
assert.strictEqual(stats.isFile(), false)
assert.strictEqual(stats.isDirectory(), false)
assert.strictEqual(stats.isSymbolicLink(), true)
assert.strictEqual(stats.size, 0)
done()
})
})
@ -292,7 +292,7 @@ describe('asar package', function () {
it('throws ENOENT error when can not find file', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'file4')
fs.lstat(p, function (err) {
assert.equal(err.code, 'ENOENT')
assert.strictEqual(err.code, 'ENOENT')
done()
})
})
@ -303,42 +303,42 @@ describe('asar package', function () {
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
const p = 'a.asar'
const r = fs.realpathSync(path.join(parent, p))
assert.equal(r, path.join(parent, p))
assert.strictEqual(r, path.join(parent, p))
})
it('returns real path of a normal file', () => {
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
const p = path.join('a.asar', 'file1')
const r = fs.realpathSync(path.join(parent, p))
assert.equal(r, path.join(parent, p))
assert.strictEqual(r, path.join(parent, p))
})
it('returns real path of a normal directory', () => {
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
const p = path.join('a.asar', 'dir1')
const r = fs.realpathSync(path.join(parent, p))
assert.equal(r, path.join(parent, p))
assert.strictEqual(r, path.join(parent, p))
})
it('returns real path of a linked file', () => {
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
const p = path.join('a.asar', 'link2', 'link1')
const r = fs.realpathSync(path.join(parent, p))
assert.equal(r, path.join(parent, 'a.asar', 'file1'))
assert.strictEqual(r, path.join(parent, 'a.asar', 'file1'))
})
it('returns real path of a linked directory', () => {
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
const p = path.join('a.asar', 'link2', 'link2')
const r = fs.realpathSync(path.join(parent, p))
assert.equal(r, path.join(parent, 'a.asar', 'dir1'))
assert.strictEqual(r, path.join(parent, 'a.asar', 'dir1'))
})
it('returns real path of an unpacked file', () => {
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
const p = path.join('unpack.asar', 'a.txt')
const r = fs.realpathSync(path.join(parent, p))
assert.equal(r, path.join(parent, p))
assert.strictEqual(r, path.join(parent, p))
})
it('throws ENOENT error when can not find file', () => {
@ -354,42 +354,42 @@ describe('asar package', function () {
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
const p = 'a.asar'
const r = fs.realpathSync.native(path.join(parent, p))
assert.equal(r, path.join(parent, p))
assert.strictEqual(r, path.join(parent, p))
})
it('returns real path of a normal file', () => {
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
const p = path.join('a.asar', 'file1')
const r = fs.realpathSync.native(path.join(parent, p))
assert.equal(r, path.join(parent, p))
assert.strictEqual(r, path.join(parent, p))
})
it('returns real path of a normal directory', () => {
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
const p = path.join('a.asar', 'dir1')
const r = fs.realpathSync.native(path.join(parent, p))
assert.equal(r, path.join(parent, p))
assert.strictEqual(r, path.join(parent, p))
})
it('returns real path of a linked file', () => {
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
const p = path.join('a.asar', 'link2', 'link1')
const r = fs.realpathSync.native(path.join(parent, p))
assert.equal(r, path.join(parent, 'a.asar', 'file1'))
assert.strictEqual(r, path.join(parent, 'a.asar', 'file1'))
})
it('returns real path of a linked directory', () => {
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
const p = path.join('a.asar', 'link2', 'link2')
const r = fs.realpathSync.native(path.join(parent, p))
assert.equal(r, path.join(parent, 'a.asar', 'dir1'))
assert.strictEqual(r, path.join(parent, 'a.asar', 'dir1'))
})
it('returns real path of an unpacked file', () => {
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
const p = path.join('unpack.asar', 'a.txt')
const r = fs.realpathSync.native(path.join(parent, p))
assert.equal(r, path.join(parent, p))
assert.strictEqual(r, path.join(parent, p))
})
it('throws ENOENT error when can not find file', () => {
@ -405,8 +405,8 @@ describe('asar package', function () {
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
const p = 'a.asar'
fs.realpath(path.join(parent, p), (err, r) => {
assert.equal(err, null)
assert.equal(r, path.join(parent, p))
assert.strictEqual(err, null)
assert.strictEqual(r, path.join(parent, p))
done()
})
})
@ -415,8 +415,8 @@ describe('asar package', function () {
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
const p = path.join('a.asar', 'file1')
fs.realpath(path.join(parent, p), (err, r) => {
assert.equal(err, null)
assert.equal(r, path.join(parent, p))
assert.strictEqual(err, null)
assert.strictEqual(r, path.join(parent, p))
done()
})
})
@ -425,8 +425,8 @@ describe('asar package', function () {
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
const p = path.join('a.asar', 'dir1')
fs.realpath(path.join(parent, p), (err, r) => {
assert.equal(err, null)
assert.equal(r, path.join(parent, p))
assert.strictEqual(err, null)
assert.strictEqual(r, path.join(parent, p))
done()
})
})
@ -435,8 +435,8 @@ describe('asar package', function () {
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
const p = path.join('a.asar', 'link2', 'link1')
fs.realpath(path.join(parent, p), (err, r) => {
assert.equal(err, null)
assert.equal(r, path.join(parent, 'a.asar', 'file1'))
assert.strictEqual(err, null)
assert.strictEqual(r, path.join(parent, 'a.asar', 'file1'))
done()
})
})
@ -445,8 +445,8 @@ describe('asar package', function () {
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
const p = path.join('a.asar', 'link2', 'link2')
fs.realpath(path.join(parent, p), (err, r) => {
assert.equal(err, null)
assert.equal(r, path.join(parent, 'a.asar', 'dir1'))
assert.strictEqual(err, null)
assert.strictEqual(r, path.join(parent, 'a.asar', 'dir1'))
done()
})
})
@ -455,8 +455,8 @@ describe('asar package', function () {
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
const p = path.join('unpack.asar', 'a.txt')
fs.realpath(path.join(parent, p), (err, r) => {
assert.equal(err, null)
assert.equal(r, path.join(parent, p))
assert.strictEqual(err, null)
assert.strictEqual(r, path.join(parent, p))
done()
})
})
@ -465,7 +465,7 @@ describe('asar package', function () {
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
const p = path.join('a.asar', 'not-exist')
fs.realpath(path.join(parent, p), err => {
assert.equal(err.code, 'ENOENT')
assert.strictEqual(err.code, 'ENOENT')
done()
})
})
@ -476,8 +476,8 @@ describe('asar package', function () {
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
const p = 'a.asar'
fs.realpath.native(path.join(parent, p), (err, r) => {
assert.equal(err, null)
assert.equal(r, path.join(parent, p))
assert.strictEqual(err, null)
assert.strictEqual(r, path.join(parent, p))
done()
})
})
@ -486,8 +486,8 @@ describe('asar package', function () {
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
const p = path.join('a.asar', 'file1')
fs.realpath.native(path.join(parent, p), (err, r) => {
assert.equal(err, null)
assert.equal(r, path.join(parent, p))
assert.strictEqual(err, null)
assert.strictEqual(r, path.join(parent, p))
done()
})
})
@ -496,8 +496,8 @@ describe('asar package', function () {
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
const p = path.join('a.asar', 'dir1')
fs.realpath.native(path.join(parent, p), (err, r) => {
assert.equal(err, null)
assert.equal(r, path.join(parent, p))
assert.strictEqual(err, null)
assert.strictEqual(r, path.join(parent, p))
done()
})
})
@ -506,8 +506,8 @@ describe('asar package', function () {
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
const p = path.join('a.asar', 'link2', 'link1')
fs.realpath.native(path.join(parent, p), (err, r) => {
assert.equal(err, null)
assert.equal(r, path.join(parent, 'a.asar', 'file1'))
assert.strictEqual(err, null)
assert.strictEqual(r, path.join(parent, 'a.asar', 'file1'))
done()
})
})
@ -516,8 +516,8 @@ describe('asar package', function () {
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
const p = path.join('a.asar', 'link2', 'link2')
fs.realpath.native(path.join(parent, p), (err, r) => {
assert.equal(err, null)
assert.equal(r, path.join(parent, 'a.asar', 'dir1'))
assert.strictEqual(err, null)
assert.strictEqual(r, path.join(parent, 'a.asar', 'dir1'))
done()
})
})
@ -526,8 +526,8 @@ describe('asar package', function () {
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
const p = path.join('unpack.asar', 'a.txt')
fs.realpath.native(path.join(parent, p), (err, r) => {
assert.equal(err, null)
assert.equal(r, path.join(parent, p))
assert.strictEqual(err, null)
assert.strictEqual(r, path.join(parent, p))
done()
})
})
@ -536,7 +536,7 @@ describe('asar package', function () {
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
const p = path.join('a.asar', 'not-exist')
fs.realpath.native(path.join(parent, p), err => {
assert.equal(err.code, 'ENOENT')
assert.strictEqual(err.code, 'ENOENT')
done()
})
})
@ -546,19 +546,19 @@ describe('asar package', function () {
it('reads dirs from root', function () {
var p = path.join(fixtures, 'asar', 'a.asar')
var dirs = fs.readdirSync(p)
assert.deepEqual(dirs, ['dir1', 'dir2', 'dir3', 'file1', 'file2', 'file3', 'link1', 'link2', 'ping.js'])
assert.deepStrictEqual(dirs, ['dir1', 'dir2', 'dir3', 'file1', 'file2', 'file3', 'link1', 'link2', 'ping.js'])
})
it('reads dirs from a normal dir', function () {
var p = path.join(fixtures, 'asar', 'a.asar', 'dir1')
var dirs = fs.readdirSync(p)
assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2'])
assert.deepStrictEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2'])
})
it('reads dirs from a linked dir', function () {
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2')
var dirs = fs.readdirSync(p)
assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2'])
assert.deepStrictEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2'])
})
it('throws ENOENT error when can not find file', function () {
@ -574,8 +574,8 @@ describe('asar package', function () {
it('reads dirs from root', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar')
fs.readdir(p, function (err, dirs) {
assert.equal(err, null)
assert.deepEqual(dirs, ['dir1', 'dir2', 'dir3', 'file1', 'file2', 'file3', 'link1', 'link2', 'ping.js'])
assert.strictEqual(err, null)
assert.deepStrictEqual(dirs, ['dir1', 'dir2', 'dir3', 'file1', 'file2', 'file3', 'link1', 'link2', 'ping.js'])
done()
})
})
@ -583,16 +583,16 @@ describe('asar package', function () {
it('reads dirs from a normal dir', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'dir1')
fs.readdir(p, function (err, dirs) {
assert.equal(err, null)
assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2'])
assert.strictEqual(err, null)
assert.deepStrictEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2'])
done()
})
})
it('reads dirs from a linked dir', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2')
fs.readdir(p, function (err, dirs) {
assert.equal(err, null)
assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2'])
assert.strictEqual(err, null)
assert.deepStrictEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2'])
done()
})
})
@ -600,7 +600,7 @@ describe('asar package', function () {
it('throws ENOENT error when can not find file', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
fs.readdir(p, function (err) {
assert.equal(err.code, 'ENOENT')
assert.strictEqual(err.code, 'ENOENT')
done()
})
})
@ -616,7 +616,7 @@ describe('asar package', function () {
fd = fs.openSync(p, 'r')
buffer = Buffer.alloc(6)
fs.readSync(fd, buffer, 0, 6, 0)
assert.equal(String(buffer).trim(), 'file1')
assert.strictEqual(String(buffer).trim(), 'file1')
fs.closeSync(fd)
}
})
@ -634,11 +634,11 @@ describe('asar package', function () {
it('opens a normal file', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
fs.open(p, 'r', function (err, fd) {
assert.equal(err, null)
assert.strictEqual(err, null)
var buffer = Buffer.alloc(6)
fs.read(fd, buffer, 0, 6, 0, function (err) {
assert.equal(err, null)
assert.equal(String(buffer).trim(), 'file1')
assert.strictEqual(err, null)
assert.strictEqual(String(buffer).trim(), 'file1')
fs.close(fd, done)
})
})
@ -647,7 +647,7 @@ describe('asar package', function () {
it('throws ENOENT error when can not find file', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
fs.open(p, 'r', function (err) {
assert.equal(err.code, 'ENOENT')
assert.strictEqual(err.code, 'ENOENT')
done()
})
})
@ -657,7 +657,7 @@ describe('asar package', function () {
it('throws error when calling inside asar archive', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
fs.mkdir(p, function (err) {
assert.equal(err.code, 'ENOTDIR')
assert.strictEqual(err.code, 'ENOTDIR')
done()
})
})
@ -677,7 +677,7 @@ describe('asar package', function () {
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
// eslint-disable-next-line
fs.exists(p, function (exists) {
assert.equal(exists, true)
assert.strictEqual(exists, true)
done()
})
})
@ -686,7 +686,7 @@ describe('asar package', function () {
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
// eslint-disable-next-line
fs.exists(p, function (exists) {
assert.equal(exists, false)
assert.strictEqual(exists, false)
done()
})
})
@ -695,7 +695,7 @@ describe('asar package', function () {
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
// eslint-disable-next-line
util.promisify(fs.exists)(p).then(exists => {
assert.equal(exists, true)
assert.strictEqual(exists, true)
done()
})
})
@ -704,7 +704,7 @@ describe('asar package', function () {
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
// eslint-disable-next-line
util.promisify(fs.exists)(p).then(exists => {
assert.equal(exists, false)
assert.strictEqual(exists, false)
done()
})
})
@ -714,14 +714,14 @@ describe('asar package', function () {
it('handles an existing file', function () {
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
assert.doesNotThrow(function () {
assert.equal(fs.existsSync(p), true)
assert.strictEqual(fs.existsSync(p), true)
})
})
it('handles a non-existent file', function () {
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
assert.doesNotThrow(function () {
assert.equal(fs.existsSync(p), false)
assert.strictEqual(fs.existsSync(p), false)
})
})
})
@ -738,7 +738,7 @@ describe('asar package', function () {
it('throws an error when called with write mode', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
fs.access(p, fs.constants.R_OK | fs.constants.W_OK, function (err) {
assert.equal(err.code, 'EACCES')
assert.strictEqual(err.code, 'EACCES')
done()
})
})
@ -746,7 +746,7 @@ describe('asar package', function () {
it('throws an error when called on non-existent file', function (done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
fs.access(p, function (err) {
assert.equal(err.code, 'ENOENT')
assert.strictEqual(err.code, 'ENOENT')
done()
})
})
@ -794,7 +794,7 @@ describe('asar package', function () {
it('opens a normal js file', function (done) {
var child = ChildProcess.fork(path.join(fixtures, 'asar', 'a.asar', 'ping.js'))
child.on('message', function (msg) {
assert.equal(msg, 'message')
assert.strictEqual(msg, 'message')
done()
})
child.send('message')
@ -804,7 +804,7 @@ describe('asar package', function () {
var file = path.join(fixtures, 'asar', 'a.asar', 'file1')
var child = ChildProcess.fork(path.join(fixtures, 'module', 'asar.js'))
child.on('message', function (content) {
assert.equal(content, fs.readFileSync(file).toString())
assert.strictEqual(content, fs.readFileSync(file).toString())
done()
})
child.send(file)
@ -816,15 +816,15 @@ describe('asar package', function () {
it('should not try to extract the command if there is a reference to a file inside an .asar', function (done) {
ChildProcess.exec('echo ' + echo + ' foo bar', function (error, stdout) {
assert.equal(error, null)
assert.equal(stdout.toString().replace(/\r/g, ''), echo + ' foo bar\n')
assert.strictEqual(error, null)
assert.strictEqual(stdout.toString().replace(/\r/g, ''), echo + ' foo bar\n')
done()
})
})
it('can be promisified', () => {
return util.promisify(ChildProcess.exec)('echo ' + echo + ' foo bar').then(({ stdout }) => {
assert.equal(stdout.toString().replace(/\r/g, ''), echo + ' foo bar\n')
assert.strictEqual(stdout.toString().replace(/\r/g, ''), echo + ' foo bar\n')
})
})
})
@ -834,7 +834,7 @@ describe('asar package', function () {
it('should not try to extract the command if there is a reference to a file inside an .asar', function (done) {
var stdout = ChildProcess.execSync('echo ' + echo + ' foo bar')
assert.equal(stdout.toString().replace(/\r/g, ''), echo + ' foo bar\n')
assert.strictEqual(stdout.toString().replace(/\r/g, ''), echo + ' foo bar\n')
done()
})
})
@ -853,20 +853,20 @@ describe('asar package', function () {
it('executes binaries', function (done) {
execFile(echo, ['test'], function (error, stdout) {
assert.equal(error, null)
assert.equal(stdout, 'test\n')
assert.strictEqual(error, null)
assert.strictEqual(stdout, 'test\n')
done()
})
})
xit('execFileSync executes binaries', function () {
var output = execFileSync(echo, ['test'])
assert.equal(String(output), 'test\n')
assert.strictEqual(String(output), 'test\n')
})
it('can be promisified', () => {
return util.promisify(ChildProcess.execFile)(echo, ['test']).then(({ stdout }) => {
assert.equal(stdout, 'test\n')
assert.strictEqual(stdout, 'test\n')
})
})
})
@ -876,16 +876,16 @@ describe('asar package', function () {
it('read a normal file', function () {
var file1 = path.join(fixtures, 'asar', 'a.asar', 'file1')
assert.equal(internalModuleReadJSON(file1).toString().trim(), 'file1')
assert.strictEqual(internalModuleReadJSON(file1).toString().trim(), 'file1')
var file2 = path.join(fixtures, 'asar', 'a.asar', 'file2')
assert.equal(internalModuleReadJSON(file2).toString().trim(), 'file2')
assert.strictEqual(internalModuleReadJSON(file2).toString().trim(), 'file2')
var file3 = path.join(fixtures, 'asar', 'a.asar', 'file3')
assert.equal(internalModuleReadJSON(file3).toString().trim(), 'file3')
assert.strictEqual(internalModuleReadJSON(file3).toString().trim(), 'file3')
})
it('reads a normal file with unpacked files', function () {
var p = path.join(fixtures, 'asar', 'unpack.asar', 'a.txt')
assert.equal(internalModuleReadJSON(p).toString().trim(), 'a')
assert.strictEqual(internalModuleReadJSON(p).toString().trim(), 'a')
})
})
@ -941,13 +941,13 @@ describe('asar package', function () {
var file = path.join(fixtures, 'asar', 'a.asar', 'file1')
var dir = path.join(fixtures, 'asar', 'a.asar', 'dir1')
fs.readFile(file, function (error) {
assert.equal(error.code, errorName)
assert.strictEqual(error.code, errorName)
fs.lstat(file, function (error) {
assert.equal(error.code, errorName)
assert.strictEqual(error.code, errorName)
fs.realpath(file, function (error) {
assert.equal(error.code, errorName)
assert.strictEqual(error.code, errorName)
fs.readdir(dir, function (error) {
assert.equal(error.code, errorName)
assert.strictEqual(error.code, errorName)
done()
})
})
@ -960,7 +960,7 @@ describe('asar package', function () {
var asar = path.join(fixtures, 'asar', 'a.asar')
var content1 = fs.readFileSync(asar)
var content2 = originalFs.readFileSync(asar)
assert.equal(content1.compare(content2), 0)
assert.strictEqual(content1.compare(content2), 0)
assert.throws(function () {
fs.readdirSync(asar)
}, /ENOTDIR/)
@ -971,7 +971,7 @@ describe('asar package', function () {
assert.throws(function () {
ChildProcess.execSync(path.join(__dirname, 'does-not-exist.txt'))
})
assert.equal(process.noAsar, false)
assert.strictEqual(process.noAsar, false)
})
})
@ -983,8 +983,8 @@ describe('asar package', function () {
}
})
forked.on('message', function (stats) {
assert.equal(stats.isFile, true)
assert.equal(stats.size, 778)
assert.strictEqual(stats.isFile, true)
assert.strictEqual(stats.size, 778)
done()
})
})
@ -1003,8 +1003,8 @@ describe('asar package', function () {
})
spawned.stdout.on('close', function () {
const stats = JSON.parse(output)
assert.equal(stats.isFile, true)
assert.equal(stats.size, 778)
assert.strictEqual(stats.isFile, true)
assert.strictEqual(stats.size, 778)
done()
})
})
@ -1021,7 +1021,7 @@ describe('asar package', function () {
it('can request a file in package', function (done) {
var p = path.resolve(fixtures, 'asar', 'a.asar', 'file1')
$.get('file://' + p, function (data) {
assert.equal(data.trim(), 'file1')
assert.strictEqual(data.trim(), 'file1')
done()
})
})
@ -1029,7 +1029,7 @@ describe('asar package', function () {
it('can request a file in package with unpacked files', function (done) {
var p = path.resolve(fixtures, 'asar', 'unpack.asar', 'a.txt')
$.get('file://' + p, function (data) {
assert.equal(data.trim(), 'a')
assert.strictEqual(data.trim(), 'a')
done()
})
})
@ -1037,7 +1037,7 @@ describe('asar package', function () {
it('can request a linked file in package', function (done) {
var p = path.resolve(fixtures, 'asar', 'a.asar', 'link2', 'link1')
$.get('file://' + p, function (data) {
assert.equal(data.trim(), 'file1')
assert.strictEqual(data.trim(), 'file1')
done()
})
})
@ -1045,7 +1045,7 @@ describe('asar package', function () {
it('can request a file in filesystem', function (done) {
var p = path.resolve(fixtures, 'asar', 'file')
$.get('file://' + p, function (data) {
assert.equal(data.trim(), 'file')
assert.strictEqual(data.trim(), 'file')
done()
})
})
@ -1055,7 +1055,7 @@ describe('asar package', function () {
$.ajax({
url: 'file://' + p,
error: function (err) {
assert.equal(err.status, 404)
assert.strictEqual(err.status, 404)
done()
}
})
@ -1073,7 +1073,7 @@ describe('asar package', function () {
})
var p = path.resolve(fixtures, 'asar', 'web.asar', 'index.html')
ipcMain.once('dirname', function (event, dirname) {
assert.equal(dirname, path.dirname(p))
assert.strictEqual(dirname, path.dirname(p))
done()
})
w.loadFile(p)
@ -1092,7 +1092,7 @@ describe('asar package', function () {
var p = path.resolve(fixtures, 'asar', 'script.asar', 'index.html')
w.loadFile(p)
ipcMain.once('ping', function (event, message) {
assert.equal(message, 'pong')
assert.strictEqual(message, 'pong')
done()
})
})
@ -1134,7 +1134,7 @@ describe('asar package', function () {
it('is available in forked scripts', function (done) {
var child = ChildProcess.fork(path.join(fixtures, 'module', 'original-fs.js'))
child.on('message', function (msg) {
assert.equal(msg, 'object')
assert.strictEqual(msg, 'object')
done()
})
child.send('message')
@ -1146,10 +1146,10 @@ describe('asar package', function () {
it('recognize asar archvies', function () {
var p = path.join(fixtures, 'asar', 'a.asar', 'link1')
assert.equal(gfs.readFileSync(p).toString().trim(), 'file1')
assert.strictEqual(gfs.readFileSync(p).toString().trim(), 'file1')
})
it('does not touch global fs object', function () {
assert.notEqual(fs.readdir, gfs.readdir)
assert.notStrictEqual(fs.readdir, gfs.readdir)
})
})
@ -1168,7 +1168,7 @@ describe('asar package', function () {
it('reads image from asar archive', function () {
var p = path.join(fixtures, 'asar', 'logo.asar', 'logo.png')
var logo = nativeImage.createFromPath(p)
assert.deepEqual(logo.getSize(), {
assert.deepStrictEqual(logo.getSize(), {
width: 55,
height: 55
})
@ -1177,7 +1177,7 @@ describe('asar package', function () {
it('reads image from asar archive with unpacked files', function () {
var p = path.join(fixtures, 'asar', 'unpack.asar', 'atom.png')
var logo = nativeImage.createFromPath(p)
assert.deepEqual(logo.getSize(), {
assert.deepStrictEqual(logo.getSize(), {
width: 1024,
height: 1024
})

18
spec/assert-helpers.js Normal file
View file

@ -0,0 +1,18 @@
function resolveSingleObjectGetters (object) {
if (object && typeof object === 'object') {
const newObject = {}
for (const key in object) {
newObject[key] = resolveGetters(object[key])[0]
}
return newObject
}
return object
}
function resolveGetters (...args) {
return args.map(resolveSingleObjectGetters)
}
module.exports = {
resolveGetters
}

View file

@ -7,6 +7,7 @@ const url = require('url')
const ChildProcess = require('child_process')
const { ipcRenderer, remote } = require('electron')
const { closeWindow } = require('./window-helpers')
const { resolveGetters } = require('./assert-helpers')
const { app, BrowserWindow, ipcMain, protocol, session, webContents } = remote
const isCI = remote.getGlobal('isCi')
const features = process.atomBinding('features')
@ -38,7 +39,7 @@ describe('chromium feature', () => {
appProcess.stdout.on('data', (data) => { output += data })
appProcess.stdout.on('end', () => {
output = output.replace(/(\r\n|\n|\r)/gm, '')
assert.equal(output, result)
assert.strictEqual(output, result)
done()
})
}
@ -151,7 +152,7 @@ describe('chromium feature', () => {
w.webContents.on('ipc-message', (event, args) => {
if (args[0] === 'deviceIds') deviceIds.push(args[1])
if (deviceIds.length === 2) {
assert.notDeepEqual(deviceIds[0], deviceIds[1])
assert.notDeepStrictEqual(deviceIds[0], deviceIds[1])
closeWindow(w).then(() => {
w = null
done()
@ -168,15 +169,15 @@ describe('chromium feature', () => {
describe('navigator.language', () => {
it('should not be empty', () => {
assert.notEqual(navigator.language, '')
assert.notStrictEqual(navigator.language, '')
})
})
describe('navigator.languages', (done) => {
it('should return the system locale only', () => {
let appLocale = app.getLocale()
assert.equal(navigator.languages.length, 1)
assert.equal(navigator.languages[0], appLocale)
assert.strictEqual(navigator.languages.length, 1)
assert.strictEqual(navigator.languages[0], appLocale)
})
})
@ -194,7 +195,7 @@ describe('chromium feature', () => {
} else if (args[0] === 'error') {
done(args[1])
} else if (args[0] === 'response') {
assert.equal(args[1], 'Hello from serviceWorker!')
assert.strictEqual(args[1], 'Hello from serviceWorker!')
session.fromPartition('sw-file-scheme-spec').clearStorageData({
storages: ['serviceworkers']
}, () => done())
@ -230,7 +231,7 @@ describe('chromium feature', () => {
} else if (args[0] === 'error') {
done(`unexpected error : ${args[1]}`)
} else if (args[0] === 'response') {
assert.equal(args[1], 'Hello from serviceWorker!')
assert.strictEqual(args[1], 'Hello from serviceWorker!')
customSession.clearStorageData({
storages: ['serviceworkers']
}, () => {
@ -287,15 +288,15 @@ describe('chromium feature', () => {
describe('window.open', () => {
it('returns a BrowserWindowProxy object', () => {
const b = window.open('about:blank', '', 'show=no')
assert.equal(b.closed, false)
assert.equal(b.constructor.name, 'BrowserWindowProxy')
assert.strictEqual(b.closed, false)
assert.strictEqual(b.constructor.name, 'BrowserWindowProxy')
b.close()
})
it('accepts "nodeIntegration" as feature', (done) => {
let b
listener = (event) => {
assert.equal(event.data.isProcessGlobalUndefined, true)
assert.strictEqual(event.data.isProcessGlobalUndefined, true)
b.close()
done()
}
@ -309,7 +310,7 @@ describe('chromium feature', () => {
const ref1 = remote.getCurrentWindow().getSize()
const width = ref1[0]
const height = ref1[1]
assert.equal(event.data, `size: ${width} ${height}`)
assert.strictEqual(event.data, `size: ${width} ${height}`)
b.close()
done()
}
@ -329,7 +330,7 @@ describe('chromium feature', () => {
}
w.webContents.once('new-window', (e, url, frameName, disposition, options) => {
assert.equal(options.show, w.isVisible())
assert.strictEqual(options.show, w.isVisible())
w.close()
done()
})
@ -340,7 +341,7 @@ describe('chromium feature', () => {
it('disables node integration when it is disabled on the parent window', (done) => {
let b
listener = (event) => {
assert.equal(event.data.isProcessGlobalUndefined, true)
assert.strictEqual(event.data.isProcessGlobalUndefined, true)
b.close()
done()
}
@ -360,7 +361,7 @@ describe('chromium feature', () => {
it('disables webviewTag when node integration is disabled on the parent window', (done) => {
let b
listener = (event) => {
assert.equal(event.data.isWebViewUndefined, true)
assert.strictEqual(event.data.isWebViewUndefined, true)
b.close()
done()
}
@ -383,7 +384,7 @@ describe('chromium feature', () => {
app.once('web-contents-created', (event, contents) => {
contents.once('did-finish-load', () => {
contents.executeJavaScript('typeof process').then((typeofProcessGlobal) => {
assert.equal(typeofProcessGlobal, 'undefined')
assert.strictEqual(typeofProcessGlobal, 'undefined')
b.close()
done()
}).catch(done)
@ -398,7 +399,7 @@ describe('chromium feature', () => {
contents.once('did-finish-load', () => {
app.once('browser-window-created', (event, window) => {
const preferences = window.webContents.getLastWebPreferences()
assert.equal(preferences.javascript, false)
assert.strictEqual(preferences.javascript, false)
window.destroy()
b.close()
done()
@ -420,7 +421,7 @@ describe('chromium feature', () => {
it('disables the <webview> tag when it is disabled on the parent window', (done) => {
let b
listener = (event) => {
assert.equal(event.data.isWebViewGlobalUndefined, true)
assert.strictEqual(event.data.isWebViewGlobalUndefined, true)
b.close()
done()
}
@ -444,7 +445,7 @@ describe('chromium feature', () => {
height: 450
}
listener = (event) => {
assert.equal(event.data, `size: ${size.width} ${size.height}`)
assert.strictEqual(event.data, `size: ${size.width} ${size.height}`)
b.close()
done()
}
@ -456,9 +457,9 @@ describe('chromium feature', () => {
w = BrowserWindow.fromId(ipcRenderer.sendSync('create-window-with-options-cycle'))
w.loadFile(path.join(fixtures, 'pages', 'window-open.html'))
w.webContents.once('new-window', (event, url, frameName, disposition, options) => {
assert.equal(options.show, false)
assert.deepEqual(options.foo, {
bar: null,
assert.strictEqual(options.show, false)
assert.deepStrictEqual(...resolveGetters(options.foo, {
bar: undefined,
baz: {
hello: {
world: true
@ -469,7 +470,7 @@ describe('chromium feature', () => {
world: true
}
}
})
}))
done()
})
})
@ -484,7 +485,7 @@ describe('chromium feature', () => {
}
app.once('browser-window-created', (event, window) => {
window.webContents.once('did-finish-load', () => {
assert.equal(b.location, targetURL)
assert.strictEqual(b.location, targetURL)
b.close()
done()
})
@ -514,14 +515,14 @@ describe('chromium feature', () => {
webContents.once('did-finish-load', () => {
const { location } = b
b.close()
assert.equal(location, 'about:blank')
assert.strictEqual(location, 'about:blank')
let c
app.once('browser-window-created', (event, { webContents }) => {
webContents.once('did-finish-load', () => {
const { location } = c
c.close()
assert.equal(location, 'about:blank')
assert.strictEqual(location, 'about:blank')
done()
})
})
@ -544,7 +545,7 @@ describe('chromium feature', () => {
it('sets the window title to the specified frameName', (done) => {
let b
app.once('browser-window-created', (event, createdWindow) => {
assert.equal(createdWindow.getTitle(), 'hello')
assert.strictEqual(createdWindow.getTitle(), 'hello')
b.close()
done()
})
@ -554,7 +555,7 @@ describe('chromium feature', () => {
it('does not throw an exception when the frameName is a built-in object property', (done) => {
let b
app.once('browser-window-created', (event, createdWindow) => {
assert.equal(createdWindow.getTitle(), '__proto__')
assert.strictEqual(createdWindow.getTitle(), '__proto__')
b.close()
done()
})
@ -575,7 +576,7 @@ describe('chromium feature', () => {
it('is null for main window', (done) => {
w = new BrowserWindow({ show: false })
w.webContents.once('ipc-message', (event, args) => {
assert.deepEqual(args, ['opener', null])
assert.deepStrictEqual(args, ['opener', null])
done()
})
w.loadFile(path.join(fixtures, 'pages', 'window-opener.html'))
@ -584,7 +585,7 @@ describe('chromium feature', () => {
it('is not null for window opened by window.open', (done) => {
let b
listener = (event) => {
assert.equal(event.data, 'object')
assert.strictEqual(event.data, 'object')
b.close()
done()
}
@ -614,7 +615,7 @@ describe('chromium feature', () => {
it('does nothing when origin of current window does not match opener', (done) => {
listener = (event) => {
assert.equal(event.data, undefined)
assert.strictEqual(event.data, null)
done()
}
window.addEventListener('message', listener)
@ -623,7 +624,7 @@ describe('chromium feature', () => {
it('works when origin matches', (done) => {
listener = (event) => {
assert.equal(event.data, location.href)
assert.strictEqual(event.data, location.href)
done()
}
window.addEventListener('message', listener)
@ -632,7 +633,7 @@ describe('chromium feature', () => {
it('works when origin does not match opener but has node integration', (done) => {
listener = (event) => {
assert.equal(event.data, location.href)
assert.strictEqual(event.data, location.href)
done()
}
window.addEventListener('message', listener)
@ -663,7 +664,7 @@ describe('chromium feature', () => {
it('does nothing when origin of webview src URL does not match opener', (done) => {
webview = new WebView()
webview.addEventListener('console-message', (e) => {
assert.equal(e.message, 'null')
assert.strictEqual(e.message, 'null')
done()
})
webview.setAttribute('allowpopups', 'on')
@ -681,7 +682,7 @@ describe('chromium feature', () => {
it('works when origin matches', (done) => {
webview = new WebView()
webview.addEventListener('console-message', (e) => {
assert.equal(e.message, webview.src)
assert.strictEqual(e.message, webview.src)
done()
})
webview.setAttribute('allowpopups', 'on')
@ -700,7 +701,7 @@ describe('chromium feature', () => {
webview = new WebView()
webview.addEventListener('console-message', (e) => {
webview.remove()
assert.equal(e.message, webview.src)
assert.strictEqual(e.message, webview.src)
done()
})
webview.setAttribute('allowpopups', 'on')
@ -724,10 +725,10 @@ describe('chromium feature', () => {
window.removeEventListener('message', listener)
b.close()
const message = JSON.parse(event.data)
assert.equal(message.data, 'testing')
assert.equal(message.origin, 'file://')
assert.equal(message.sourceEqualsOpener, true)
assert.equal(event.origin, 'file://')
assert.strictEqual(message.data, 'testing')
assert.strictEqual(message.origin, 'file://')
assert.strictEqual(message.sourceEqualsOpener, true)
assert.strictEqual(event.origin, 'file://')
done()
}
window.addEventListener('message', listener)
@ -754,8 +755,8 @@ describe('chromium feature', () => {
listener = (event) => {
window.removeEventListener('message', listener)
b.close()
assert.equal(event.source, b)
assert.equal(event.origin, 'file://')
assert.strictEqual(event.source, b)
assert.strictEqual(event.origin, 'file://')
done()
}
window.addEventListener('message', listener)
@ -766,7 +767,7 @@ describe('chromium feature', () => {
const webview = new WebView()
webview.addEventListener('console-message', (e) => {
webview.remove()
assert.equal(e.message, 'message')
assert.strictEqual(e.message, 'message')
done()
})
webview.allowpopups = true
@ -806,7 +807,7 @@ describe('chromium feature', () => {
listener = (event) => {
window.removeEventListener('message', listener)
b.close()
assert.equal(event.data, 'deliver')
assert.strictEqual(event.data, 'deliver')
done()
}
window.addEventListener('message', listener)
@ -838,7 +839,7 @@ describe('chromium feature', () => {
}
const webgl = document.createElement('canvas').getContext('webgl')
assert.notEqual(webgl, null)
assert.notStrictEqual(webgl, null)
})
})
@ -847,7 +848,7 @@ describe('chromium feature', () => {
const worker = new Worker('../fixtures/workers/worker.js')
const message = 'ping'
worker.onmessage = (event) => {
assert.equal(event.data, message)
assert.strictEqual(event.data, message)
worker.terminate()
done()
}
@ -857,7 +858,7 @@ describe('chromium feature', () => {
it('Worker has no node integration by default', (done) => {
let worker = new Worker('../fixtures/workers/worker_node.js')
worker.onmessage = (event) => {
assert.equal(event.data, 'undefined undefined undefined undefined')
assert.strictEqual(event.data, 'undefined undefined undefined undefined')
worker.terminate()
done()
}
@ -866,7 +867,7 @@ describe('chromium feature', () => {
it('Worker has node integration with nodeIntegrationInWorker', (done) => {
let webview = new WebView()
webview.addEventListener('ipc-message', (e) => {
assert.equal(e.channel, 'object function object function')
assert.strictEqual(e.channel, 'object function object function')
webview.remove()
done()
})
@ -879,7 +880,7 @@ describe('chromium feature', () => {
const worker = new SharedWorker('../fixtures/workers/shared_worker.js')
const message = 'ping'
worker.port.onmessage = (event) => {
assert.equal(event.data, message)
assert.strictEqual(event.data, message)
done()
}
worker.port.postMessage(message)
@ -888,7 +889,7 @@ describe('chromium feature', () => {
it('SharedWorker has no node integration by default', (done) => {
let worker = new SharedWorker('../fixtures/workers/shared_worker_node.js')
worker.port.onmessage = (event) => {
assert.equal(event.data, 'undefined undefined undefined undefined')
assert.strictEqual(event.data, 'undefined undefined undefined undefined')
done()
}
})
@ -899,7 +900,7 @@ describe('chromium feature', () => {
console.log(e)
})
webview.addEventListener('ipc-message', (e) => {
assert.equal(e.channel, 'object function object function')
assert.strictEqual(e.channel, 'object function object function')
webview.remove()
done()
})
@ -924,7 +925,7 @@ describe('chromium feature', () => {
iframe.src = `file://${fixtures}/pages/set-global.html`
document.body.appendChild(iframe)
iframe.onload = () => {
assert.equal(iframe.contentWindow.test, 'undefined undefined undefined')
assert.strictEqual(iframe.contentWindow.test, 'undefined undefined undefined')
done()
}
})
@ -933,7 +934,7 @@ describe('chromium feature', () => {
describe('storage', () => {
it('requesting persitent quota works', (done) => {
navigator.webkitPersistentStorage.requestQuota(1024 * 1024, (grantedBytes) => {
assert.equal(grantedBytes, 1048576)
assert.strictEqual(grantedBytes, 1048576)
done()
})
})
@ -973,7 +974,7 @@ describe('chromium feature', () => {
it('cannot access localStorage', (done) => {
ipcMain.once('local-storage-response', (event, error) => {
assert.equal(
assert.strictEqual(
error,
'Failed to read the \'localStorage\' property from \'Window\': Access is denied for this document.')
done()
@ -983,7 +984,7 @@ describe('chromium feature', () => {
it('cannot access sessionStorage', (done) => {
ipcMain.once('session-storage-response', (event, error) => {
assert.equal(
assert.strictEqual(
error,
'Failed to read the \'sessionStorage\' property from \'Window\': Access is denied for this document.')
done()
@ -993,7 +994,7 @@ describe('chromium feature', () => {
it('cannot access WebSQL database', (done) => {
ipcMain.once('web-sql-response', (event, error) => {
assert.equal(
assert.strictEqual(
error,
'An attempt was made to break through the security policy of the user agent.')
done()
@ -1003,7 +1004,7 @@ describe('chromium feature', () => {
it('cannot access indexedDB', (done) => {
ipcMain.once('indexed-db-response', (event, error) => {
assert.equal(error, 'The user denied permission to access the database.')
assert.strictEqual(error, 'The user denied permission to access the database.')
done()
})
contents.loadURL(`${protocolName}://host/indexedDB`)
@ -1148,15 +1149,15 @@ describe('chromium feature', () => {
this.createBrowserWindow({ plugins: true, preload: preloadFile })
ipcMain.once('pdf-loaded', (event, state) => {
assert.equal(state, 'success')
assert.strictEqual(state, 'success')
done()
})
w.webContents.on('page-title-updated', () => {
const parsedURL = url.parse(w.webContents.getURL(), true)
assert.equal(parsedURL.protocol, 'chrome:')
assert.equal(parsedURL.hostname, 'pdf-viewer')
assert.equal(parsedURL.query.src, pagePath)
assert.equal(w.webContents.getTitle(), 'cat.pdf')
assert.strictEqual(parsedURL.protocol, 'chrome:')
assert.strictEqual(parsedURL.hostname, 'pdf-viewer')
assert.strictEqual(parsedURL.query.src, pagePath)
assert.strictEqual(w.webContents.getTitle(), 'cat.pdf')
})
w.loadFile(path.join(fixtures, 'pages', page))
}
@ -1165,15 +1166,15 @@ describe('chromium feature', () => {
it('opens when loading a pdf resource as top level navigation', (done) => {
this.createBrowserWindow({ plugins: true, preload: 'preload-pdf-loaded.js' })
ipcMain.once('pdf-loaded', (event, state) => {
assert.equal(state, 'success')
assert.strictEqual(state, 'success')
done()
})
w.webContents.on('page-title-updated', () => {
const parsedURL = url.parse(w.webContents.getURL(), true)
assert.equal(parsedURL.protocol, 'chrome:')
assert.equal(parsedURL.hostname, 'pdf-viewer')
assert.equal(parsedURL.query.src, this.pdfSource)
assert.equal(w.webContents.getTitle(), 'cat.pdf')
assert.strictEqual(parsedURL.protocol, 'chrome:')
assert.strictEqual(parsedURL.hostname, 'pdf-viewer')
assert.strictEqual(parsedURL.query.src, this.pdfSource)
assert.strictEqual(w.webContents.getTitle(), 'cat.pdf')
})
w.webContents.loadURL(this.pdfSource)
})
@ -1181,17 +1182,17 @@ describe('chromium feature', () => {
it('opens a pdf link given params, the query string should be escaped', (done) => {
this.createBrowserWindow({ plugins: true, preload: 'preload-pdf-loaded.js' })
ipcMain.once('pdf-loaded', (event, state) => {
assert.equal(state, 'success')
assert.strictEqual(state, 'success')
done()
})
w.webContents.on('page-title-updated', () => {
const parsedURL = url.parse(w.webContents.getURL(), true)
assert.equal(parsedURL.protocol, 'chrome:')
assert.equal(parsedURL.hostname, 'pdf-viewer')
assert.equal(parsedURL.query.src, this.pdfSourceWithParams)
assert.equal(parsedURL.query.b, undefined)
assert.strictEqual(parsedURL.protocol, 'chrome:')
assert.strictEqual(parsedURL.hostname, 'pdf-viewer')
assert.strictEqual(parsedURL.query.src, this.pdfSourceWithParams)
assert.strictEqual(parsedURL.query.b, undefined)
assert(parsedURL.search.endsWith('%3Fa%3D1%26b%3D2'))
assert.equal(w.webContents.getTitle(), 'cat.pdf')
assert.strictEqual(w.webContents.getTitle(), 'cat.pdf')
})
w.webContents.loadURL(this.pdfSourceWithParams)
})
@ -1200,9 +1201,9 @@ describe('chromium feature', () => {
this.createBrowserWindow({ plugins: false, preload: 'preload-pdf-loaded.js' })
ipcRenderer.sendSync('set-download-option', false, false)
ipcRenderer.once('download-done', (event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename) => {
assert.equal(state, 'completed')
assert.equal(filename, 'cat.pdf')
assert.equal(mimeType, 'application/pdf')
assert.strictEqual(state, 'completed')
assert.strictEqual(filename, 'cat.pdf')
assert.strictEqual(mimeType, 'application/pdf')
fs.unlinkSync(path.join(fixtures, 'mock.pdf'))
done()
})
@ -1211,8 +1212,8 @@ describe('chromium feature', () => {
it('should not open when pdf is requested as sub resource', (done) => {
fetch(this.pdfSource).then((res) => {
assert.equal(res.status, 200)
assert.notEqual(document.title, 'cat.pdf')
assert.strictEqual(res.status, 200)
assert.notStrictEqual(document.title, 'cat.pdf')
done()
}).catch((e) => done(e))
})
@ -1256,11 +1257,11 @@ describe('chromium feature', () => {
w = new BrowserWindow({ show: false })
w.webContents.once('did-finish-load', () => {
// History should have current page by now.
assert.equal(w.webContents.length(), 1)
assert.strictEqual(w.webContents.length(), 1)
w.webContents.executeJavaScript('window.history.pushState({}, "")', () => {
// Initial page + pushed state
assert.equal(w.webContents.length(), 2)
assert.strictEqual(w.webContents.length(), 2)
done()
})
})

View file

@ -6,6 +6,6 @@ delete window.Buffer
delete global.Buffer
// Test that remote.js doesn't use Buffer global
remote.require(path.join(__dirname, 'print_name.js')).echo(new Buffer('bar'))
remote.require(path.join(__dirname, 'print_name.js')).echo(Buffer.from('bar'))
window.test = new Buffer('buffer')
window.test = Buffer.from('buffer')

View file

@ -20,7 +20,7 @@ describe('modules support', () => {
const runas = path.join(fixtures, 'module', 'runas.js')
const child = require('child_process').fork(runas)
child.on('message', (msg) => {
assert.equal(msg, 'ok')
assert.strictEqual(msg, 'ok')
done()
})
})
@ -42,7 +42,7 @@ describe('modules support', () => {
const libm = ffi.Library('libm', {
ceil: ['double', ['double']]
})
assert.equal(libm.ceil(1.5), 2)
assert.strictEqual(libm.ceil(1.5), 2)
})
})
@ -51,7 +51,7 @@ describe('modules support', () => {
describe('Q.when', () => {
it('emits the fullfil callback', (done) => {
Q(true).then((val) => {
assert.equal(val, true)
assert.strictEqual(val, true)
done()
})
})
@ -92,7 +92,7 @@ describe('modules support', () => {
describe('when the path is inside the resources path', () => {
it('does not include paths outside of the resources path', () => {
let modulePath = process.resourcesPath
assert.deepEqual(Module._nodeModulePaths(modulePath), [
assert.deepStrictEqual(Module._nodeModulePaths(modulePath), [
path.join(process.resourcesPath, 'node_modules')
])
@ -102,26 +102,26 @@ describe('modules support', () => {
assert(nodeModulePaths.includes(path.join(modulePath, '..', 'node_modules')))
modulePath = path.join(process.resourcesPath, 'foo')
assert.deepEqual(Module._nodeModulePaths(modulePath), [
assert.deepStrictEqual(Module._nodeModulePaths(modulePath), [
path.join(process.resourcesPath, 'foo', 'node_modules'),
path.join(process.resourcesPath, 'node_modules')
])
modulePath = path.join(process.resourcesPath, 'node_modules', 'foo')
assert.deepEqual(Module._nodeModulePaths(modulePath), [
assert.deepStrictEqual(Module._nodeModulePaths(modulePath), [
path.join(process.resourcesPath, 'node_modules', 'foo', 'node_modules'),
path.join(process.resourcesPath, 'node_modules')
])
modulePath = path.join(process.resourcesPath, 'node_modules', 'foo', 'bar')
assert.deepEqual(Module._nodeModulePaths(modulePath), [
assert.deepStrictEqual(Module._nodeModulePaths(modulePath), [
path.join(process.resourcesPath, 'node_modules', 'foo', 'bar', 'node_modules'),
path.join(process.resourcesPath, 'node_modules', 'foo', 'node_modules'),
path.join(process.resourcesPath, 'node_modules')
])
modulePath = path.join(process.resourcesPath, 'node_modules', 'foo', 'node_modules', 'bar')
assert.deepEqual(Module._nodeModulePaths(modulePath), [
assert.deepStrictEqual(Module._nodeModulePaths(modulePath), [
path.join(process.resourcesPath, 'node_modules', 'foo', 'node_modules', 'bar', 'node_modules'),
path.join(process.resourcesPath, 'node_modules', 'foo', 'node_modules'),
path.join(process.resourcesPath, 'node_modules')
@ -132,7 +132,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')
assert.deepEqual(Module._nodeModulePaths(modulePath), [
assert.deepStrictEqual(Module._nodeModulePaths(modulePath), [
path.join(modulePath, 'node_modules'),
path.resolve('/node_modules')
])
@ -156,7 +156,7 @@ describe('modules support', () => {
it('searches for module under app directory', async () => {
w.loadURL('about:blank')
const result = await w.webContents.executeJavaScript('typeof require("q").when')
assert.equal(result, 'function')
assert.strictEqual(result, 'function')
})
})
})

View file

@ -15,7 +15,7 @@ describe('node feature', () => {
it('works in current process', (done) => {
const child = ChildProcess.fork(path.join(fixtures, 'module', 'ping.js'))
child.on('message', (msg) => {
assert.equal(msg, 'message')
assert.strictEqual(msg, 'message')
done()
})
child.send('message')
@ -25,7 +25,7 @@ describe('node feature', () => {
const args = ['--expose_gc', '-test', '1']
const child = ChildProcess.fork(path.join(fixtures, 'module', 'process_args.js'), args)
child.on('message', (msg) => {
assert.deepEqual(args, msg.slice(2))
assert.deepStrictEqual(args, msg.slice(2))
done()
})
child.send('message')
@ -34,7 +34,7 @@ describe('node feature', () => {
it('works in forked process', (done) => {
const child = ChildProcess.fork(path.join(fixtures, 'module', 'fork_ping.js'))
child.on('message', (msg) => {
assert.equal(msg, 'message')
assert.strictEqual(msg, 'message')
done()
})
child.send('message')
@ -45,7 +45,7 @@ describe('node feature', () => {
path: process.env['PATH']
})
child.on('message', (msg) => {
assert.equal(msg, 'message')
assert.strictEqual(msg, 'message')
done()
})
child.send('message')
@ -55,7 +55,7 @@ describe('node feature', () => {
const fork = remote.require('child_process').fork
const child = fork(path.join(fixtures, 'module', 'ping.js'))
child.on('message', (msg) => {
assert.equal(msg, 'message')
assert.strictEqual(msg, 'message')
done()
})
child.send('message')
@ -64,7 +64,7 @@ describe('node feature', () => {
it('has String::localeCompare working in script', (done) => {
const child = ChildProcess.fork(path.join(fixtures, 'module', 'locale-compare.js'))
child.on('message', (msg) => {
assert.deepEqual(msg, [0, -1, 1])
assert.deepStrictEqual(msg, [0, -1, 1])
done()
})
child.send('message')
@ -73,7 +73,7 @@ describe('node feature', () => {
it('has setImmediate working in script', (done) => {
const child = ChildProcess.fork(path.join(fixtures, 'module', 'set-immediate.js'))
child.on('message', (msg) => {
assert.equal(msg, 'ok')
assert.strictEqual(msg, 'ok')
done()
})
child.send('message')
@ -86,8 +86,8 @@ describe('node feature', () => {
data += String(chunk)
})
child.on('close', (code) => {
assert.equal(code, 0)
assert.equal(data, 'pipes stdio')
assert.strictEqual(code, 0)
assert.strictEqual(data, 'pipes stdio')
done()
})
})
@ -96,7 +96,7 @@ describe('node feature', () => {
const source = "process.on('message', (message) => { process.send(message) })"
const forked = ChildProcess.fork('--eval', [source])
forked.once('message', (message) => {
assert.equal(message, 'hello')
assert.strictEqual(message, 'hello')
done()
})
forked.send('hello')
@ -122,7 +122,7 @@ describe('node feature', () => {
output += data
})
child.stdout.on('close', () => {
assert.deepEqual(JSON.parse(output), {
assert.deepStrictEqual(JSON.parse(output), {
processLog: process.platform === 'win32' ? 'function' : 'undefined',
processType: 'undefined',
window: 'undefined'
@ -164,14 +164,14 @@ describe('node feature', () => {
describe('error thrown in main process node context', () => {
it('gets emitted as a process uncaughtException event', () => {
const error = ipcRenderer.sendSync('handle-uncaught-exception', 'hello')
assert.equal(error, 'hello')
assert.strictEqual(error, 'hello')
})
})
describe('promise rejection in main process node context', () => {
it('gets emitted as a process unhandledRejection event', () => {
const error = ipcRenderer.sendSync('handle-unhandled-rejection', 'hello')
assert.equal(error, 'hello')
assert.strictEqual(error, 'hello')
})
})
@ -240,9 +240,9 @@ describe('node feature', () => {
child.on('message', ({ cmd, debuggerEnabled, secondSessionOpened, success }) => {
if (cmd === 'assert') {
assert.equal(debuggerEnabled, true)
assert.equal(secondSessionOpened, true)
assert.equal(success, true)
assert.strictEqual(debuggerEnabled, true)
assert.strictEqual(secondSessionOpened, true)
assert.strictEqual(success, true)
done()
}
})
@ -291,10 +291,10 @@ describe('node feature', () => {
const script = path.join(fixtures, 'module', 'create_socket.js')
const child = ChildProcess.fork(script, [socketPath])
child.on('exit', (code) => {
assert.equal(code, 0)
assert.strictEqual(code, 0)
const client = require('net').connect(socketPath)
client.on('error', (error) => {
assert.equal(error.code, 'ECONNREFUSED')
assert.strictEqual(error.code, 'ECONNREFUSED')
done()
})
})
@ -306,23 +306,23 @@ describe('node feature', () => {
const p = document.createElement('p')
p.innerText = '闲云潭影日悠悠,物换星移几度秋'
const b = Buffer.from(p.innerText)
assert.equal(b.toString(), '闲云潭影日悠悠,物换星移几度秋')
assert.equal(Buffer.byteLength(p.innerText), 45)
assert.strictEqual(b.toString(), '闲云潭影日悠悠,物换星移几度秋')
assert.strictEqual(Buffer.byteLength(p.innerText), 45)
})
it('correctly parses external one-byte UTF8 string', () => {
const p = document.createElement('p')
p.innerText = 'Jøhänñéß'
const b = Buffer.from(p.innerText)
assert.equal(b.toString(), 'Jøhänñéß')
assert.equal(Buffer.byteLength(p.innerText), 13)
assert.strictEqual(b.toString(), 'Jøhänñéß')
assert.strictEqual(Buffer.byteLength(p.innerText), 13)
})
it('does not crash when creating large Buffers', () => {
let buffer = Buffer.from(new Array(4096).join(' '))
assert.equal(buffer.length, 4095)
assert.strictEqual(buffer.length, 4095)
buffer = Buffer.from(new Array(4097).join(' '))
assert.equal(buffer.length, 4096)
assert.strictEqual(buffer.length, 4096)
})
it('does not crash for crypto operations', () => {
@ -334,8 +334,8 @@ describe('node feature', () => {
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()])
assert.equal(cipherText, result)
let result = Buffer.concat([decipher.update(input), decipher.final()]).toString('utf8')
assert.strictEqual(cipherText, result)
}
})
})
@ -361,7 +361,7 @@ describe('node feature', () => {
return
}
assert.equal(typeof process.stdout.isTTY, 'boolean')
assert.strictEqual(typeof process.stdout.isTTY, 'boolean')
})
it('should have isTTY undefined on Windows', function () {
@ -371,7 +371,7 @@ describe('node feature', () => {
return
}
assert.equal(process.stdout.isTTY, undefined)
assert.strictEqual(process.stdout.isTTY, undefined)
})
})
@ -383,7 +383,7 @@ describe('node feature', () => {
})
it('returns null when read from', () => {
assert.equal(process.stdin.read(), null)
assert.strictEqual(process.stdin.read(), null)
})
})

View file

@ -124,11 +124,11 @@ describe('<webview> tag', function () {
const message = await startLoadingWebViewAndWaitForMessage(webview, {
src: '../fixtures/pages/e.html'
})
assert.equal(message, 'Window script is loaded before preload script')
assert.strictEqual(message, 'Window script is loaded before preload script')
})
it('ignores empty values', () => {
assert.equal(webview.src, '')
assert.strictEqual(webview.src, '')
for (const emptyValue of ['', null, undefined]) {
webview.src = emptyValue
@ -188,7 +188,7 @@ describe('<webview> tag', function () {
it('disables node integration on child windows when it is disabled on the webview', (done) => {
app.once('browser-window-created', (event, window) => {
assert.equal(window.webContents.getWebPreferences().nodeIntegration, false)
assert.strictEqual(window.webContents.getWebPreferences().nodeIntegration, false)
done()
})
@ -215,7 +215,7 @@ describe('<webview> tag', function () {
webview.reload()
const { message } = await waitForEvent(webview, 'console-message')
assert.equal(message, 'function')
assert.strictEqual(message, 'function')
})
})
@ -282,8 +282,8 @@ describe('<webview> tag', function () {
webview.send('ping', message)
const { channel, args } = await waitForEvent(webview, 'ipc-message')
assert.equal(channel, 'pong')
assert.deepEqual(args, [message])
assert.strictEqual(channel, 'pong')
assert.deepStrictEqual(args, [message])
})
it('works without script tag in page', async () => {
@ -317,11 +317,11 @@ describe('<webview> tag', function () {
})
it('ignores empty values', () => {
assert.equal(webview.preload, '')
assert.strictEqual(webview.preload, '')
for (const emptyValue of ['', null, undefined]) {
webview.preload = emptyValue
assert.equal(webview.preload, '')
assert.strictEqual(webview.preload, '')
}
})
})
@ -332,7 +332,7 @@ describe('<webview> tag', function () {
const server = http.createServer((req, res) => {
res.end()
server.close()
assert.equal(req.headers.referer, referrer)
assert.strictEqual(req.headers.referer, referrer)
done()
}).listen(0, '127.0.0.1', () => {
const port = server.address().port
@ -528,7 +528,7 @@ describe('<webview> tag', function () {
})
const [, data] = await emittedOnce(ipcMain, 'isolated-world')
assert.deepEqual(data, {
assert.deepStrictEqual(data, {
preloadContext: {
preloadProperty: 'number',
pageProperty: 'undefined',
@ -559,8 +559,8 @@ describe('<webview> tag', function () {
})
const { url, frameName } = await waitForEvent(webview, 'new-window')
assert.equal(url, 'http://host/')
assert.equal(frameName, 'host')
assert.strictEqual(url, 'http://host/')
assert.strictEqual(frameName, 'host')
})
it('emits when link with target is called', async () => {
@ -569,8 +569,8 @@ describe('<webview> tag', function () {
})
const { url, frameName } = await waitForEvent(webview, 'new-window')
assert.equal(url, 'http://host/')
assert.equal(frameName, 'target')
assert.strictEqual(url, 'http://host/')
assert.strictEqual(frameName, 'target')
})
})
@ -582,8 +582,8 @@ describe('<webview> tag', function () {
})
const { channel, args } = await waitForEvent(webview, 'ipc-message')
assert.equal(channel, 'channel')
assert.deepEqual(args, ['arg1', 'arg2'])
assert.strictEqual(channel, 'channel')
assert.deepStrictEqual(args, ['arg1', 'arg2'])
})
})
@ -594,7 +594,7 @@ describe('<webview> tag', function () {
})
const { title, explicitSet } = await waitForEvent(webview, 'page-title-set')
assert.equal(title, 'test')
assert.strictEqual(title, 'test')
assert(explicitSet)
})
})
@ -607,11 +607,11 @@ describe('<webview> tag', function () {
const { favicons } = await waitForEvent(webview, 'page-favicon-updated')
assert(favicons)
assert.equal(favicons.length, 2)
assert.strictEqual(favicons.length, 2)
if (process.platform === 'win32') {
assert(/^file:\/\/\/[A-Z]:\/favicon.png$/i.test(favicons[0]))
} else {
assert.equal(favicons[0], 'file:///favicon.png')
assert.strictEqual(favicons[0], 'file:///favicon.png')
}
})
})
@ -623,7 +623,7 @@ describe('<webview> tag', function () {
})
const { url } = await waitForEvent(webview, 'will-navigate')
assert.equal(url, 'http://host/')
assert.strictEqual(url, 'http://host/')
})
})
@ -640,7 +640,7 @@ describe('<webview> tag', function () {
loadWebView(webview, { src: pageUrl })
const { url } = await waitForEvent(webview, 'did-navigate')
assert.equal(url, pageUrl)
assert.strictEqual(url, pageUrl)
})
})
@ -655,7 +655,7 @@ describe('<webview> tag', function () {
})
loadWebView(webview, { src: pageUrl })
const event = await waitForEvent(webview, 'did-navigate-in-page')
assert.equal(event.url, `${pageUrl}#test_content`)
assert.strictEqual(event.url, `${pageUrl}#test_content`)
})
it('emits when window.history.replaceState is called', async () => {
@ -663,7 +663,7 @@ describe('<webview> tag', function () {
src: `file://${fixtures}/pages/webview-did-navigate-in-page-with-history.html`
})
const { url } = await waitForEvent(webview, 'did-navigate-in-page')
assert.equal(url, 'http://host/')
assert.strictEqual(url, 'http://host/')
})
it('emits when window.location.hash is changed', async () => {
@ -676,7 +676,7 @@ describe('<webview> tag', function () {
})
loadWebView(webview, { src: pageUrl })
const event = await waitForEvent(webview, 'did-navigate-in-page')
assert.equal(event.url, `${pageUrl}#test`)
assert.strictEqual(event.url, `${pageUrl}#test`)
})
})
@ -776,7 +776,7 @@ describe('<webview> tag', function () {
webview.reload()
const { channel } = await waitForOnbeforeunload
assert.equal(channel, 'onbeforeunload')
assert.strictEqual(channel, 'onbeforeunload')
})
})
@ -785,13 +785,13 @@ describe('<webview> tag', function () {
let loadCount = 1
const listener = (e) => {
if (loadCount === 1) {
assert.equal(e.channel, 'history')
assert.equal(e.args[0], 1)
assert.strictEqual(e.channel, 'history')
assert.strictEqual(e.args[0], 1)
assert(!webview.canGoBack())
assert(!webview.canGoForward())
} else if (loadCount === 2) {
assert.equal(e.channel, 'history')
assert.equal(e.args[0], 2)
assert.strictEqual(e.channel, 'history')
assert.strictEqual(e.args[0], 2)
assert(!webview.canGoBack())
assert(webview.canGoForward())
webview.removeEventListener('ipc-message', listener)
@ -837,8 +837,8 @@ describe('<webview> tag', function () {
})
const event = await waitForEvent(webview, 'ipc-message')
assert.equal(event.channel, 'history')
assert.equal(event.args[0], 2)
assert.strictEqual(event.channel, 'history')
assert.strictEqual(event.args[0], 2)
assert(webview.canGoBack())
webview.clearHistory()
@ -863,7 +863,7 @@ describe('<webview> tag', function () {
server.listen(0, '127.0.0.1', () => {
const port = server.address().port
webview.addEventListener('ipc-message', (e) => {
assert.equal(e.channel, message)
assert.strictEqual(e.channel, message)
done()
})
loadWebView(webview, {
@ -925,7 +925,7 @@ describe('<webview> tag', function () {
resolve(result)
})
})
assert.equal(result, expectedResult)
assert.strictEqual(result, expectedResult)
})
})
@ -945,8 +945,8 @@ describe('<webview> tag', function () {
})
const { channel, args } = await waitForIpcMessage
assert.equal(channel, 'keyup')
assert.deepEqual(args, ['C', 'KeyC', 67, true, false])
assert.strictEqual(channel, 'keyup')
assert.deepStrictEqual(args, ['C', 'KeyC', 67, true, false])
})
it('can send mouse event', async () => {
@ -965,8 +965,8 @@ describe('<webview> tag', function () {
})
const { channel, args } = await waitForIpcMessage
assert.equal(channel, 'mouseup')
assert.deepEqual(args, [10, 20, false, true])
assert.strictEqual(channel, 'mouseup')
assert.deepStrictEqual(args, [10, 20, false, true])
})
})
@ -990,11 +990,11 @@ describe('<webview> tag', function () {
let requestId = null
let activeMatchOrdinal = []
const listener = (e) => {
assert.equal(e.result.requestId, requestId)
assert.equal(e.result.matches, 3)
assert.strictEqual(e.result.requestId, requestId)
assert.strictEqual(e.result.matches, 3)
activeMatchOrdinal.push(e.result.activeMatchOrdinal)
if (e.result.activeMatchOrdinal === e.result.matches) {
assert.deepEqual(activeMatchOrdinal, [1, 2, 3])
assert.deepStrictEqual(activeMatchOrdinal, [1, 2, 3])
webview.stopFindInPage('clearSelection')
done()
} else {
@ -1036,7 +1036,7 @@ describe('<webview> tag', function () {
return callback(true)
}
assert.equal(permission, requestedPermission)
assert.strictEqual(permission, requestedPermission)
callback(false)
if (completed) completed()
}
@ -1048,8 +1048,8 @@ describe('<webview> tag', function () {
if (isCI) return done()
webview.addEventListener('ipc-message', (e) => {
assert.equal(e.channel, 'message')
assert.deepEqual(e.args, ['PermissionDeniedError'])
assert.strictEqual(e.channel, 'message')
assert.deepStrictEqual(e.args, ['PermissionDeniedError'])
done()
})
webview.src = `file://${fixtures}/pages/permissions/media.html`
@ -1061,8 +1061,8 @@ describe('<webview> tag', function () {
it('emits when using navigator.geolocation api', (done) => {
webview.addEventListener('ipc-message', (e) => {
assert.equal(e.channel, 'message')
assert.deepEqual(e.args, ['User denied Geolocation'])
assert.strictEqual(e.channel, 'message')
assert.deepStrictEqual(e.args, ['User denied Geolocation'])
done()
})
webview.src = `file://${fixtures}/pages/permissions/geolocation.html`
@ -1074,8 +1074,8 @@ describe('<webview> tag', function () {
it('emits when using navigator.requestMIDIAccess without sysex api', (done) => {
webview.addEventListener('ipc-message', (e) => {
assert.equal(e.channel, 'message')
assert.deepEqual(e.args, ['SecurityError'])
assert.strictEqual(e.channel, 'message')
assert.deepStrictEqual(e.args, ['SecurityError'])
done()
})
webview.src = `file://${fixtures}/pages/permissions/midi.html`
@ -1087,8 +1087,8 @@ describe('<webview> tag', function () {
it('emits when using navigator.requestMIDIAccess with sysex api', (done) => {
webview.addEventListener('ipc-message', (e) => {
assert.equal(e.channel, 'message')
assert.deepEqual(e.args, ['SecurityError'])
assert.strictEqual(e.channel, 'message')
assert.deepStrictEqual(e.args, ['SecurityError'])
done()
})
webview.src = `file://${fixtures}/pages/permissions/midi-sysex.html`
@ -1107,8 +1107,8 @@ describe('<webview> tag', function () {
it('emits when using Notification.requestPermission', (done) => {
webview.addEventListener('ipc-message', (e) => {
assert.equal(e.channel, 'message')
assert.deepEqual(e.args, ['granted'])
assert.strictEqual(e.channel, 'message')
assert.deepStrictEqual(e.args, ['granted'])
done()
})
webview.src = `file://${fixtures}/pages/permissions/notification.html`
@ -1116,7 +1116,7 @@ describe('<webview> tag', function () {
webview.setAttribute('nodeintegration', 'on')
session.fromPartition(webview.partition).setPermissionRequestHandler((webContents, permission, callback) => {
if (webContents.id === webview.getWebContents().id) {
assert.equal(permission, 'notifications')
assert.strictEqual(permission, 'notifications')
setTimeout(() => { callback(true) }, 10)
}
})
@ -1152,15 +1152,15 @@ describe('<webview> tag', function () {
const [, visibilityState, hidden] = await pongSignal2
assert(!hidden)
assert.equal(visibilityState, 'visible')
assert.strictEqual(visibilityState, 'visible')
})
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')
assert.equal(visibilityState, 'hidden')
assert.equal(hidden, true)
assert.strictEqual(visibilityState, 'hidden')
assert.strictEqual(hidden, true)
// We have to start waiting for the event
// before we ask the webContents to resize.
@ -1168,8 +1168,8 @@ describe('<webview> tag', function () {
w.webContents.emit('-window-visibility-change', 'visible')
return getResponse.then(([, visibilityState, hidden]) => {
assert.equal(visibilityState, 'visible')
assert.equal(hidden, false)
assert.strictEqual(visibilityState, 'visible')
assert.strictEqual(hidden, false)
})
})
})
@ -1221,7 +1221,7 @@ describe('<webview> tag', function () {
src: `file://${fixtures}/pages/a.html`
})
assert.equal(message, 'undefined')
assert.strictEqual(message, 'undefined')
})
})