chore: update to standard 12
This commit is contained in:
parent
9e85bdb02c
commit
558fff69e7
198 changed files with 4455 additions and 2940 deletions
|
@ -28,8 +28,7 @@ desktopCapturer.getSources({types: ['window', 'screen']}, (error, sources) => {
|
||||||
maxHeight: 720
|
maxHeight: 720
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}).then((stream) => handleStream(stream))
|
||||||
.then((stream) => handleStream(stream))
|
|
||||||
.catch((e) => handleError(e))
|
.catch((e) => handleError(e))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,7 +253,7 @@ const {remote} = require('electron')
|
||||||
const { Menu, MenuItem } = remote
|
const { Menu, MenuItem } = remote
|
||||||
|
|
||||||
const menu = new Menu()
|
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({ type: 'separator' }))
|
||||||
menu.append(new MenuItem({ label: 'MenuItem2', type: 'checkbox', checked: true }))
|
menu.append(new MenuItem({ label: 'MenuItem2', type: 'checkbox', checked: true }))
|
||||||
|
|
||||||
|
|
|
@ -32,13 +32,13 @@ app.start().then(function () {
|
||||||
return app.browserWindow.isVisible()
|
return app.browserWindow.isVisible()
|
||||||
}).then(function (isVisible) {
|
}).then(function (isVisible) {
|
||||||
// Verify the window is visible
|
// Verify the window is visible
|
||||||
assert.equal(isVisible, true)
|
assert.strictEqual(isVisible, true)
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
// Get the window's title
|
// Get the window's title
|
||||||
return app.client.getTitle()
|
return app.client.getTitle()
|
||||||
}).then(function (title) {
|
}).then(function (title) {
|
||||||
// Verify the window's title
|
// Verify the window's title
|
||||||
assert.equal(title, 'My App')
|
assert.strictEqual(title, 'My App')
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
// Log any failures
|
// Log any failures
|
||||||
console.error('Test failed', error.message)
|
console.error('Test failed', error.message)
|
||||||
|
|
2604
package-lock.json
generated
2604
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -29,8 +29,8 @@
|
||||||
"request": "^2.88.0",
|
"request": "^2.88.0",
|
||||||
"semver": "^5.5.0",
|
"semver": "^5.5.0",
|
||||||
"serve": "^6.5.8",
|
"serve": "^6.5.8",
|
||||||
"standard": "^10.0.0",
|
"standard": "^12.0.0",
|
||||||
"standard-markdown": "^4.0.0",
|
"standard-markdown": "^5.0.0",
|
||||||
"sumchecker": "^2.0.2",
|
"sumchecker": "^2.0.2",
|
||||||
"temp": "^0.8.3"
|
"temp": "^0.8.3"
|
||||||
},
|
},
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -129,7 +129,7 @@ describe('crashReporter module', () => {
|
||||||
const dumps = files.filter((file) => /\.dmp$/.test(file) && !existingDumpFiles.has(file))
|
const dumps = files.filter((file) => /\.dmp$/.test(file) && !existingDumpFiles.has(file))
|
||||||
if (!dumps.length) return
|
if (!dumps.length) return
|
||||||
|
|
||||||
assert.equal(1, dumps.length)
|
assert.strictEqual(1, dumps.length)
|
||||||
dumpFile = path.join(crashesDir, dumps[0])
|
dumpFile = path.join(crashesDir, dumps[0])
|
||||||
clearInterval(pollInterval)
|
clearInterval(pollInterval)
|
||||||
// dump file should not be deleted when not uploading, so we wait
|
// 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', () => {
|
it('returns the product name if one is specified', () => {
|
||||||
const name = crashReporter.getProductName()
|
const name = crashReporter.getProductName()
|
||||||
const expectedName = (process.platform === 'darwin') ? 'Electron Test' : 'Zombies'
|
const expectedName = (process.platform === 'darwin') ? 'Electron Test' : 'Zombies'
|
||||||
assert.equal(name, expectedName)
|
assert.strictEqual(name, expectedName)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getTempDirectory', () => {
|
describe('getTempDirectory', () => {
|
||||||
it('returns temp directory for app if one is specified', () => {
|
it('returns temp directory for app if one is specified', () => {
|
||||||
const tempDir = crashReporter.getTempDirectory()
|
const tempDir = crashReporter.getTempDirectory()
|
||||||
assert.equal(tempDir, app.getPath('temp'))
|
assert.strictEqual(tempDir, app.getPath('temp'))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ describe('crashReporter module', () => {
|
||||||
} else {
|
} else {
|
||||||
dir = `${app.getPath('temp')}/Electron Test Crashes`
|
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',
|
submitURL: 'http://127.0.0.1/crashes',
|
||||||
uploadToServer: true
|
uploadToServer: true
|
||||||
})
|
})
|
||||||
assert.equal(crashReporter.getUploadToServer(), true)
|
assert.strictEqual(crashReporter.getUploadToServer(), true)
|
||||||
})
|
})
|
||||||
it('returns false when uploadToServer is set to false', function () {
|
it('returns false when uploadToServer is set to false', function () {
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
|
@ -314,7 +314,7 @@ describe('crashReporter module', () => {
|
||||||
uploadToServer: true
|
uploadToServer: true
|
||||||
})
|
})
|
||||||
crashReporter.setUploadToServer(false)
|
crashReporter.setUploadToServer(false)
|
||||||
assert.equal(crashReporter.getUploadToServer(), false)
|
assert.strictEqual(crashReporter.getUploadToServer(), false)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ describe('crashReporter module', () => {
|
||||||
uploadToServer: true
|
uploadToServer: true
|
||||||
})
|
})
|
||||||
crashReporter.setUploadToServer(false)
|
crashReporter.setUploadToServer(false)
|
||||||
assert.equal(crashReporter.getUploadToServer(), false)
|
assert.strictEqual(crashReporter.getUploadToServer(), false)
|
||||||
})
|
})
|
||||||
it('sets uploadToServer true when called with true', function () {
|
it('sets uploadToServer true when called with true', function () {
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
|
@ -350,7 +350,7 @@ describe('crashReporter module', () => {
|
||||||
uploadToServer: false
|
uploadToServer: false
|
||||||
})
|
})
|
||||||
crashReporter.setUploadToServer(true)
|
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 (error) throw error
|
||||||
if (called) return
|
if (called) return
|
||||||
called = true
|
called = true
|
||||||
assert.equal(fields.prod, 'Electron')
|
assert.strictEqual(fields.prod, 'Electron')
|
||||||
assert.equal(fields.ver, process.versions.electron)
|
assert.strictEqual(fields.ver, process.versions.electron)
|
||||||
assert.equal(fields.process_type, processType)
|
assert.strictEqual(fields.process_type, processType)
|
||||||
assert.equal(fields.platform, process.platform)
|
assert.strictEqual(fields.platform, process.platform)
|
||||||
assert.equal(fields.extra1, 'extra1')
|
assert.strictEqual(fields.extra1, 'extra1')
|
||||||
assert.equal(fields.extra2, 'extra2')
|
assert.strictEqual(fields.extra2, 'extra2')
|
||||||
assert.equal(fields.extra3, undefined)
|
assert.strictEqual(fields.extra3, undefined)
|
||||||
assert.equal(fields._productName, 'Zombies')
|
assert.strictEqual(fields._productName, 'Zombies')
|
||||||
assert.equal(fields._companyName, 'Umbrella Corporation')
|
assert.strictEqual(fields._companyName, 'Umbrella Corporation')
|
||||||
assert.equal(fields._version, app.getVersion())
|
assert.strictEqual(fields._version, app.getVersion())
|
||||||
|
|
||||||
const reportId = 'abc-123-def-456-abc-789-abc-123-abcd'
|
const reportId = 'abc-123-def-456-abc-789-abc-123-abcd'
|
||||||
res.end(reportId, () => {
|
res.end(reportId, () => {
|
||||||
waitForCrashReport().then(() => {
|
waitForCrashReport().then(() => {
|
||||||
assert.equal(crashReporter.getLastCrashReport().id, reportId)
|
assert.strictEqual(crashReporter.getLastCrashReport().id, reportId)
|
||||||
assert.notEqual(crashReporter.getUploadedReports().length, 0)
|
assert.notStrictEqual(crashReporter.getUploadedReports().length, 0)
|
||||||
assert.equal(crashReporter.getUploadedReports()[0].id, reportId)
|
assert.strictEqual(crashReporter.getUploadedReports()[0].id, reportId)
|
||||||
req.socket.destroy()
|
req.socket.destroy()
|
||||||
done()
|
done()
|
||||||
}, done)
|
}, done)
|
||||||
|
|
|
@ -62,7 +62,7 @@ describe('net module', () => {
|
||||||
server.on('request', (request, response) => {
|
server.on('request', (request, response) => {
|
||||||
switch (request.url) {
|
switch (request.url) {
|
||||||
case requestUrl:
|
case requestUrl:
|
||||||
assert.equal(request.method, 'GET')
|
assert.strictEqual(request.method, 'GET')
|
||||||
response.end()
|
response.end()
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
@ -71,7 +71,7 @@ describe('net module', () => {
|
||||||
})
|
})
|
||||||
const urlRequest = net.request(`${server.url}${requestUrl}`)
|
const urlRequest = net.request(`${server.url}${requestUrl}`)
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
assert.equal(response.statusCode, 200)
|
assert.strictEqual(response.statusCode, 200)
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('data', (chunk) => {
|
response.on('data', (chunk) => {
|
||||||
})
|
})
|
||||||
|
@ -88,7 +88,7 @@ describe('net module', () => {
|
||||||
server.on('request', (request, response) => {
|
server.on('request', (request, response) => {
|
||||||
switch (request.url) {
|
switch (request.url) {
|
||||||
case requestUrl:
|
case requestUrl:
|
||||||
assert.equal(request.method, 'POST')
|
assert.strictEqual(request.method, 'POST')
|
||||||
response.end()
|
response.end()
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
@ -100,7 +100,7 @@ describe('net module', () => {
|
||||||
url: `${server.url}${requestUrl}`
|
url: `${server.url}${requestUrl}`
|
||||||
})
|
})
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
assert.equal(response.statusCode, 200)
|
assert.strictEqual(response.statusCode, 200)
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('data', (chunk) => {
|
response.on('data', (chunk) => {
|
||||||
})
|
})
|
||||||
|
@ -118,7 +118,7 @@ describe('net module', () => {
|
||||||
server.on('request', (request, response) => {
|
server.on('request', (request, response) => {
|
||||||
switch (request.url) {
|
switch (request.url) {
|
||||||
case requestUrl:
|
case requestUrl:
|
||||||
assert.equal(request.method, 'GET')
|
assert.strictEqual(request.method, 'GET')
|
||||||
response.write(bodyData)
|
response.write(bodyData)
|
||||||
response.end()
|
response.end()
|
||||||
break
|
break
|
||||||
|
@ -129,13 +129,13 @@ describe('net module', () => {
|
||||||
const urlRequest = net.request(`${server.url}${requestUrl}`)
|
const urlRequest = net.request(`${server.url}${requestUrl}`)
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
let expectedBodyData = ''
|
let expectedBodyData = ''
|
||||||
assert.equal(response.statusCode, 200)
|
assert.strictEqual(response.statusCode, 200)
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('data', (chunk) => {
|
response.on('data', (chunk) => {
|
||||||
expectedBodyData += chunk.toString()
|
expectedBodyData += chunk.toString()
|
||||||
})
|
})
|
||||||
response.on('end', () => {
|
response.on('end', () => {
|
||||||
assert.equal(expectedBodyData, bodyData)
|
assert.strictEqual(expectedBodyData, bodyData)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
response.resume()
|
response.resume()
|
||||||
|
@ -150,12 +150,12 @@ describe('net module', () => {
|
||||||
let postedBodyData = ''
|
let postedBodyData = ''
|
||||||
switch (request.url) {
|
switch (request.url) {
|
||||||
case requestUrl:
|
case requestUrl:
|
||||||
assert.equal(request.method, 'POST')
|
assert.strictEqual(request.method, 'POST')
|
||||||
request.on('data', (chunk) => {
|
request.on('data', (chunk) => {
|
||||||
postedBodyData += chunk.toString()
|
postedBodyData += chunk.toString()
|
||||||
})
|
})
|
||||||
request.on('end', () => {
|
request.on('end', () => {
|
||||||
assert.equal(postedBodyData, bodyData)
|
assert.strictEqual(postedBodyData, bodyData)
|
||||||
response.end()
|
response.end()
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
@ -168,7 +168,7 @@ describe('net module', () => {
|
||||||
url: `${server.url}${requestUrl}`
|
url: `${server.url}${requestUrl}`
|
||||||
})
|
})
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
assert.equal(response.statusCode, 200)
|
assert.strictEqual(response.statusCode, 200)
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('data', (chunk) => {})
|
response.on('data', (chunk) => {})
|
||||||
response.on('end', () => {
|
response.on('end', () => {
|
||||||
|
@ -188,8 +188,8 @@ describe('net module', () => {
|
||||||
response.statusCode = 200
|
response.statusCode = 200
|
||||||
response.statusMessage = 'OK'
|
response.statusMessage = 'OK'
|
||||||
response.chunkedEncoding = true
|
response.chunkedEncoding = true
|
||||||
assert.equal(request.method, 'POST')
|
assert.strictEqual(request.method, 'POST')
|
||||||
assert.equal(request.headers['transfer-encoding'], 'chunked')
|
assert.strictEqual(request.headers['transfer-encoding'], 'chunked')
|
||||||
assert(!request.headers['content-length'])
|
assert(!request.headers['content-length'])
|
||||||
request.on('data', (chunk) => {
|
request.on('data', (chunk) => {
|
||||||
response.write(chunk)
|
response.write(chunk)
|
||||||
|
@ -212,7 +212,7 @@ describe('net module', () => {
|
||||||
let sentChunks = []
|
let sentChunks = []
|
||||||
let receivedChunks = []
|
let receivedChunks = []
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
assert.equal(response.statusCode, 200)
|
assert.strictEqual(response.statusCode, 200)
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('data', (chunk) => {
|
response.on('data', (chunk) => {
|
||||||
receivedChunks.push(chunk)
|
receivedChunks.push(chunk)
|
||||||
|
@ -220,8 +220,8 @@ describe('net module', () => {
|
||||||
response.on('end', () => {
|
response.on('end', () => {
|
||||||
let sentData = Buffer.concat(sentChunks)
|
let sentData = Buffer.concat(sentChunks)
|
||||||
let receivedData = Buffer.concat(receivedChunks)
|
let receivedData = Buffer.concat(receivedChunks)
|
||||||
assert.equal(sentData.toString(), receivedData.toString())
|
assert.strictEqual(sentData.toString(), receivedData.toString())
|
||||||
assert.equal(chunkIndex, chunkCount)
|
assert.strictEqual(chunkIndex, chunkCount)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
response.resume()
|
response.resume()
|
||||||
|
@ -284,7 +284,7 @@ describe('net module', () => {
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
requestResponseEventEmitted = true
|
requestResponseEventEmitted = true
|
||||||
const statusCode = response.statusCode
|
const statusCode = response.statusCode
|
||||||
assert.equal(statusCode, 200)
|
assert.strictEqual(statusCode, 200)
|
||||||
let buffers = []
|
let buffers = []
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('data', (chunk) => {
|
response.on('data', (chunk) => {
|
||||||
|
@ -328,7 +328,7 @@ describe('net module', () => {
|
||||||
server.on('request', (request, response) => {
|
server.on('request', (request, response) => {
|
||||||
switch (request.url) {
|
switch (request.url) {
|
||||||
case requestUrl:
|
case requestUrl:
|
||||||
assert.equal(request.headers[customHeaderName.toLowerCase()],
|
assert.strictEqual(request.headers[customHeaderName.toLowerCase()],
|
||||||
customHeaderValue)
|
customHeaderValue)
|
||||||
response.statusCode = 200
|
response.statusCode = 200
|
||||||
response.statusMessage = 'OK'
|
response.statusMessage = 'OK'
|
||||||
|
@ -344,7 +344,7 @@ describe('net module', () => {
|
||||||
})
|
})
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
const statusCode = response.statusCode
|
const statusCode = response.statusCode
|
||||||
assert.equal(statusCode, 200)
|
assert.strictEqual(statusCode, 200)
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('data', (chunk) => {
|
response.on('data', (chunk) => {
|
||||||
})
|
})
|
||||||
|
@ -354,14 +354,14 @@ describe('net module', () => {
|
||||||
response.resume()
|
response.resume()
|
||||||
})
|
})
|
||||||
urlRequest.setHeader(customHeaderName, customHeaderValue)
|
urlRequest.setHeader(customHeaderName, customHeaderValue)
|
||||||
assert.equal(urlRequest.getHeader(customHeaderName),
|
assert.strictEqual(urlRequest.getHeader(customHeaderName),
|
||||||
customHeaderValue)
|
customHeaderValue)
|
||||||
assert.equal(urlRequest.getHeader(customHeaderName.toLowerCase()),
|
assert.strictEqual(urlRequest.getHeader(customHeaderName.toLowerCase()),
|
||||||
customHeaderValue)
|
customHeaderValue)
|
||||||
urlRequest.write('')
|
urlRequest.write('')
|
||||||
assert.equal(urlRequest.getHeader(customHeaderName),
|
assert.strictEqual(urlRequest.getHeader(customHeaderName),
|
||||||
customHeaderValue)
|
customHeaderValue)
|
||||||
assert.equal(urlRequest.getHeader(customHeaderName.toLowerCase()),
|
assert.strictEqual(urlRequest.getHeader(customHeaderName.toLowerCase()),
|
||||||
customHeaderValue)
|
customHeaderValue)
|
||||||
urlRequest.end()
|
urlRequest.end()
|
||||||
})
|
})
|
||||||
|
@ -373,14 +373,14 @@ describe('net module', () => {
|
||||||
server.on('request', (request, response) => {
|
server.on('request', (request, response) => {
|
||||||
switch (request.url) {
|
switch (request.url) {
|
||||||
case requestUrl:
|
case requestUrl:
|
||||||
assert.equal(request.headers[customHeaderName.toLowerCase()],
|
assert.strictEqual(request.headers[customHeaderName.toLowerCase()],
|
||||||
customHeaderValue.toString())
|
customHeaderValue.toString())
|
||||||
response.statusCode = 200
|
response.statusCode = 200
|
||||||
response.statusMessage = 'OK'
|
response.statusMessage = 'OK'
|
||||||
response.end()
|
response.end()
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
assert.equal(request.url, requestUrl)
|
assert.strictEqual(request.url, requestUrl)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const urlRequest = net.request({
|
const urlRequest = net.request({
|
||||||
|
@ -389,7 +389,7 @@ describe('net module', () => {
|
||||||
})
|
})
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
const statusCode = response.statusCode
|
const statusCode = response.statusCode
|
||||||
assert.equal(statusCode, 200)
|
assert.strictEqual(statusCode, 200)
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('end', () => {
|
response.on('end', () => {
|
||||||
done()
|
done()
|
||||||
|
@ -397,14 +397,14 @@ describe('net module', () => {
|
||||||
response.resume()
|
response.resume()
|
||||||
})
|
})
|
||||||
urlRequest.setHeader(customHeaderName, customHeaderValue)
|
urlRequest.setHeader(customHeaderName, customHeaderValue)
|
||||||
assert.equal(urlRequest.getHeader(customHeaderName),
|
assert.strictEqual(urlRequest.getHeader(customHeaderName),
|
||||||
customHeaderValue)
|
customHeaderValue)
|
||||||
assert.equal(urlRequest.getHeader(customHeaderName.toLowerCase()),
|
assert.strictEqual(urlRequest.getHeader(customHeaderName.toLowerCase()),
|
||||||
customHeaderValue)
|
customHeaderValue)
|
||||||
urlRequest.write('')
|
urlRequest.write('')
|
||||||
assert.equal(urlRequest.getHeader(customHeaderName),
|
assert.strictEqual(urlRequest.getHeader(customHeaderName),
|
||||||
customHeaderValue)
|
customHeaderValue)
|
||||||
assert.equal(urlRequest.getHeader(customHeaderName.toLowerCase()),
|
assert.strictEqual(urlRequest.getHeader(customHeaderName.toLowerCase()),
|
||||||
customHeaderValue)
|
customHeaderValue)
|
||||||
urlRequest.end()
|
urlRequest.end()
|
||||||
})
|
})
|
||||||
|
@ -431,7 +431,7 @@ describe('net module', () => {
|
||||||
})
|
})
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
const statusCode = response.statusCode
|
const statusCode = response.statusCode
|
||||||
assert.equal(statusCode, 200)
|
assert.strictEqual(statusCode, 200)
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('data', (chunk) => {
|
response.on('data', (chunk) => {
|
||||||
})
|
})
|
||||||
|
@ -470,7 +470,7 @@ describe('net module', () => {
|
||||||
})
|
})
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
const statusCode = response.statusCode
|
const statusCode = response.statusCode
|
||||||
assert.equal(statusCode, 200)
|
assert.strictEqual(statusCode, 200)
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('data', (chunk) => {
|
response.on('data', (chunk) => {
|
||||||
})
|
})
|
||||||
|
@ -480,7 +480,7 @@ describe('net module', () => {
|
||||||
response.resume()
|
response.resume()
|
||||||
})
|
})
|
||||||
urlRequest.setHeader(customHeaderName, customHeaderValue)
|
urlRequest.setHeader(customHeaderName, customHeaderValue)
|
||||||
assert.equal(urlRequest.getHeader(customHeaderName),
|
assert.strictEqual(urlRequest.getHeader(customHeaderName),
|
||||||
customHeaderValue)
|
customHeaderValue)
|
||||||
urlRequest.removeHeader(customHeaderName)
|
urlRequest.removeHeader(customHeaderName)
|
||||||
assert(!urlRequest.getHeader(customHeaderName))
|
assert(!urlRequest.getHeader(customHeaderName))
|
||||||
|
@ -495,7 +495,7 @@ describe('net module', () => {
|
||||||
server.on('request', (request, response) => {
|
server.on('request', (request, response) => {
|
||||||
switch (request.url) {
|
switch (request.url) {
|
||||||
case requestUrl:
|
case requestUrl:
|
||||||
assert.equal(request.headers[customHeaderName.toLowerCase()],
|
assert.strictEqual(request.headers[customHeaderName.toLowerCase()],
|
||||||
customHeaderValue)
|
customHeaderValue)
|
||||||
response.statusCode = 200
|
response.statusCode = 200
|
||||||
response.statusMessage = 'OK'
|
response.statusMessage = 'OK'
|
||||||
|
@ -511,7 +511,7 @@ describe('net module', () => {
|
||||||
})
|
})
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
const statusCode = response.statusCode
|
const statusCode = response.statusCode
|
||||||
assert.equal(statusCode, 200)
|
assert.strictEqual(statusCode, 200)
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('data', (chunk) => {
|
response.on('data', (chunk) => {
|
||||||
})
|
})
|
||||||
|
@ -521,13 +521,13 @@ describe('net module', () => {
|
||||||
response.resume()
|
response.resume()
|
||||||
})
|
})
|
||||||
urlRequest.setHeader(customHeaderName, customHeaderValue)
|
urlRequest.setHeader(customHeaderName, customHeaderValue)
|
||||||
assert.equal(urlRequest.getHeader(customHeaderName),
|
assert.strictEqual(urlRequest.getHeader(customHeaderName),
|
||||||
customHeaderValue)
|
customHeaderValue)
|
||||||
urlRequest.write('')
|
urlRequest.write('')
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
urlRequest.removeHeader(customHeaderName)
|
urlRequest.removeHeader(customHeaderName)
|
||||||
})
|
})
|
||||||
assert.equal(urlRequest.getHeader(customHeaderName),
|
assert.strictEqual(urlRequest.getHeader(customHeaderName),
|
||||||
customHeaderValue)
|
customHeaderValue)
|
||||||
urlRequest.end()
|
urlRequest.end()
|
||||||
})
|
})
|
||||||
|
@ -540,7 +540,7 @@ describe('net module', () => {
|
||||||
server.on('request', (request, response) => {
|
server.on('request', (request, response) => {
|
||||||
switch (request.url) {
|
switch (request.url) {
|
||||||
case requestUrl:
|
case requestUrl:
|
||||||
assert.equal(request.headers[cookieHeaderName.toLowerCase()],
|
assert.strictEqual(request.headers[cookieHeaderName.toLowerCase()],
|
||||||
cookieHeaderValue)
|
cookieHeaderValue)
|
||||||
response.statusCode = 200
|
response.statusCode = 200
|
||||||
response.statusMessage = 'OK'
|
response.statusMessage = 'OK'
|
||||||
|
@ -563,7 +563,7 @@ describe('net module', () => {
|
||||||
})
|
})
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
const statusCode = response.statusCode
|
const statusCode = response.statusCode
|
||||||
assert.equal(statusCode, 200)
|
assert.strictEqual(statusCode, 200)
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('data', (chunk) => {})
|
response.on('data', (chunk) => {})
|
||||||
response.on('end', () => {
|
response.on('end', () => {
|
||||||
|
@ -572,7 +572,7 @@ describe('net module', () => {
|
||||||
response.resume()
|
response.resume()
|
||||||
})
|
})
|
||||||
urlRequest.setHeader(cookieHeaderName, cookieHeaderValue)
|
urlRequest.setHeader(cookieHeaderName, cookieHeaderValue)
|
||||||
assert.equal(urlRequest.getHeader(cookieHeaderName),
|
assert.strictEqual(urlRequest.getHeader(cookieHeaderName),
|
||||||
cookieHeaderValue)
|
cookieHeaderValue)
|
||||||
urlRequest.end()
|
urlRequest.end()
|
||||||
})
|
})
|
||||||
|
@ -746,7 +746,7 @@ describe('net module', () => {
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
requestResponseEventEmitted = true
|
requestResponseEventEmitted = true
|
||||||
const statusCode = response.statusCode
|
const statusCode = response.statusCode
|
||||||
assert.equal(statusCode, 200)
|
assert.strictEqual(statusCode, 200)
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('data', (chunk) => {
|
response.on('data', (chunk) => {
|
||||||
})
|
})
|
||||||
|
@ -825,7 +825,7 @@ describe('net module', () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
assert(requestFinishEventEmitted)
|
assert(requestFinishEventEmitted)
|
||||||
assert(requestReceivedByServer)
|
assert(requestReceivedByServer)
|
||||||
assert.equal(requestAbortEventCount, 1)
|
assert.strictEqual(requestAbortEventCount, 1)
|
||||||
assert(requestCloseEventEmitted)
|
assert(requestCloseEventEmitted)
|
||||||
done()
|
done()
|
||||||
}, 500)
|
}, 500)
|
||||||
|
@ -873,7 +873,7 @@ describe('net module', () => {
|
||||||
const urlRequest = net.request(`${server.url}${requestUrl}`)
|
const urlRequest = net.request(`${server.url}${requestUrl}`)
|
||||||
|
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
assert.equal(response.statusCode, 200)
|
assert.strictEqual(response.statusCode, 200)
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('data', (chunk) => {
|
response.on('data', (chunk) => {
|
||||||
})
|
})
|
||||||
|
@ -929,7 +929,7 @@ describe('net module', () => {
|
||||||
session: customSession
|
session: customSession
|
||||||
})
|
})
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
assert.equal(response.statusCode, 200)
|
assert.strictEqual(response.statusCode, 200)
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('data', (chunk) => {
|
response.on('data', (chunk) => {
|
||||||
})
|
})
|
||||||
|
@ -995,7 +995,7 @@ describe('net module', () => {
|
||||||
url: `${server.url}${requestUrl}`
|
url: `${server.url}${requestUrl}`
|
||||||
})
|
})
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
assert.equal(response.statusCode, 200)
|
assert.strictEqual(response.statusCode, 200)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
urlRequest.end()
|
urlRequest.end()
|
||||||
|
@ -1027,7 +1027,7 @@ describe('net module', () => {
|
||||||
url: `${server.url}${requestUrl}`
|
url: `${server.url}${requestUrl}`
|
||||||
})
|
})
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
assert.equal(response.statusCode, 200)
|
assert.strictEqual(response.statusCode, 200)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
urlRequest.end()
|
urlRequest.end()
|
||||||
|
@ -1055,7 +1055,7 @@ describe('net module', () => {
|
||||||
redirect: 'error'
|
redirect: 'error'
|
||||||
})
|
})
|
||||||
urlRequest.on('error', (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', () => {
|
urlRequest.on('close', () => {
|
||||||
done()
|
done()
|
||||||
|
@ -1091,8 +1091,8 @@ describe('net module', () => {
|
||||||
redirect: 'manual'
|
redirect: 'manual'
|
||||||
})
|
})
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
assert.equal(response.statusCode, 200)
|
assert.strictEqual(response.statusCode, 200)
|
||||||
assert.equal(redirectCount, 2)
|
assert.strictEqual(redirectCount, 2)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
urlRequest.on('redirect', (status, method, url) => {
|
urlRequest.on('redirect', (status, method, url) => {
|
||||||
|
@ -1132,7 +1132,7 @@ describe('net module', () => {
|
||||||
redirect: 'manual'
|
redirect: 'manual'
|
||||||
})
|
})
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
assert.equal(response.statusCode, 200)
|
assert.strictEqual(response.statusCode, 200)
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('data', (chunk) => {
|
response.on('data', (chunk) => {
|
||||||
})
|
})
|
||||||
|
@ -1142,7 +1142,7 @@ describe('net module', () => {
|
||||||
response.resume()
|
response.resume()
|
||||||
})
|
})
|
||||||
urlRequest.on('close', () => {
|
urlRequest.on('close', () => {
|
||||||
assert.equal(redirectCount, 1)
|
assert.strictEqual(redirectCount, 1)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
urlRequest.on('redirect', (status, method, url) => {
|
urlRequest.on('redirect', (status, method, url) => {
|
||||||
|
@ -1211,7 +1211,7 @@ describe('net module', () => {
|
||||||
partition: customPartitionName
|
partition: customPartitionName
|
||||||
})
|
})
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
assert.equal(response.statusCode, 200)
|
assert.strictEqual(response.statusCode, 200)
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('data', (chunk) => {
|
response.on('data', (chunk) => {
|
||||||
})
|
})
|
||||||
|
@ -1247,8 +1247,8 @@ describe('net module', () => {
|
||||||
server.on('request', (request, response) => {
|
server.on('request', (request, response) => {
|
||||||
switch (request.url) {
|
switch (request.url) {
|
||||||
case requestUrl:
|
case requestUrl:
|
||||||
assert.equal(request.method, 'GET')
|
assert.strictEqual(request.method, 'GET')
|
||||||
assert.equal(request.headers[customHeaderName.toLowerCase()],
|
assert.strictEqual(request.headers[customHeaderName.toLowerCase()],
|
||||||
customHeaderValue)
|
customHeaderValue)
|
||||||
response.statusCode = 200
|
response.statusCode = 200
|
||||||
response.statusMessage = 'OK'
|
response.statusMessage = 'OK'
|
||||||
|
@ -1268,7 +1268,7 @@ describe('net module', () => {
|
||||||
options.headers[customHeaderName] = customHeaderValue
|
options.headers[customHeaderName] = customHeaderValue
|
||||||
const urlRequest = net.request(options)
|
const urlRequest = net.request(options)
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
assert.equal(response.statusCode, 200)
|
assert.strictEqual(response.statusCode, 200)
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('data', (chunk) => {
|
response.on('data', (chunk) => {
|
||||||
})
|
})
|
||||||
|
@ -1303,7 +1303,7 @@ describe('net module', () => {
|
||||||
if (chunk) {
|
if (chunk) {
|
||||||
receivedBodyData += chunk.toString()
|
receivedBodyData += chunk.toString()
|
||||||
}
|
}
|
||||||
assert.equal(receivedBodyData, bodyData)
|
assert.strictEqual(receivedBodyData, bodyData)
|
||||||
response.end()
|
response.end()
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
@ -1316,7 +1316,7 @@ describe('net module', () => {
|
||||||
nodeRequest.on('response', (nodeResponse) => {
|
nodeRequest.on('response', (nodeResponse) => {
|
||||||
const netRequest = net.request(`${server.url}${netRequestUrl}`)
|
const netRequest = net.request(`${server.url}${netRequestUrl}`)
|
||||||
netRequest.on('response', (netResponse) => {
|
netRequest.on('response', (netResponse) => {
|
||||||
assert.equal(netResponse.statusCode, 200)
|
assert.strictEqual(netResponse.statusCode, 200)
|
||||||
netResponse.pause()
|
netResponse.pause()
|
||||||
netResponse.on('data', (chunk) => {})
|
netResponse.on('data', (chunk) => {})
|
||||||
netResponse.on('end', () => {
|
netResponse.on('end', () => {
|
||||||
|
@ -1380,13 +1380,13 @@ describe('net module', () => {
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
const statusCode = response.statusCode
|
const statusCode = response.statusCode
|
||||||
assert(typeof statusCode === 'number')
|
assert(typeof statusCode === 'number')
|
||||||
assert.equal(statusCode, 200)
|
assert.strictEqual(statusCode, 200)
|
||||||
const statusMessage = response.statusMessage
|
const statusMessage = response.statusMessage
|
||||||
assert(typeof statusMessage === 'string')
|
assert(typeof statusMessage === 'string')
|
||||||
assert.equal(statusMessage, 'OK')
|
assert.strictEqual(statusMessage, 'OK')
|
||||||
const headers = response.headers
|
const headers = response.headers
|
||||||
assert(typeof headers === 'object')
|
assert(typeof headers === 'object')
|
||||||
assert.deepEqual(headers[customHeaderName.toLowerCase()],
|
assert.deepStrictEqual(headers[customHeaderName.toLowerCase()],
|
||||||
[customHeaderValue])
|
[customHeaderValue])
|
||||||
const httpVersion = response.httpVersion
|
const httpVersion = response.httpVersion
|
||||||
assert(typeof httpVersion === 'string')
|
assert(typeof httpVersion === 'string')
|
||||||
|
@ -1429,7 +1429,7 @@ describe('net module', () => {
|
||||||
if (chunk) {
|
if (chunk) {
|
||||||
receivedBodyData += chunk.toString()
|
receivedBodyData += chunk.toString()
|
||||||
}
|
}
|
||||||
assert.equal(receivedBodyData, bodyData)
|
assert.strictEqual(receivedBodyData, bodyData)
|
||||||
response.end()
|
response.end()
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
@ -1491,7 +1491,7 @@ describe('net module', () => {
|
||||||
urlRequest.on('response', (response) => {
|
urlRequest.on('response', (response) => {
|
||||||
assert(!requestCloseEventEmitted)
|
assert(!requestCloseEventEmitted)
|
||||||
const statusCode = response.statusCode
|
const statusCode = response.statusCode
|
||||||
assert.equal(statusCode, 200)
|
assert.strictEqual(statusCode, 200)
|
||||||
response.pause()
|
response.pause()
|
||||||
response.on('data', () => {
|
response.on('data', () => {
|
||||||
})
|
})
|
||||||
|
|
|
@ -59,9 +59,9 @@ describe('protocol module', () => {
|
||||||
|
|
||||||
it('throws error when scheme is already registered', (done) => {
|
it('throws error when scheme is already registered', (done) => {
|
||||||
protocol.registerStringProtocol(protocolName, emptyHandler, (error) => {
|
protocol.registerStringProtocol(protocolName, emptyHandler, (error) => {
|
||||||
assert.equal(error, null)
|
assert.strictEqual(error, null)
|
||||||
protocol.registerBufferProtocol(protocolName, emptyHandler, (error) => {
|
protocol.registerBufferProtocol(protocolName, emptyHandler, (error) => {
|
||||||
assert.notEqual(error, null)
|
assert.notStrictEqual(error, null)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -83,7 +83,7 @@ describe('protocol module', () => {
|
||||||
url: protocolName + '://fake-host',
|
url: protocolName + '://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, text)
|
assert.strictEqual(data, text)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -99,7 +99,7 @@ describe('protocol module', () => {
|
||||||
cache: false,
|
cache: false,
|
||||||
success: () => done('request succeeded but it should not'),
|
success: () => done('request succeeded but it should not'),
|
||||||
error: (xhr, errorType) => {
|
error: (xhr, errorType) => {
|
||||||
assert.equal(errorType, 'error')
|
assert.strictEqual(errorType, 'error')
|
||||||
return done()
|
return done()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -116,7 +116,7 @@ describe('protocol module', () => {
|
||||||
url: protocolName + '://fake-host',
|
url: protocolName + '://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, text)
|
assert.strictEqual(data, text)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -128,7 +128,7 @@ describe('protocol module', () => {
|
||||||
describe('protocol.unregisterProtocol', () => {
|
describe('protocol.unregisterProtocol', () => {
|
||||||
it('returns error when scheme does not exist', (done) => {
|
it('returns error when scheme does not exist', (done) => {
|
||||||
protocol.unregisterProtocol('not-exist', (error) => {
|
protocol.unregisterProtocol('not-exist', (error) => {
|
||||||
assert.notEqual(error, null)
|
assert.notStrictEqual(error, null)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -143,7 +143,7 @@ describe('protocol module', () => {
|
||||||
url: protocolName + '://fake-host',
|
url: protocolName + '://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, text)
|
assert.strictEqual(data, text)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -159,8 +159,8 @@ describe('protocol module', () => {
|
||||||
url: protocolName + '://fake-host',
|
url: protocolName + '://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data, status, request) => {
|
success: (data, status, request) => {
|
||||||
assert.equal(data, text)
|
assert.strictEqual(data, text)
|
||||||
assert.equal(request.getResponseHeader('Access-Control-Allow-Origin'), '*')
|
assert.strictEqual(request.getResponseHeader('Access-Control-Allow-Origin'), '*')
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -181,7 +181,7 @@ describe('protocol module', () => {
|
||||||
url: protocolName + '://fake-host',
|
url: protocolName + '://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, text)
|
assert.strictEqual(data, text)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -198,7 +198,7 @@ describe('protocol module', () => {
|
||||||
cache: false,
|
cache: false,
|
||||||
success: () => done('request succeeded but it should not'),
|
success: () => done('request succeeded but it should not'),
|
||||||
error: (xhr, errorType) => {
|
error: (xhr, errorType) => {
|
||||||
assert.equal(errorType, 'error')
|
assert.strictEqual(errorType, 'error')
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -216,7 +216,7 @@ describe('protocol module', () => {
|
||||||
url: protocolName + '://fake-host',
|
url: protocolName + '://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, text)
|
assert.strictEqual(data, text)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -232,8 +232,8 @@ describe('protocol module', () => {
|
||||||
url: protocolName + '://fake-host',
|
url: protocolName + '://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data, status, request) => {
|
success: (data, status, request) => {
|
||||||
assert.equal(data, text)
|
assert.strictEqual(data, text)
|
||||||
assert.equal(request.getResponseHeader('Access-Control-Allow-Origin'), '*')
|
assert.strictEqual(request.getResponseHeader('Access-Control-Allow-Origin'), '*')
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -254,7 +254,7 @@ describe('protocol module', () => {
|
||||||
url: protocolName + '://fake-host',
|
url: protocolName + '://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, text)
|
assert.strictEqual(data, text)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -271,7 +271,7 @@ describe('protocol module', () => {
|
||||||
cache: false,
|
cache: false,
|
||||||
success: () => done('request succeeded but it should not'),
|
success: () => done('request succeeded but it should not'),
|
||||||
error: (xhr, errorType) => {
|
error: (xhr, errorType) => {
|
||||||
assert.equal(errorType, 'error')
|
assert.strictEqual(errorType, 'error')
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -293,7 +293,7 @@ describe('protocol module', () => {
|
||||||
url: protocolName + '://fake-host',
|
url: protocolName + '://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, String(fileContent))
|
assert.strictEqual(data, String(fileContent))
|
||||||
return done()
|
return done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -309,8 +309,8 @@ describe('protocol module', () => {
|
||||||
url: protocolName + '://fake-host',
|
url: protocolName + '://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data, status, request) => {
|
success: (data, status, request) => {
|
||||||
assert.equal(data, String(fileContent))
|
assert.strictEqual(data, String(fileContent))
|
||||||
assert.equal(request.getResponseHeader('Access-Control-Allow-Origin'), '*')
|
assert.strictEqual(request.getResponseHeader('Access-Control-Allow-Origin'), '*')
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => {
|
error: (xhr, errorType, error) => {
|
||||||
|
@ -328,7 +328,7 @@ describe('protocol module', () => {
|
||||||
url: protocolName + '://fake-host',
|
url: protocolName + '://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, String(fileContent))
|
assert.strictEqual(data, String(fileContent))
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -344,7 +344,7 @@ describe('protocol module', () => {
|
||||||
url: protocolName + '://fake-host',
|
url: protocolName + '://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, String(normalContent))
|
assert.strictEqual(data, String(normalContent))
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -362,7 +362,7 @@ describe('protocol module', () => {
|
||||||
cache: false,
|
cache: false,
|
||||||
success: () => done('request succeeded but it should not'),
|
success: () => done('request succeeded but it should not'),
|
||||||
error: (xhr, errorType) => {
|
error: (xhr, errorType) => {
|
||||||
assert.equal(errorType, 'error')
|
assert.strictEqual(errorType, 'error')
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -378,7 +378,7 @@ describe('protocol module', () => {
|
||||||
cache: false,
|
cache: false,
|
||||||
success: () => done('request succeeded but it should not'),
|
success: () => done('request succeeded but it should not'),
|
||||||
error: (xhr, errorType) => {
|
error: (xhr, errorType) => {
|
||||||
assert.equal(errorType, 'error')
|
assert.strictEqual(errorType, 'error')
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -389,7 +389,7 @@ describe('protocol module', () => {
|
||||||
describe('protocol.registerHttpProtocol', () => {
|
describe('protocol.registerHttpProtocol', () => {
|
||||||
it('sends url as response', (done) => {
|
it('sends url as response', (done) => {
|
||||||
const server = http.createServer((req, res) => {
|
const server = http.createServer((req, res) => {
|
||||||
assert.notEqual(req.headers.accept, '')
|
assert.notStrictEqual(req.headers.accept, '')
|
||||||
res.end(text)
|
res.end(text)
|
||||||
server.close()
|
server.close()
|
||||||
})
|
})
|
||||||
|
@ -403,7 +403,7 @@ describe('protocol module', () => {
|
||||||
url: protocolName + '://fake-host',
|
url: protocolName + '://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, text)
|
assert.strictEqual(data, text)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -421,7 +421,7 @@ describe('protocol module', () => {
|
||||||
cache: false,
|
cache: false,
|
||||||
success: () => done('request succeeded but it should not'),
|
success: () => done('request succeeded but it should not'),
|
||||||
error: (xhr, errorType) => {
|
error: (xhr, errorType) => {
|
||||||
assert.equal(errorType, 'error')
|
assert.strictEqual(errorType, 'error')
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -439,7 +439,7 @@ describe('protocol module', () => {
|
||||||
done('request succeeded but it should not')
|
done('request succeeded but it should not')
|
||||||
},
|
},
|
||||||
error: (xhr, errorType) => {
|
error: (xhr, errorType) => {
|
||||||
assert.equal(errorType, 'error')
|
assert.strictEqual(errorType, 'error')
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -466,7 +466,7 @@ describe('protocol module', () => {
|
||||||
if (error) return done(error)
|
if (error) return done(error)
|
||||||
contents = webContents.create({})
|
contents = webContents.create({})
|
||||||
contents.on('did-finish-load', () => {
|
contents.on('did-finish-load', () => {
|
||||||
assert.equal(contents.getURL(), url)
|
assert.strictEqual(contents.getURL(), url)
|
||||||
server.close()
|
server.close()
|
||||||
contents.destroy()
|
contents.destroy()
|
||||||
done()
|
done()
|
||||||
|
@ -486,7 +486,7 @@ describe('protocol module', () => {
|
||||||
url: protocolName + '://fake-host',
|
url: protocolName + '://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, text)
|
assert.strictEqual(data, text)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => {
|
error: (xhr, errorType, error) => {
|
||||||
|
@ -504,8 +504,8 @@ describe('protocol module', () => {
|
||||||
url: protocolName + '://fake-host',
|
url: protocolName + '://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data, _, request) => {
|
success: (data, _, request) => {
|
||||||
assert.equal(request.status, 200)
|
assert.strictEqual(request.status, 200)
|
||||||
assert.equal(data, text)
|
assert.strictEqual(data, text)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => {
|
error: (xhr, errorType, error) => {
|
||||||
|
@ -528,9 +528,9 @@ describe('protocol module', () => {
|
||||||
url: protocolName + '://fake-host',
|
url: protocolName + '://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data, _, request) => {
|
success: (data, _, request) => {
|
||||||
assert.equal(request.status, 200)
|
assert.strictEqual(request.status, 200)
|
||||||
assert.equal(request.getResponseHeader('x-electron'), 'a,b')
|
assert.strictEqual(request.getResponseHeader('x-electron'), 'a,b')
|
||||||
assert.equal(data, text)
|
assert.strictEqual(data, text)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => {
|
error: (xhr, errorType, error) => {
|
||||||
|
@ -551,8 +551,8 @@ describe('protocol module', () => {
|
||||||
url: protocolName + '://fake-host',
|
url: protocolName + '://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data, _, request) => {
|
success: (data, _, request) => {
|
||||||
assert.equal(request.status, 204)
|
assert.strictEqual(request.status, 204)
|
||||||
assert.equal(data, undefined)
|
assert.strictEqual(data, undefined)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => {
|
error: (xhr, errorType, error) => {
|
||||||
|
@ -580,7 +580,7 @@ describe('protocol module', () => {
|
||||||
},
|
},
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data['x-return-headers'], 'yes')
|
assert.strictEqual(data['x-return-headers'], 'yes')
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => {
|
error: (xhr, errorType, error) => {
|
||||||
|
@ -594,35 +594,35 @@ describe('protocol module', () => {
|
||||||
describe('protocol.isProtocolHandled', () => {
|
describe('protocol.isProtocolHandled', () => {
|
||||||
it('returns true for about:', (done) => {
|
it('returns true for about:', (done) => {
|
||||||
protocol.isProtocolHandled('about', (result) => {
|
protocol.isProtocolHandled('about', (result) => {
|
||||||
assert.equal(result, true)
|
assert.strictEqual(result, true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns true for file:', (done) => {
|
it('returns true for file:', (done) => {
|
||||||
protocol.isProtocolHandled('file', (result) => {
|
protocol.isProtocolHandled('file', (result) => {
|
||||||
assert.equal(result, true)
|
assert.strictEqual(result, true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns true for http:', (done) => {
|
it('returns true for http:', (done) => {
|
||||||
protocol.isProtocolHandled('http', (result) => {
|
protocol.isProtocolHandled('http', (result) => {
|
||||||
assert.equal(result, true)
|
assert.strictEqual(result, true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns true for https:', (done) => {
|
it('returns true for https:', (done) => {
|
||||||
protocol.isProtocolHandled('https', (result) => {
|
protocol.isProtocolHandled('https', (result) => {
|
||||||
assert.equal(result, true)
|
assert.strictEqual(result, true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns false when scheme is not registered', (done) => {
|
it('returns false when scheme is not registered', (done) => {
|
||||||
protocol.isProtocolHandled('no-exist', (result) => {
|
protocol.isProtocolHandled('no-exist', (result) => {
|
||||||
assert.equal(result, false)
|
assert.strictEqual(result, false)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -630,9 +630,9 @@ describe('protocol module', () => {
|
||||||
it('returns true for custom protocol', (done) => {
|
it('returns true for custom protocol', (done) => {
|
||||||
const emptyHandler = (request, callback) => callback()
|
const emptyHandler = (request, callback) => callback()
|
||||||
protocol.registerStringProtocol(protocolName, emptyHandler, (error) => {
|
protocol.registerStringProtocol(protocolName, emptyHandler, (error) => {
|
||||||
assert.equal(error, null)
|
assert.strictEqual(error, null)
|
||||||
protocol.isProtocolHandled(protocolName, (result) => {
|
protocol.isProtocolHandled(protocolName, (result) => {
|
||||||
assert.equal(result, true)
|
assert.strictEqual(result, true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -641,9 +641,9 @@ describe('protocol module', () => {
|
||||||
it('returns true for intercepted protocol', (done) => {
|
it('returns true for intercepted protocol', (done) => {
|
||||||
const emptyHandler = (request, callback) => callback()
|
const emptyHandler = (request, callback) => callback()
|
||||||
protocol.interceptStringProtocol('http', emptyHandler, (error) => {
|
protocol.interceptStringProtocol('http', emptyHandler, (error) => {
|
||||||
assert.equal(error, null)
|
assert.strictEqual(error, null)
|
||||||
protocol.isProtocolHandled('http', (result) => {
|
protocol.isProtocolHandled('http', (result) => {
|
||||||
assert.equal(result, true)
|
assert.strictEqual(result, true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -654,9 +654,9 @@ describe('protocol module', () => {
|
||||||
const emptyHandler = (request, callback) => callback()
|
const emptyHandler = (request, callback) => callback()
|
||||||
it('throws error when scheme is already intercepted', (done) => {
|
it('throws error when scheme is already intercepted', (done) => {
|
||||||
protocol.interceptStringProtocol('http', emptyHandler, (error) => {
|
protocol.interceptStringProtocol('http', emptyHandler, (error) => {
|
||||||
assert.equal(error, null)
|
assert.strictEqual(error, null)
|
||||||
protocol.interceptBufferProtocol('http', emptyHandler, (error) => {
|
protocol.interceptBufferProtocol('http', emptyHandler, (error) => {
|
||||||
assert.notEqual(error, null)
|
assert.notStrictEqual(error, null)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -677,7 +677,7 @@ describe('protocol module', () => {
|
||||||
url: 'http://fake-host',
|
url: 'http://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, text)
|
assert.strictEqual(data, text)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -693,7 +693,7 @@ describe('protocol module', () => {
|
||||||
cache: false,
|
cache: false,
|
||||||
success: () => done('request succeeded but it should not'),
|
success: () => done('request succeeded but it should not'),
|
||||||
error: (xhr, errorType) => {
|
error: (xhr, errorType) => {
|
||||||
assert.equal(errorType, 'error')
|
assert.strictEqual(errorType, 'error')
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -710,7 +710,7 @@ describe('protocol module', () => {
|
||||||
url: 'http://fake-host',
|
url: 'http://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, text)
|
assert.strictEqual(data, text)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -731,8 +731,8 @@ describe('protocol module', () => {
|
||||||
url: 'http://fake-host',
|
url: 'http://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(typeof data, 'object')
|
assert.strictEqual(typeof data, 'object')
|
||||||
assert.equal(data.value, 1)
|
assert.strictEqual(data.value, 1)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -753,7 +753,7 @@ describe('protocol module', () => {
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: postData,
|
data: postData,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.deepEqual(qs.parse(data), postData)
|
assert.deepStrictEqual(qs.parse(data), postData)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -771,7 +771,7 @@ describe('protocol module', () => {
|
||||||
url: 'http://fake-host',
|
url: 'http://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, text)
|
assert.strictEqual(data, text)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -792,7 +792,7 @@ describe('protocol module', () => {
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: postData,
|
data: postData,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, $.param(postData))
|
assert.strictEqual(data, $.param(postData))
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -836,7 +836,7 @@ describe('protocol module', () => {
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: postData,
|
data: postData,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.deepEqual(qs.parse(data), postData)
|
assert.deepStrictEqual(qs.parse(data), postData)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => done(error)
|
error: (xhr, errorType, error) => done(error)
|
||||||
|
@ -848,7 +848,7 @@ describe('protocol module', () => {
|
||||||
it('can use custom session', (done) => {
|
it('can use custom session', (done) => {
|
||||||
const customSession = session.fromPartition('custom-ses', { cache: false })
|
const customSession = session.fromPartition('custom-ses', { cache: false })
|
||||||
customSession.webRequest.onBeforeRequest((details, callback) => {
|
customSession.webRequest.onBeforeRequest((details, callback) => {
|
||||||
assert.equal(details.url, 'http://fake-host/')
|
assert.strictEqual(details.url, 'http://fake-host/')
|
||||||
callback({ cancel: true })
|
callback({ cancel: true })
|
||||||
})
|
})
|
||||||
const handler = (request, callback) => {
|
const handler = (request, callback) => {
|
||||||
|
@ -878,7 +878,7 @@ describe('protocol module', () => {
|
||||||
url: 'http://fake-host',
|
url: 'http://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, text)
|
assert.strictEqual(data, text)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => {
|
error: (xhr, errorType, error) => {
|
||||||
|
@ -900,7 +900,7 @@ describe('protocol module', () => {
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: postData,
|
data: postData,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.deepEqual(qs.parse(data), postData)
|
assert.deepStrictEqual(qs.parse(data), postData)
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => {
|
error: (xhr, errorType, error) => {
|
||||||
|
@ -923,7 +923,7 @@ describe('protocol module', () => {
|
||||||
})
|
})
|
||||||
}, 300)
|
}, 300)
|
||||||
} else {
|
} else {
|
||||||
assert.equal(request.url.indexOf('http://fake-redirect'), 0)
|
assert.strictEqual(request.url.indexOf('http://fake-redirect'), 0)
|
||||||
callback(getStream(1, 'redirect'))
|
callback(getStream(1, 'redirect'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -933,7 +933,7 @@ describe('protocol module', () => {
|
||||||
url: 'http://fake-host',
|
url: 'http://fake-host',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, 'redirect')
|
assert.strictEqual(data, 'redirect')
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType, error) => {
|
error: (xhr, errorType, error) => {
|
||||||
|
@ -947,14 +947,14 @@ describe('protocol module', () => {
|
||||||
describe('protocol.uninterceptProtocol', () => {
|
describe('protocol.uninterceptProtocol', () => {
|
||||||
it('returns error when scheme does not exist', (done) => {
|
it('returns error when scheme does not exist', (done) => {
|
||||||
protocol.uninterceptProtocol('not-exist', (error) => {
|
protocol.uninterceptProtocol('not-exist', (error) => {
|
||||||
assert.notEqual(error, null)
|
assert.notStrictEqual(error, null)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns error when scheme is not intercepted', (done) => {
|
it('returns error when scheme is not intercepted', (done) => {
|
||||||
protocol.uninterceptProtocol('http', (error) => {
|
protocol.uninterceptProtocol('http', (error) => {
|
||||||
assert.notEqual(error, null)
|
assert.notStrictEqual(error, null)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -11,7 +11,7 @@ const comparePaths = (path1, path2) => {
|
||||||
path1 = path1.toLowerCase()
|
path1 = path1.toLowerCase()
|
||||||
path2 = path2.toLowerCase()
|
path2 = path2.toLowerCase()
|
||||||
}
|
}
|
||||||
assert.equal(path1, path2)
|
assert.strictEqual(path1, path2)
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('remote module', () => {
|
describe('remote module', () => {
|
||||||
|
@ -25,23 +25,23 @@ describe('remote module', () => {
|
||||||
it('should returns same object for the same module', () => {
|
it('should returns same object for the same module', () => {
|
||||||
const dialog1 = remote.require('electron')
|
const dialog1 = remote.require('electron')
|
||||||
const dialog2 = remote.require('electron')
|
const dialog2 = remote.require('electron')
|
||||||
assert.equal(dialog1, dialog2)
|
assert.strictEqual(dialog1, dialog2)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should work when object contains id property', () => {
|
it('should work when object contains id property', () => {
|
||||||
const a = remote.require(path.join(fixtures, 'module', 'id.js'))
|
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', () => {
|
it('should work when object has no prototype', () => {
|
||||||
const a = remote.require(path.join(fixtures, 'module', 'no-prototype.js'))
|
const a = remote.require(path.join(fixtures, 'module', 'no-prototype.js'))
|
||||||
assert.equal(a.foo.constructor.name, '')
|
assert.strictEqual(a.foo.constructor.name, '')
|
||||||
assert.equal(a.foo.bar, 'baz')
|
assert.strictEqual(a.foo.bar, 'baz')
|
||||||
assert.equal(a.foo.baz, false)
|
assert.strictEqual(a.foo.baz, false)
|
||||||
assert.equal(a.bar, 1234)
|
assert.strictEqual(a.bar, 1234)
|
||||||
assert.equal(a.anonymous.constructor.name, '')
|
assert.strictEqual(a.anonymous.constructor.name, '')
|
||||||
assert.equal(a.getConstructorName(Object.create(null)), '')
|
assert.strictEqual(a.getConstructorName(Object.create(null)), '')
|
||||||
assert.equal(a.getConstructorName(new (class {})()), '')
|
assert.strictEqual(a.getConstructorName(new (class {})()), '')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should search module from the user app', () => {
|
it('should search module from the user app', () => {
|
||||||
|
@ -51,41 +51,41 @@ describe('remote module', () => {
|
||||||
|
|
||||||
it('should work with function properties', () => {
|
it('should work with function properties', () => {
|
||||||
let a = remote.require(path.join(fixtures, 'module', 'export-function-with-properties.js'))
|
let a = remote.require(path.join(fixtures, 'module', 'export-function-with-properties.js'))
|
||||||
assert.equal(typeof a, 'function')
|
assert.strictEqual(typeof a, 'function')
|
||||||
assert.equal(a.bar, 'baz')
|
assert.strictEqual(a.bar, 'baz')
|
||||||
|
|
||||||
a = remote.require(path.join(fixtures, 'module', 'function-with-properties.js'))
|
a = remote.require(path.join(fixtures, 'module', 'function-with-properties.js'))
|
||||||
assert.equal(typeof a, 'object')
|
assert.strictEqual(typeof a, 'object')
|
||||||
assert.equal(a.foo(), 'hello')
|
assert.strictEqual(a.foo(), 'hello')
|
||||||
assert.equal(a.foo.bar, 'baz')
|
assert.strictEqual(a.foo.bar, 'baz')
|
||||||
assert.equal(a.foo.nested.prop, 'yes')
|
assert.strictEqual(a.foo.nested.prop, 'yes')
|
||||||
assert.equal(a.foo.method1(), 'world')
|
assert.strictEqual(a.foo.method1(), 'world')
|
||||||
assert.equal(a.foo.method1.prop1(), 123)
|
assert.strictEqual(a.foo.method1.prop1(), 123)
|
||||||
|
|
||||||
assert.ok(Object.keys(a.foo).includes('bar'))
|
assert.ok(Object.keys(a.foo).includes('bar'))
|
||||||
assert.ok(Object.keys(a.foo).includes('nested'))
|
assert.ok(Object.keys(a.foo).includes('nested'))
|
||||||
assert.ok(Object.keys(a.foo).includes('method1'))
|
assert.ok(Object.keys(a.foo).includes('method1'))
|
||||||
|
|
||||||
a = remote.require(path.join(fixtures, 'module', 'function-with-missing-properties.js')).setup()
|
a = remote.require(path.join(fixtures, 'module', 'function-with-missing-properties.js')).setup()
|
||||||
assert.equal(a.bar(), true)
|
assert.strictEqual(a.bar(), true)
|
||||||
assert.equal(a.bar.baz, undefined)
|
assert.strictEqual(a.bar.baz, undefined)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should work with static class members', () => {
|
it('should work with static class members', () => {
|
||||||
const a = remote.require(path.join(fixtures, 'module', 'remote-static.js'))
|
const a = remote.require(path.join(fixtures, 'module', 'remote-static.js'))
|
||||||
assert.equal(typeof a.Foo, 'function')
|
assert.strictEqual(typeof a.Foo, 'function')
|
||||||
assert.equal(a.Foo.foo(), 3)
|
assert.strictEqual(a.Foo.foo(), 3)
|
||||||
assert.equal(a.Foo.bar, 'baz')
|
assert.strictEqual(a.Foo.bar, 'baz')
|
||||||
|
|
||||||
const foo = new a.Foo()
|
const foo = new a.Foo()
|
||||||
assert.equal(foo.baz(), 123)
|
assert.strictEqual(foo.baz(), 123)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('includes the length of functions specified as arguments', () => {
|
it('includes the length of functions specified as arguments', () => {
|
||||||
const a = remote.require(path.join(fixtures, 'module', 'function-with-args.js'))
|
const a = remote.require(path.join(fixtures, 'module', 'function-with-args.js'))
|
||||||
assert.equal(a((a, b, c, d, f) => {}), 5)
|
assert.strictEqual(a((a, b, c, d, f) => {}), 5)
|
||||||
assert.equal(a((a) => {}), 1)
|
assert.strictEqual(a((a) => {}), 1)
|
||||||
assert.equal(a((...args) => {}), 0)
|
assert.strictEqual(a((...args) => {}), 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('handles circular references in arrays and objects', () => {
|
it('handles circular references in arrays and objects', () => {
|
||||||
|
@ -94,7 +94,7 @@ describe('remote module', () => {
|
||||||
let arrayA = ['foo']
|
let arrayA = ['foo']
|
||||||
const arrayB = [arrayA, 'bar']
|
const arrayB = [arrayA, 'bar']
|
||||||
arrayA.push(arrayB)
|
arrayA.push(arrayB)
|
||||||
assert.deepEqual(a.returnArgs(arrayA, arrayB), [
|
assert.deepStrictEqual(a.returnArgs(arrayA, arrayB), [
|
||||||
['foo', [null, 'bar']],
|
['foo', [null, 'bar']],
|
||||||
[['foo', null], 'bar']
|
[['foo', null], 'bar']
|
||||||
])
|
])
|
||||||
|
@ -102,40 +102,40 @@ describe('remote module', () => {
|
||||||
let objectA = { foo: 'bar' }
|
let objectA = { foo: 'bar' }
|
||||||
const objectB = { baz: objectA }
|
const objectB = { baz: objectA }
|
||||||
objectA.objectB = objectB
|
objectA.objectB = objectB
|
||||||
assert.deepEqual(a.returnArgs(objectA, objectB), [
|
assert.deepStrictEqual(a.returnArgs(objectA, objectB), [
|
||||||
{ foo: 'bar', objectB: { baz: null } },
|
{ foo: 'bar', objectB: { baz: null } },
|
||||||
{ baz: { foo: 'bar', objectB: null } }
|
{ baz: { foo: 'bar', objectB: null } }
|
||||||
])
|
])
|
||||||
|
|
||||||
arrayA = [1, 2, 3]
|
arrayA = [1, 2, 3]
|
||||||
assert.deepEqual(a.returnArgs({foo: arrayA}, {bar: arrayA}), [
|
assert.deepStrictEqual(a.returnArgs({ foo: arrayA }, { bar: arrayA }), [
|
||||||
{ foo: [1, 2, 3] },
|
{ foo: [1, 2, 3] },
|
||||||
{ bar: [1, 2, 3] }
|
{ bar: [1, 2, 3] }
|
||||||
])
|
])
|
||||||
|
|
||||||
objectA = { foo: 'bar' }
|
objectA = { foo: 'bar' }
|
||||||
assert.deepEqual(a.returnArgs({foo: objectA}, {bar: objectA}), [
|
assert.deepStrictEqual(a.returnArgs({ foo: objectA }, { bar: objectA }), [
|
||||||
{ foo: { foo: 'bar' } },
|
{ foo: { foo: 'bar' } },
|
||||||
{ bar: { foo: 'bar' } }
|
{ bar: { foo: 'bar' } }
|
||||||
])
|
])
|
||||||
|
|
||||||
arrayA = []
|
arrayA = []
|
||||||
arrayA.push(arrayA)
|
arrayA.push(arrayA)
|
||||||
assert.deepEqual(a.returnArgs(arrayA), [
|
assert.deepStrictEqual(a.returnArgs(arrayA), [
|
||||||
[null]
|
[null]
|
||||||
])
|
])
|
||||||
|
|
||||||
objectA = {}
|
objectA = {}
|
||||||
objectA.foo = objectA
|
objectA.foo = objectA
|
||||||
objectA.bar = 'baz'
|
objectA.bar = 'baz'
|
||||||
assert.deepEqual(a.returnArgs(objectA), [
|
assert.deepStrictEqual(a.returnArgs(objectA), [
|
||||||
{ foo: null, bar: 'baz' }
|
{ foo: null, bar: 'baz' }
|
||||||
])
|
])
|
||||||
|
|
||||||
objectA = {}
|
objectA = {}
|
||||||
objectA.foo = { bar: objectA }
|
objectA.foo = { bar: objectA }
|
||||||
objectA.bar = 'baz'
|
objectA.bar = 'baz'
|
||||||
assert.deepEqual(a.returnArgs(objectA), [
|
assert.deepStrictEqual(a.returnArgs(objectA), [
|
||||||
{ foo: { bar: null }, bar: 'baz' }
|
{ foo: { bar: null }, bar: 'baz' }
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
@ -146,16 +146,16 @@ describe('remote module', () => {
|
||||||
const buf = Buffer.from('test')
|
const buf = Buffer.from('test')
|
||||||
const call = remote.require(path.join(fixtures, 'module', 'call.js'))
|
const call = remote.require(path.join(fixtures, 'module', 'call.js'))
|
||||||
const result = call.call(remote.createFunctionWithReturnValue(buf))
|
const result = call.call(remote.createFunctionWithReturnValue(buf))
|
||||||
assert.equal(result.constructor.name, 'Buffer')
|
assert.strictEqual(result.constructor.name, 'Buffer')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('remote modules', () => {
|
describe('remote modules', () => {
|
||||||
it('includes browser process modules as properties', () => {
|
it('includes browser process modules as properties', () => {
|
||||||
assert.equal(typeof remote.app.getPath, 'function')
|
assert.strictEqual(typeof remote.app.getPath, 'function')
|
||||||
assert.equal(typeof remote.webContents.getFocusedWebContents, 'function')
|
assert.strictEqual(typeof remote.webContents.getFocusedWebContents, 'function')
|
||||||
assert.equal(typeof remote.clipboard.readText, 'function')
|
assert.strictEqual(typeof remote.clipboard.readText, 'function')
|
||||||
assert.equal(typeof remote.shell.openExternal, 'function')
|
assert.strictEqual(typeof remote.shell.openExternal, 'function')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns toString() of original function via toString()', () => {
|
it('returns toString() of original function via toString()', () => {
|
||||||
|
@ -163,29 +163,29 @@ describe('remote module', () => {
|
||||||
assert(readText.toString().startsWith('function'))
|
assert(readText.toString().startsWith('function'))
|
||||||
|
|
||||||
const { functionWithToStringProperty } = remote.require(path.join(fixtures, 'module', 'to-string-non-function.js'))
|
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', () => {
|
describe('remote object in renderer', () => {
|
||||||
it('can change its properties', () => {
|
it('can change its properties', () => {
|
||||||
const property = remote.require(path.join(fixtures, 'module', 'property.js'))
|
const property = remote.require(path.join(fixtures, 'module', 'property.js'))
|
||||||
assert.equal(property.property, 1127)
|
assert.strictEqual(property.property, 1127)
|
||||||
|
|
||||||
property.property = null
|
property.property = null
|
||||||
assert.equal(property.property, null)
|
assert.strictEqual(property.property, null)
|
||||||
property.property = undefined
|
property.property = undefined
|
||||||
assert.equal(property.property, undefined)
|
assert.strictEqual(property.property, undefined)
|
||||||
property.property = 1007
|
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'
|
property.func.property = 'bar'
|
||||||
assert.equal(property.getFunctionProperty(), 'bar-browser')
|
assert.strictEqual(property.getFunctionProperty(), 'bar-browser')
|
||||||
property.func.property = 'foo' // revert back
|
property.func.property = 'foo' // revert back
|
||||||
|
|
||||||
const property2 = remote.require(path.join(fixtures, 'module', 'property.js'))
|
const property2 = remote.require(path.join(fixtures, 'module', 'property.js'))
|
||||||
assert.equal(property2.property, 1007)
|
assert.strictEqual(property2.property, 1007)
|
||||||
property.property = 1127
|
property.property = 1127
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -213,17 +213,17 @@ describe('remote module', () => {
|
||||||
it('can construct an object from its member', () => {
|
it('can construct an object from its member', () => {
|
||||||
const call = remote.require(path.join(fixtures, 'module', 'call.js'))
|
const call = remote.require(path.join(fixtures, 'module', 'call.js'))
|
||||||
const obj = new call.constructor()
|
const obj = new call.constructor()
|
||||||
assert.equal(obj.test, 'test')
|
assert.strictEqual(obj.test, 'test')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can reassign and delete its member functions', () => {
|
it('can reassign and delete its member functions', () => {
|
||||||
const remoteFunctions = remote.require(path.join(fixtures, 'module', 'function.js'))
|
const remoteFunctions = remote.require(path.join(fixtures, 'module', 'function.js'))
|
||||||
assert.equal(remoteFunctions.aFunction(), 1127)
|
assert.strictEqual(remoteFunctions.aFunction(), 1127)
|
||||||
|
|
||||||
remoteFunctions.aFunction = () => { return 1234 }
|
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', () => {
|
it('is referenced by its members', () => {
|
||||||
|
@ -249,13 +249,13 @@ describe('remote module', () => {
|
||||||
|
|
||||||
it('keeps its constructor name for objects', () => {
|
it('keeps its constructor name for objects', () => {
|
||||||
const buf = Buffer.from('test')
|
const buf = Buffer.from('test')
|
||||||
assert.equal(printName.print(buf), 'Buffer')
|
assert.strictEqual(printName.print(buf), 'Buffer')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('supports instanceof Date', () => {
|
it('supports instanceof Date', () => {
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
assert.equal(printName.print(now), 'Date')
|
assert.strictEqual(printName.print(now), 'Date')
|
||||||
assert.deepEqual(printName.echo(now), now)
|
assert.deepStrictEqual(printName.echo(now), now)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('supports instanceof Buffer', () => {
|
it('supports instanceof Buffer', () => {
|
||||||
|
@ -274,89 +274,89 @@ describe('remote module', () => {
|
||||||
const view = new DataView(buffer)
|
const view = new DataView(buffer)
|
||||||
|
|
||||||
view.setFloat64(0, Math.PI)
|
view.setFloat64(0, Math.PI)
|
||||||
assert.deepEqual(printName.echo(buffer), buffer)
|
assert.deepStrictEqual(printName.echo(buffer), buffer)
|
||||||
assert.equal(printName.print(buffer), 'ArrayBuffer')
|
assert.strictEqual(printName.print(buffer), 'ArrayBuffer')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('supports instanceof Int8Array', () => {
|
it('supports instanceof Int8Array', () => {
|
||||||
const values = [1, 2, 3, 4]
|
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)
|
const int8values = new Int8Array(values)
|
||||||
assert.deepEqual(printName.typedArray('Int8Array', int8values), int8values)
|
assert.deepStrictEqual(printName.typedArray('Int8Array', int8values), int8values)
|
||||||
assert.equal(printName.print(int8values), 'Int8Array')
|
assert.strictEqual(printName.print(int8values), 'Int8Array')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('supports instanceof Uint8Array', () => {
|
it('supports instanceof Uint8Array', () => {
|
||||||
const values = [1, 2, 3, 4]
|
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)
|
const uint8values = new Uint8Array(values)
|
||||||
assert.deepEqual(printName.typedArray('Uint8Array', uint8values), uint8values)
|
assert.deepStrictEqual(printName.typedArray('Uint8Array', uint8values), uint8values)
|
||||||
assert.equal(printName.print(uint8values), 'Uint8Array')
|
assert.strictEqual(printName.print(uint8values), 'Uint8Array')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('supports instanceof Uint8ClampedArray', () => {
|
it('supports instanceof Uint8ClampedArray', () => {
|
||||||
const values = [1, 2, 3, 4]
|
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)
|
const uint8values = new Uint8ClampedArray(values)
|
||||||
assert.deepEqual(printName.typedArray('Uint8ClampedArray', uint8values), uint8values)
|
assert.deepStrictEqual(printName.typedArray('Uint8ClampedArray', uint8values), uint8values)
|
||||||
assert.equal(printName.print(uint8values), 'Uint8ClampedArray')
|
assert.strictEqual(printName.print(uint8values), 'Uint8ClampedArray')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('supports instanceof Int16Array', () => {
|
it('supports instanceof Int16Array', () => {
|
||||||
const values = [0x1234, 0x2345, 0x3456, 0x4567]
|
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)
|
const int16values = new Int16Array(values)
|
||||||
assert.deepEqual(printName.typedArray('Int16Array', int16values), int16values)
|
assert.deepStrictEqual(printName.typedArray('Int16Array', int16values), int16values)
|
||||||
assert.equal(printName.print(int16values), 'Int16Array')
|
assert.strictEqual(printName.print(int16values), 'Int16Array')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('supports instanceof Uint16Array', () => {
|
it('supports instanceof Uint16Array', () => {
|
||||||
const values = [0x1234, 0x2345, 0x3456, 0x4567]
|
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)
|
const uint16values = new Uint16Array(values)
|
||||||
assert.deepEqual(printName.typedArray('Uint16Array', uint16values), uint16values)
|
assert.deepStrictEqual(printName.typedArray('Uint16Array', uint16values), uint16values)
|
||||||
assert.equal(printName.print(uint16values), 'Uint16Array')
|
assert.strictEqual(printName.print(uint16values), 'Uint16Array')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('supports instanceof Int32Array', () => {
|
it('supports instanceof Int32Array', () => {
|
||||||
const values = [0x12345678, 0x23456789]
|
const values = [0x12345678, 0x23456789]
|
||||||
assert.deepEqual(printName.typedArray('Int32Array', values), values)
|
assert.deepStrictEqual(printName.typedArray('Int32Array', values), values)
|
||||||
|
|
||||||
const int32values = new Int32Array(values)
|
const int32values = new Int32Array(values)
|
||||||
assert.deepEqual(printName.typedArray('Int32Array', int32values), int32values)
|
assert.deepStrictEqual(printName.typedArray('Int32Array', int32values), int32values)
|
||||||
assert.equal(printName.print(int32values), 'Int32Array')
|
assert.strictEqual(printName.print(int32values), 'Int32Array')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('supports instanceof Uint32Array', () => {
|
it('supports instanceof Uint32Array', () => {
|
||||||
const values = [0x12345678, 0x23456789]
|
const values = [0x12345678, 0x23456789]
|
||||||
assert.deepEqual(printName.typedArray('Uint32Array', values), values)
|
assert.deepStrictEqual(printName.typedArray('Uint32Array', values), values)
|
||||||
|
|
||||||
const uint32values = new Uint32Array(values)
|
const uint32values = new Uint32Array(values)
|
||||||
assert.deepEqual(printName.typedArray('Uint32Array', uint32values), uint32values)
|
assert.deepStrictEqual(printName.typedArray('Uint32Array', uint32values), uint32values)
|
||||||
assert.equal(printName.print(uint32values), 'Uint32Array')
|
assert.strictEqual(printName.print(uint32values), 'Uint32Array')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('supports instanceof Float32Array', () => {
|
it('supports instanceof Float32Array', () => {
|
||||||
const values = [0.5, 1.0, 1.5]
|
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()
|
const float32values = new Float32Array()
|
||||||
assert.deepEqual(printName.typedArray('Float32Array', float32values), float32values)
|
assert.deepStrictEqual(printName.typedArray('Float32Array', float32values), float32values)
|
||||||
assert.equal(printName.print(float32values), 'Float32Array')
|
assert.strictEqual(printName.print(float32values), 'Float32Array')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('supports instanceof Float64Array', () => {
|
it('supports instanceof Float64Array', () => {
|
||||||
const values = [0.5, 1.0, 1.5]
|
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])
|
const float64values = new Float64Array([0.5, 1.0, 1.5])
|
||||||
assert.deepEqual(printName.typedArray('Float64Array', float64values), float64values)
|
assert.deepStrictEqual(printName.typedArray('Float64Array', float64values), float64values)
|
||||||
assert.equal(printName.print(float64values), 'Float64Array')
|
assert.strictEqual(printName.print(float64values), 'Float64Array')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -364,7 +364,7 @@ describe('remote module', () => {
|
||||||
it('can be used as promise in each side', (done) => {
|
it('can be used as promise in each side', (done) => {
|
||||||
const promise = remote.require(path.join(fixtures, 'module', 'promise.js'))
|
const promise = remote.require(path.join(fixtures, 'module', 'promise.js'))
|
||||||
promise.twicePromise(Promise.resolve(1234)).then((value) => {
|
promise.twicePromise(Promise.resolve(1234)).then((value) => {
|
||||||
assert.equal(value, 2468)
|
assert.strictEqual(value, 2468)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -372,7 +372,7 @@ describe('remote module', () => {
|
||||||
it('handles rejections via catch(onRejected)', (done) => {
|
it('handles rejections via catch(onRejected)', (done) => {
|
||||||
const promise = remote.require(path.join(fixtures, 'module', 'rejected-promise.js'))
|
const promise = remote.require(path.join(fixtures, 'module', 'rejected-promise.js'))
|
||||||
promise.reject(Promise.resolve(1234)).catch((error) => {
|
promise.reject(Promise.resolve(1234)).catch((error) => {
|
||||||
assert.equal(error.message, 'rejected')
|
assert.strictEqual(error.message, 'rejected')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -380,7 +380,7 @@ describe('remote module', () => {
|
||||||
it('handles rejections via then(onFulfilled, onRejected)', (done) => {
|
it('handles rejections via then(onFulfilled, onRejected)', (done) => {
|
||||||
const promise = remote.require(path.join(fixtures, 'module', 'rejected-promise.js'))
|
const promise = remote.require(path.join(fixtures, 'module', 'rejected-promise.js'))
|
||||||
promise.reject(Promise.resolve(1234)).then(() => {}, (error) => {
|
promise.reject(Promise.resolve(1234)).then(() => {}, (error) => {
|
||||||
assert.equal(error.message, 'rejected')
|
assert.strictEqual(error.message, 'rejected')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -394,7 +394,7 @@ describe('remote module', () => {
|
||||||
promise.reject().then(() => {
|
promise.reject().then(() => {
|
||||||
done(new Error('Promise was not rejected'))
|
done(new Error('Promise was not rejected'))
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
assert.equal(error.message, 'rejected')
|
assert.strictEqual(error.message, 'rejected')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -402,7 +402,7 @@ describe('remote module', () => {
|
||||||
it('emits unhandled rejection events in the renderer process', (done) => {
|
it('emits unhandled rejection events in the renderer process', (done) => {
|
||||||
window.addEventListener('unhandledrejection', function (event) {
|
window.addEventListener('unhandledrejection', function (event) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
assert.equal(event.reason.message, 'rejected')
|
assert.strictEqual(event.reason.message, 'rejected')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -427,17 +427,17 @@ describe('remote module', () => {
|
||||||
let derived = cl.derived
|
let derived = cl.derived
|
||||||
|
|
||||||
it('can get methods', () => {
|
it('can get methods', () => {
|
||||||
assert.equal(base.method(), 'method')
|
assert.strictEqual(base.method(), 'method')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can get properties', () => {
|
it('can get properties', () => {
|
||||||
assert.equal(base.readonly, 'readonly')
|
assert.strictEqual(base.readonly, 'readonly')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can change properties', () => {
|
it('can change properties', () => {
|
||||||
assert.equal(base.value, 'old')
|
assert.strictEqual(base.value, 'old')
|
||||||
base.value = 'new'
|
base.value = 'new'
|
||||||
assert.equal(base.value, 'new')
|
assert.strictEqual(base.value, 'new')
|
||||||
base.value = 'old'
|
base.value = 'old'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -447,8 +447,8 @@ describe('remote module', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('keeps prototype chain in derived class', () => {
|
it('keeps prototype chain in derived class', () => {
|
||||||
assert.equal(derived.method(), 'method')
|
assert.strictEqual(derived.method(), 'method')
|
||||||
assert.equal(derived.readonly, 'readonly')
|
assert.strictEqual(derived.readonly, 'readonly')
|
||||||
assert(!derived.hasOwnProperty('method'))
|
assert(!derived.hasOwnProperty('method'))
|
||||||
let proto = Object.getPrototypeOf(derived)
|
let proto = Object.getPrototypeOf(derived)
|
||||||
assert(!proto.hasOwnProperty('method'))
|
assert(!proto.hasOwnProperty('method'))
|
||||||
|
@ -459,7 +459,7 @@ describe('remote module', () => {
|
||||||
let method = derived.method
|
let method = derived.method
|
||||||
derived = null
|
derived = null
|
||||||
global.gc()
|
global.gc()
|
||||||
assert.equal(method(), 'method')
|
assert.strictEqual(method(), 'method')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -480,7 +480,7 @@ describe('remote module', () => {
|
||||||
throwFunction(err)
|
throwFunction(err)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
assert.ok(error.from)
|
assert.ok(error.from)
|
||||||
assert.deepEqual(error.cause, err)
|
assert.deepStrictEqual(error.cause, err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -5,15 +5,15 @@ describe('screen module', () => {
|
||||||
describe('screen.getCursorScreenPoint()', () => {
|
describe('screen.getCursorScreenPoint()', () => {
|
||||||
it('returns a point object', () => {
|
it('returns a point object', () => {
|
||||||
const point = screen.getCursorScreenPoint()
|
const point = screen.getCursorScreenPoint()
|
||||||
assert.equal(typeof point.x, 'number')
|
assert.strictEqual(typeof point.x, 'number')
|
||||||
assert.equal(typeof point.y, 'number')
|
assert.strictEqual(typeof point.y, 'number')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('screen.getPrimaryDisplay()', () => {
|
describe('screen.getPrimaryDisplay()', () => {
|
||||||
it('returns a display object', () => {
|
it('returns a display object', () => {
|
||||||
const display = screen.getPrimaryDisplay()
|
const display = screen.getPrimaryDisplay()
|
||||||
assert.equal(typeof display.scaleFactor, 'number')
|
assert.strictEqual(typeof display.scaleFactor, 'number')
|
||||||
assert(display.size.width > 0)
|
assert(display.size.width > 0)
|
||||||
assert(display.size.height > 0)
|
assert(display.size.height > 0)
|
||||||
})
|
})
|
||||||
|
|
|
@ -40,13 +40,13 @@ describe('session module', () => {
|
||||||
|
|
||||||
describe('session.defaultSession', () => {
|
describe('session.defaultSession', () => {
|
||||||
it('returns the default session', () => {
|
it('returns the default session', () => {
|
||||||
assert.equal(session.defaultSession, session.fromPartition(''))
|
assert.strictEqual(session.defaultSession, session.fromPartition(''))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('session.fromPartition(partition, options)', () => {
|
describe('session.fromPartition(partition, options)', () => {
|
||||||
it('returns existing session with same partition', () => {
|
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', () => {
|
it('created session is ref-counted', () => {
|
||||||
|
@ -54,10 +54,10 @@ describe('session module', () => {
|
||||||
const userAgent = 'test-agent'
|
const userAgent = 'test-agent'
|
||||||
const ses1 = session.fromPartition(partition)
|
const ses1 = session.fromPartition(partition)
|
||||||
ses1.setUserAgent(userAgent)
|
ses1.setUserAgent(userAgent)
|
||||||
assert.equal(ses1.getUserAgent(), userAgent)
|
assert.strictEqual(ses1.getUserAgent(), userAgent)
|
||||||
ses1.destroy()
|
ses1.destroy()
|
||||||
const ses2 = session.fromPartition(partition)
|
const ses2 = session.fromPartition(partition)
|
||||||
assert.notEqual(ses2.getUserAgent(), userAgent)
|
assert.notStrictEqual(ses2.getUserAgent(), userAgent)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ describe('session module', () => {
|
||||||
value: '1'
|
value: '1'
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
assert(error, 'Should have an error')
|
assert(error, 'Should have an error')
|
||||||
assert.equal(error.message, 'Setting cookie failed')
|
assert.strictEqual(error.message, 'Setting cookie failed')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -157,10 +157,10 @@ describe('session module', () => {
|
||||||
if (error) return done(error)
|
if (error) return done(error)
|
||||||
session.defaultSession.cookies.get({ url: origin }, (error, list) => {
|
session.defaultSession.cookies.get({ url: origin }, (error, list) => {
|
||||||
if (error) return done(error)
|
if (error) return done(error)
|
||||||
assert.equal(list.length, 1)
|
assert.strictEqual(list.length, 1)
|
||||||
assert.equal(list[0].name, 'custom')
|
assert.strictEqual(list[0].name, 'custom')
|
||||||
assert.equal(list[0].value, '1')
|
assert.strictEqual(list[0].value, '1')
|
||||||
assert.equal(list[0].domain, 'fake-host')
|
assert.strictEqual(list[0].domain, 'fake-host')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -170,16 +170,16 @@ describe('session module', () => {
|
||||||
const { cookies } = session.fromPartition('cookies-changed')
|
const { cookies } = session.fromPartition('cookies-changed')
|
||||||
|
|
||||||
cookies.once('changed', (event, cookie, cause, removed) => {
|
cookies.once('changed', (event, cookie, cause, removed) => {
|
||||||
assert.equal(cookie.name, 'foo')
|
assert.strictEqual(cookie.name, 'foo')
|
||||||
assert.equal(cookie.value, 'bar')
|
assert.strictEqual(cookie.value, 'bar')
|
||||||
assert.equal(cause, 'explicit')
|
assert.strictEqual(cause, 'explicit')
|
||||||
assert.equal(removed, false)
|
assert.strictEqual(removed, false)
|
||||||
|
|
||||||
cookies.once('changed', (event, cookie, cause, removed) => {
|
cookies.once('changed', (event, cookie, cause, removed) => {
|
||||||
assert.equal(cookie.name, 'foo')
|
assert.strictEqual(cookie.name, 'foo')
|
||||||
assert.equal(cookie.value, 'bar')
|
assert.strictEqual(cookie.value, 'bar')
|
||||||
assert.equal(cause, 'explicit')
|
assert.strictEqual(cause, 'explicit')
|
||||||
assert.equal(removed, true)
|
assert.strictEqual(removed, true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ describe('session module', () => {
|
||||||
it('clears localstorage data', (done) => {
|
it('clears localstorage data', (done) => {
|
||||||
ipcMain.on('count', (event, count) => {
|
ipcMain.on('count', (event, count) => {
|
||||||
ipcMain.removeAllListeners('count')
|
ipcMain.removeAllListeners('count')
|
||||||
assert.equal(count, 0)
|
assert.strictEqual(count, 0)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.loadFile(path.join(fixtures, 'api', 'localstorage.html'))
|
w.loadFile(path.join(fixtures, 'api', 'localstorage.html'))
|
||||||
|
@ -265,9 +265,9 @@ describe('session module', () => {
|
||||||
ipcRenderer.sendSync('set-download-option', false, true)
|
ipcRenderer.sendSync('set-download-option', false, true)
|
||||||
w.loadURL(url)
|
w.loadURL(url)
|
||||||
ipcRenderer.once('download-error', (event, downloadUrl, filename, error) => {
|
ipcRenderer.once('download-error', (event, downloadUrl, filename, error) => {
|
||||||
assert.equal(downloadUrl, url)
|
assert.strictEqual(downloadUrl, url)
|
||||||
assert.equal(filename, 'mockFile.txt')
|
assert.strictEqual(filename, 'mockFile.txt')
|
||||||
assert.equal(error, 'Object has been destroyed')
|
assert.strictEqual(error, 'Object has been destroyed')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -296,19 +296,19 @@ describe('session module', () => {
|
||||||
const assertDownload = (event, state, url, mimeType,
|
const assertDownload = (event, state, url, mimeType,
|
||||||
receivedBytes, totalBytes, disposition,
|
receivedBytes, totalBytes, disposition,
|
||||||
filename, port, savePath, isCustom) => {
|
filename, port, savePath, isCustom) => {
|
||||||
assert.equal(state, 'completed')
|
assert.strictEqual(state, 'completed')
|
||||||
assert.equal(filename, 'mock.pdf')
|
assert.strictEqual(filename, 'mock.pdf')
|
||||||
assert.ok(path.isAbsolute(savePath))
|
assert.ok(path.isAbsolute(savePath))
|
||||||
assert.ok(isPathEqual(savePath, path.join(__dirname, 'fixtures', 'mock.pdf')))
|
assert.ok(isPathEqual(savePath, path.join(__dirname, 'fixtures', 'mock.pdf')))
|
||||||
if (isCustom) {
|
if (isCustom) {
|
||||||
assert.equal(url, `${protocolName}://item`)
|
assert.strictEqual(url, `${protocolName}://item`)
|
||||||
} else {
|
} 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.strictEqual(mimeType, 'application/pdf')
|
||||||
assert.equal(receivedBytes, mockPDF.length)
|
assert.strictEqual(receivedBytes, mockPDF.length)
|
||||||
assert.equal(totalBytes, mockPDF.length)
|
assert.strictEqual(totalBytes, mockPDF.length)
|
||||||
assert.equal(disposition, contentDisposition)
|
assert.strictEqual(disposition, contentDisposition)
|
||||||
assert(fs.existsSync(downloadFilePath))
|
assert(fs.existsSync(downloadFilePath))
|
||||||
fs.unlinkSync(downloadFilePath)
|
fs.unlinkSync(downloadFilePath)
|
||||||
}
|
}
|
||||||
|
@ -384,12 +384,12 @@ describe('session module', () => {
|
||||||
mimeType, receivedBytes,
|
mimeType, receivedBytes,
|
||||||
totalBytes, disposition,
|
totalBytes, disposition,
|
||||||
filename) => {
|
filename) => {
|
||||||
assert.equal(state, 'cancelled')
|
assert.strictEqual(state, 'cancelled')
|
||||||
assert.equal(filename, 'mock.pdf')
|
assert.strictEqual(filename, 'mock.pdf')
|
||||||
assert.equal(mimeType, 'application/pdf')
|
assert.strictEqual(mimeType, 'application/pdf')
|
||||||
assert.equal(receivedBytes, 0)
|
assert.strictEqual(receivedBytes, 0)
|
||||||
assert.equal(totalBytes, mockPDF.length)
|
assert.strictEqual(totalBytes, mockPDF.length)
|
||||||
assert.equal(disposition, contentDisposition)
|
assert.strictEqual(disposition, contentDisposition)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -410,12 +410,12 @@ describe('session module', () => {
|
||||||
mimeType, receivedBytes,
|
mimeType, receivedBytes,
|
||||||
totalBytes, disposition,
|
totalBytes, disposition,
|
||||||
filename) => {
|
filename) => {
|
||||||
assert.equal(state, 'cancelled')
|
assert.strictEqual(state, 'cancelled')
|
||||||
assert.equal(filename, 'download.pdf')
|
assert.strictEqual(filename, 'download.pdf')
|
||||||
assert.equal(mimeType, 'application/pdf')
|
assert.strictEqual(mimeType, 'application/pdf')
|
||||||
assert.equal(receivedBytes, 0)
|
assert.strictEqual(receivedBytes, 0)
|
||||||
assert.equal(totalBytes, mockPDF.length)
|
assert.strictEqual(totalBytes, mockPDF.length)
|
||||||
assert.equal(disposition, contentDisposition)
|
assert.strictEqual(disposition, contentDisposition)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -425,7 +425,7 @@ describe('session module', () => {
|
||||||
it('does not display a save dialog and reports the done state as interrupted', (done) => {
|
it('does not display a save dialog and reports the done state as interrupted', (done) => {
|
||||||
ipcRenderer.sendSync('set-download-option', false, false)
|
ipcRenderer.sendSync('set-download-option', false, false)
|
||||||
ipcRenderer.once('download-done', (event, state) => {
|
ipcRenderer.once('download-done', (event, state) => {
|
||||||
assert.equal(state, 'interrupted')
|
assert.strictEqual(state, 'interrupted')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.webContents.downloadURL(`file://${path.join(__dirname, 'does-not-exist.txt')}`)
|
w.webContents.downloadURL(`file://${path.join(__dirname, 'does-not-exist.txt')}`)
|
||||||
|
@ -461,9 +461,9 @@ describe('session module', () => {
|
||||||
|
|
||||||
it('does not affect defaultSession', (done) => {
|
it('does not affect defaultSession', (done) => {
|
||||||
protocol.isProtocolHandled(protocolName, (result) => {
|
protocol.isProtocolHandled(protocolName, (result) => {
|
||||||
assert.equal(result, false)
|
assert.strictEqual(result, false)
|
||||||
partitionProtocol.isProtocolHandled(protocolName, (result) => {
|
partitionProtocol.isProtocolHandled(protocolName, (result) => {
|
||||||
assert.equal(result, true)
|
assert.strictEqual(result, true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -480,7 +480,7 @@ describe('session module', () => {
|
||||||
const config = { proxyRules: 'http=myproxy:80' }
|
const config = { proxyRules: 'http=myproxy:80' }
|
||||||
session.defaultSession.setProxy(config, () => {
|
session.defaultSession.setProxy(config, () => {
|
||||||
session.defaultSession.resolveProxy('http://localhost', (proxy) => {
|
session.defaultSession.resolveProxy('http://localhost', (proxy) => {
|
||||||
assert.equal(proxy, 'PROXY myproxy:80')
|
assert.strictEqual(proxy, 'PROXY myproxy:80')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -493,7 +493,7 @@ describe('session module', () => {
|
||||||
}
|
}
|
||||||
session.defaultSession.setProxy(config, () => {
|
session.defaultSession.setProxy(config, () => {
|
||||||
session.defaultSession.resolveProxy('http://localhost', (proxy) => {
|
session.defaultSession.resolveProxy('http://localhost', (proxy) => {
|
||||||
assert.equal(proxy, 'DIRECT')
|
assert.strictEqual(proxy, 'DIRECT')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -540,7 +540,7 @@ describe('session module', () => {
|
||||||
let uuid = request.uploadData[1].blobUUID
|
let uuid = request.uploadData[1].blobUUID
|
||||||
assert(uuid)
|
assert(uuid)
|
||||||
session.defaultSession.getBlobData(uuid, (result) => {
|
session.defaultSession.getBlobData(uuid, (result) => {
|
||||||
assert.equal(result.toString(), postData)
|
assert.strictEqual(result.toString(), postData)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -587,7 +587,7 @@ describe('session module', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
w.webContents.once('did-finish-load', () => {
|
w.webContents.once('did-finish-load', () => {
|
||||||
assert.equal(w.webContents.getTitle(), 'hello')
|
assert.strictEqual(w.webContents.getTitle(), 'hello')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.loadURL(`https://127.0.0.1:${server.address().port}`)
|
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) => {
|
it('rejects the request when the callback is called with -2', (done) => {
|
||||||
session.defaultSession.setCertificateVerifyProc(({ hostname, certificate, verificationResult }, callback) => {
|
session.defaultSession.setCertificateVerifyProc(({ hostname, certificate, verificationResult }, callback) => {
|
||||||
assert.equal(hostname, '127.0.0.1')
|
assert.strictEqual(hostname, '127.0.0.1')
|
||||||
assert.equal(certificate.issuerName, 'Intermediate CA')
|
assert.strictEqual(certificate.issuerName, 'Intermediate CA')
|
||||||
assert.equal(certificate.subjectName, 'localhost')
|
assert.strictEqual(certificate.subjectName, 'localhost')
|
||||||
assert.equal(certificate.issuer.commonName, 'Intermediate CA')
|
assert.strictEqual(certificate.issuer.commonName, 'Intermediate CA')
|
||||||
assert.equal(certificate.subject.commonName, 'localhost')
|
assert.strictEqual(certificate.subject.commonName, 'localhost')
|
||||||
assert.equal(certificate.issuerCert.issuer.commonName, 'Root CA')
|
assert.strictEqual(certificate.issuerCert.issuer.commonName, 'Root CA')
|
||||||
assert.equal(certificate.issuerCert.subject.commonName, 'Intermediate CA')
|
assert.strictEqual(certificate.issuerCert.subject.commonName, 'Intermediate CA')
|
||||||
assert.equal(certificate.issuerCert.issuerCert.issuer.commonName, 'Root CA')
|
assert.strictEqual(certificate.issuerCert.issuerCert.issuer.commonName, 'Root CA')
|
||||||
assert.equal(certificate.issuerCert.issuerCert.subject.commonName, 'Root CA')
|
assert.strictEqual(certificate.issuerCert.issuerCert.subject.commonName, 'Root CA')
|
||||||
assert.equal(certificate.issuerCert.issuerCert.issuerCert, undefined)
|
assert.strictEqual(certificate.issuerCert.issuerCert.issuerCert, undefined)
|
||||||
assert(['net::ERR_CERT_AUTHORITY_INVALID', 'net::ERR_CERT_COMMON_NAME_INVALID'].includes(verificationResult), verificationResult)
|
assert(['net::ERR_CERT_AUTHORITY_INVALID', 'net::ERR_CERT_COMMON_NAME_INVALID'].includes(verificationResult), verificationResult)
|
||||||
callback(-2)
|
callback(-2)
|
||||||
})
|
})
|
||||||
|
|
||||||
const url = `https://127.0.0.1:${server.address().port}`
|
const url = `https://127.0.0.1:${server.address().port}`
|
||||||
w.webContents.once('did-finish-load', () => {
|
w.webContents.once('did-finish-load', () => {
|
||||||
assert.equal(w.webContents.getTitle(), url)
|
assert.strictEqual(w.webContents.getTitle(), url)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.loadURL(url)
|
w.loadURL(url)
|
||||||
|
@ -634,12 +634,12 @@ describe('session module', () => {
|
||||||
mimeType, receivedBytes,
|
mimeType, receivedBytes,
|
||||||
totalBytes, filename,
|
totalBytes, filename,
|
||||||
savePath) => {
|
savePath) => {
|
||||||
assert.equal(state, 'interrupted')
|
assert.strictEqual(state, 'interrupted')
|
||||||
assert.deepEqual(urlChain, ['http://127.0.0.1/'])
|
assert.deepStrictEqual(urlChain, ['http://127.0.0.1/'])
|
||||||
assert.equal(mimeType, 'application/pdf')
|
assert.strictEqual(mimeType, 'application/pdf')
|
||||||
assert.equal(receivedBytes, 0)
|
assert.strictEqual(receivedBytes, 0)
|
||||||
assert.equal(totalBytes, 5242880)
|
assert.strictEqual(totalBytes, 5242880)
|
||||||
assert.equal(savePath, filePath)
|
assert.strictEqual(savePath, filePath)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -673,13 +673,13 @@ describe('session module', () => {
|
||||||
ipcRenderer.sendSync('set-download-option', false, false, downloadFilePath)
|
ipcRenderer.sendSync('set-download-option', false, false, downloadFilePath)
|
||||||
w.webContents.session.createInterruptedDownload(options)
|
w.webContents.session.createInterruptedDownload(options)
|
||||||
} else {
|
} else {
|
||||||
assert.equal(state, 'completed')
|
assert.strictEqual(state, 'completed')
|
||||||
assert.equal(filename, 'logo.png')
|
assert.strictEqual(filename, 'logo.png')
|
||||||
assert.equal(savePath, downloadFilePath)
|
assert.strictEqual(savePath, downloadFilePath)
|
||||||
assert.equal(url, downloadUrl)
|
assert.strictEqual(url, downloadUrl)
|
||||||
assert.equal(mimeType, 'image/png')
|
assert.strictEqual(mimeType, 'image/png')
|
||||||
assert.equal(receivedBytes, 14022)
|
assert.strictEqual(receivedBytes, 14022)
|
||||||
assert.equal(totalBytes, 14022)
|
assert.strictEqual(totalBytes, 14022)
|
||||||
assert(fs.existsSync(downloadFilePath))
|
assert(fs.existsSync(downloadFilePath))
|
||||||
fs.unlinkSync(downloadFilePath)
|
fs.unlinkSync(downloadFilePath)
|
||||||
rangeServer.close()
|
rangeServer.close()
|
||||||
|
@ -719,8 +719,8 @@ describe('session module', () => {
|
||||||
})
|
})
|
||||||
request.on('login', (info, callback) => {
|
request.on('login', (info, callback) => {
|
||||||
attempt += 1
|
attempt += 1
|
||||||
assert.equal(info.scheme, 'basic')
|
assert.strictEqual(info.scheme, 'basic')
|
||||||
assert.equal(info.realm, 'Restricted')
|
assert.strictEqual(info.realm, 'Restricted')
|
||||||
callback('test', 'test')
|
callback('test', 'test')
|
||||||
})
|
})
|
||||||
request.on('response', (response) => {
|
request.on('response', (response) => {
|
||||||
|
@ -730,7 +730,7 @@ describe('session module', () => {
|
||||||
data += chunk
|
data += chunk
|
||||||
})
|
})
|
||||||
response.on('end', () => {
|
response.on('end', () => {
|
||||||
assert.equal(data, 'authenticated')
|
assert.strictEqual(data, 'authenticated')
|
||||||
ses.clearAuthCache({ type: 'password' }, () => {
|
ses.clearAuthCache({ type: 'password' }, () => {
|
||||||
issueLoginRequest(attempt)
|
issueLoginRequest(attempt)
|
||||||
})
|
})
|
||||||
|
@ -756,8 +756,8 @@ describe('session module', () => {
|
||||||
|
|
||||||
webview = new WebView()
|
webview = new WebView()
|
||||||
webview.addEventListener('ipc-message', (e) => {
|
webview.addEventListener('ipc-message', (e) => {
|
||||||
assert.equal(e.channel, 'message')
|
assert.strictEqual(e.channel, 'message')
|
||||||
assert.deepEqual(e.args, ['SecurityError'])
|
assert.deepStrictEqual(e.args, ['SecurityError'])
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
webview.src = `file://${fixtures}/pages/permissions/midi-sysex.html`
|
webview.src = `file://${fixtures}/pages/permissions/midi-sysex.html`
|
||||||
|
|
|
@ -32,7 +32,7 @@ describe('shell module', () => {
|
||||||
|
|
||||||
it('reads all properties of a shortcut', () => {
|
it('reads all properties of a shortcut', () => {
|
||||||
const shortcut = shell.readShortcutLink(path.join(fixtures, 'assets', 'shortcut.lnk'))
|
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', () => {
|
it('writes the shortcut', () => {
|
||||||
assert.equal(shell.writeShortcutLink(tmpShortcut, {target: 'C:\\'}), true)
|
assert.strictEqual(shell.writeShortcutLink(tmpShortcut, { target: 'C:\\' }), true)
|
||||||
assert.equal(fs.existsSync(tmpShortcut), true)
|
assert.strictEqual(fs.existsSync(tmpShortcut), true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('correctly sets the fields', () => {
|
it('correctly sets the fields', () => {
|
||||||
assert.equal(shell.writeShortcutLink(tmpShortcut, shortcutOptions), true)
|
assert.strictEqual(shell.writeShortcutLink(tmpShortcut, shortcutOptions), true)
|
||||||
assert.deepEqual(shell.readShortcutLink(tmpShortcut), shortcutOptions)
|
assert.deepStrictEqual(shell.readShortcutLink(tmpShortcut), shortcutOptions)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates the shortcut', () => {
|
it('updates the shortcut', () => {
|
||||||
assert.equal(shell.writeShortcutLink(tmpShortcut, 'update', shortcutOptions), false)
|
assert.strictEqual(shell.writeShortcutLink(tmpShortcut, 'update', shortcutOptions), false)
|
||||||
assert.equal(shell.writeShortcutLink(tmpShortcut, 'create', shortcutOptions), true)
|
assert.strictEqual(shell.writeShortcutLink(tmpShortcut, 'create', shortcutOptions), true)
|
||||||
assert.deepEqual(shell.readShortcutLink(tmpShortcut), shortcutOptions)
|
assert.deepStrictEqual(shell.readShortcutLink(tmpShortcut), shortcutOptions)
|
||||||
const change = { target: 'D:\\' }
|
const change = { target: 'D:\\' }
|
||||||
assert.equal(shell.writeShortcutLink(tmpShortcut, 'update', change), true)
|
assert.strictEqual(shell.writeShortcutLink(tmpShortcut, 'update', change), true)
|
||||||
assert.deepEqual(shell.readShortcutLink(tmpShortcut), Object.assign(shortcutOptions, change))
|
assert.deepStrictEqual(shell.readShortcutLink(tmpShortcut), Object.assign(shortcutOptions, change))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('replaces the shortcut', () => {
|
it('replaces the shortcut', () => {
|
||||||
assert.equal(shell.writeShortcutLink(tmpShortcut, 'replace', shortcutOptions), false)
|
assert.strictEqual(shell.writeShortcutLink(tmpShortcut, 'replace', shortcutOptions), false)
|
||||||
assert.equal(shell.writeShortcutLink(tmpShortcut, 'create', shortcutOptions), true)
|
assert.strictEqual(shell.writeShortcutLink(tmpShortcut, 'create', shortcutOptions), true)
|
||||||
assert.deepEqual(shell.readShortcutLink(tmpShortcut), shortcutOptions)
|
assert.deepStrictEqual(shell.readShortcutLink(tmpShortcut), shortcutOptions)
|
||||||
const change = {
|
const change = {
|
||||||
target: 'D:\\',
|
target: 'D:\\',
|
||||||
description: 'description2',
|
description: 'description2',
|
||||||
|
@ -75,8 +75,8 @@ describe('shell module', () => {
|
||||||
icon: 'icon2',
|
icon: 'icon2',
|
||||||
iconIndex: 2
|
iconIndex: 2
|
||||||
}
|
}
|
||||||
assert.equal(shell.writeShortcutLink(tmpShortcut, 'replace', change), true)
|
assert.strictEqual(shell.writeShortcutLink(tmpShortcut, 'replace', change), true)
|
||||||
assert.deepEqual(shell.readShortcutLink(tmpShortcut), change)
|
assert.deepStrictEqual(shell.readShortcutLink(tmpShortcut), change)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,7 +12,7 @@ describe('systemPreferences module', () => {
|
||||||
|
|
||||||
it('should return a non-empty string', () => {
|
it('should return a non-empty string', () => {
|
||||||
let accentColor = systemPreferences.getAccentColor()
|
let accentColor = systemPreferences.getAccentColor()
|
||||||
assert.notEqual(accentColor, null)
|
assert.notStrictEqual(accentColor, null)
|
||||||
assert(accentColor.length > 0)
|
assert(accentColor.length > 0)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -31,7 +31,7 @@ describe('systemPreferences module', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns a hex RGB color string', () => {
|
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) {
|
for (const userDefault of defaultsMap) {
|
||||||
const { key, value: expectedValue, type } = userDefault
|
const { key, value: expectedValue, type } = userDefault
|
||||||
const actualValue = systemPreferences.getUserDefault(key, type)
|
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', () => {
|
it('returns values for known user defaults', () => {
|
||||||
const locale = systemPreferences.getUserDefault('AppleLocale', 'string')
|
const locale = systemPreferences.getUserDefault('AppleLocale', 'string')
|
||||||
assert.equal(typeof locale, 'string')
|
assert.strictEqual(typeof locale, 'string')
|
||||||
assert(locale.length > 0)
|
assert(locale.length > 0)
|
||||||
|
|
||||||
const languages = systemPreferences.getUserDefault('AppleLanguages', 'array')
|
const languages = systemPreferences.getUserDefault('AppleLanguages', 'array')
|
||||||
|
@ -95,15 +95,15 @@ describe('systemPreferences module', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns values for unknown user defaults', () => {
|
it('returns values for unknown user defaults', () => {
|
||||||
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'boolean'), false)
|
assert.strictEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'boolean'), false)
|
||||||
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'integer'), 0)
|
assert.strictEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'integer'), 0)
|
||||||
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'float'), 0)
|
assert.strictEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'float'), 0)
|
||||||
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'double'), 0)
|
assert.strictEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'double'), 0)
|
||||||
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'string'), '')
|
assert.strictEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'string'), '')
|
||||||
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'url'), '')
|
assert.strictEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'url'), '')
|
||||||
assert.equal(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'badtype'), undefined)
|
assert.strictEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'badtype'), undefined)
|
||||||
assert.deepEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'array'), [])
|
assert.deepStrictEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'array'), [])
|
||||||
assert.deepEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'dictionary'), {})
|
assert.deepStrictEqual(systemPreferences.getUserDefault('UserDefaultDoesNotExist', 'dictionary'), {})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ describe('systemPreferences module', () => {
|
||||||
for (const [type, value] of TEST_CASES) {
|
for (const [type, value] of TEST_CASES) {
|
||||||
systemPreferences.setUserDefault(KEY, type, value)
|
systemPreferences.setUserDefault(KEY, type, value)
|
||||||
const retrievedValue = systemPreferences.getUserDefault(KEY, type)
|
const retrievedValue = systemPreferences.getUserDefault(KEY, type)
|
||||||
assert.deepEqual(retrievedValue, value)
|
assert.deepStrictEqual(retrievedValue, value)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ describe('systemPreferences module', () => {
|
||||||
const KEY = 'SystemPreferencesTest'
|
const KEY = 'SystemPreferencesTest'
|
||||||
systemPreferences.setUserDefault(KEY, 'string', 'foo')
|
systemPreferences.setUserDefault(KEY, 'string', 'foo')
|
||||||
systemPreferences.removeUserDefault(KEY)
|
systemPreferences.removeUserDefault(KEY)
|
||||||
assert.equal(systemPreferences.getUserDefault(KEY, 'string'), '')
|
assert.strictEqual(systemPreferences.getUserDefault(KEY, 'string'), '')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does not throw for missing keys', () => {
|
it('does not throw for missing keys', () => {
|
||||||
|
@ -170,7 +170,7 @@ describe('systemPreferences module', () => {
|
||||||
|
|
||||||
describe('systemPreferences.isInvertedColorScheme()', () => {
|
describe('systemPreferences.isInvertedColorScheme()', () => {
|
||||||
it('returns a boolean', () => {
|
it('returns a boolean', () => {
|
||||||
assert.equal(typeof systemPreferences.isInvertedColorScheme(), 'boolean')
|
assert.strictEqual(typeof systemPreferences.isInvertedColorScheme(), 'boolean')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -44,9 +44,9 @@ describe('webContents module', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
assert.ok(all.length >= 4)
|
assert.ok(all.length >= 4)
|
||||||
assert.equal(all[0].getType(), 'window')
|
assert.strictEqual(all[0].getType(), 'window')
|
||||||
assert.equal(all[all.length - 2].getType(), 'remote')
|
assert.strictEqual(all[all.length - 2].getType(), 'remote')
|
||||||
assert.equal(all[all.length - 1].getType(), 'webview')
|
assert.strictEqual(all[all.length - 1].getType(), 'webview')
|
||||||
|
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
@ -61,15 +61,15 @@ describe('webContents module', () => {
|
||||||
if (isCi) return done()
|
if (isCi) return done()
|
||||||
|
|
||||||
const specWebContents = remote.getCurrentWebContents()
|
const specWebContents = remote.getCurrentWebContents()
|
||||||
assert.equal(specWebContents.id, webContents.getFocusedWebContents().id)
|
assert.strictEqual(specWebContents.id, webContents.getFocusedWebContents().id)
|
||||||
|
|
||||||
specWebContents.once('devtools-opened', () => {
|
specWebContents.once('devtools-opened', () => {
|
||||||
assert.equal(specWebContents.devToolsWebContents.id, webContents.getFocusedWebContents().id)
|
assert.strictEqual(specWebContents.devToolsWebContents.id, webContents.getFocusedWebContents().id)
|
||||||
specWebContents.closeDevTools()
|
specWebContents.closeDevTools()
|
||||||
})
|
})
|
||||||
|
|
||||||
specWebContents.once('devtools-closed', () => {
|
specWebContents.once('devtools-closed', () => {
|
||||||
assert.equal(specWebContents.id, webContents.getFocusedWebContents().id)
|
assert.strictEqual(specWebContents.id, webContents.getFocusedWebContents().id)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ describe('webContents module', () => {
|
||||||
describe('isFocused() API', () => {
|
describe('isFocused() API', () => {
|
||||||
it('returns false when the window is hidden', () => {
|
it('returns false when the window is hidden', () => {
|
||||||
BrowserWindow.getAllWindows().forEach((window) => {
|
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.loadFile(path.join(fixtures, 'pages', 'key-events.html'))
|
||||||
w.webContents.once('did-finish-load', () => {
|
w.webContents.once('did-finish-load', () => {
|
||||||
ipcMain.once('keydown', (event, key) => {
|
ipcMain.once('keydown', (event, key) => {
|
||||||
assert.equal(key, 'b')
|
assert.strictEqual(key, 'b')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -175,14 +175,14 @@ describe('webContents module', () => {
|
||||||
const testBeforeInput = (opts) => {
|
const testBeforeInput = (opts) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
w.webContents.once('before-input-event', (event, input) => {
|
w.webContents.once('before-input-event', (event, input) => {
|
||||||
assert.equal(input.type, opts.type)
|
assert.strictEqual(input.type, opts.type)
|
||||||
assert.equal(input.key, opts.key)
|
assert.strictEqual(input.key, opts.key)
|
||||||
assert.equal(input.code, opts.code)
|
assert.strictEqual(input.code, opts.code)
|
||||||
assert.equal(input.isAutoRepeat, opts.isAutoRepeat)
|
assert.strictEqual(input.isAutoRepeat, opts.isAutoRepeat)
|
||||||
assert.equal(input.shift, opts.shift)
|
assert.strictEqual(input.shift, opts.shift)
|
||||||
assert.equal(input.control, opts.control)
|
assert.strictEqual(input.control, opts.control)
|
||||||
assert.equal(input.alt, opts.alt)
|
assert.strictEqual(input.alt, opts.alt)
|
||||||
assert.equal(input.meta, opts.meta)
|
assert.strictEqual(input.meta, opts.meta)
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -262,12 +262,12 @@ describe('webContents module', () => {
|
||||||
|
|
||||||
it('can send keydown events', (done) => {
|
it('can send keydown events', (done) => {
|
||||||
ipcMain.once('keydown', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
|
ipcMain.once('keydown', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
|
||||||
assert.equal(key, 'a')
|
assert.strictEqual(key, 'a')
|
||||||
assert.equal(code, 'KeyA')
|
assert.strictEqual(code, 'KeyA')
|
||||||
assert.equal(keyCode, 65)
|
assert.strictEqual(keyCode, 65)
|
||||||
assert.equal(shiftKey, false)
|
assert.strictEqual(shiftKey, false)
|
||||||
assert.equal(ctrlKey, false)
|
assert.strictEqual(ctrlKey, false)
|
||||||
assert.equal(altKey, false)
|
assert.strictEqual(altKey, false)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'A' })
|
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'A' })
|
||||||
|
@ -275,12 +275,12 @@ describe('webContents module', () => {
|
||||||
|
|
||||||
it('can send keydown events with modifiers', (done) => {
|
it('can send keydown events with modifiers', (done) => {
|
||||||
ipcMain.once('keydown', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
|
ipcMain.once('keydown', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
|
||||||
assert.equal(key, 'Z')
|
assert.strictEqual(key, 'Z')
|
||||||
assert.equal(code, 'KeyZ')
|
assert.strictEqual(code, 'KeyZ')
|
||||||
assert.equal(keyCode, 90)
|
assert.strictEqual(keyCode, 90)
|
||||||
assert.equal(shiftKey, true)
|
assert.strictEqual(shiftKey, true)
|
||||||
assert.equal(ctrlKey, true)
|
assert.strictEqual(ctrlKey, true)
|
||||||
assert.equal(altKey, false)
|
assert.strictEqual(altKey, false)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'Z', modifiers: ['shift', 'ctrl'] })
|
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) => {
|
it('can send keydown events with special keys', (done) => {
|
||||||
ipcMain.once('keydown', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
|
ipcMain.once('keydown', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
|
||||||
assert.equal(key, 'Tab')
|
assert.strictEqual(key, 'Tab')
|
||||||
assert.equal(code, 'Tab')
|
assert.strictEqual(code, 'Tab')
|
||||||
assert.equal(keyCode, 9)
|
assert.strictEqual(keyCode, 9)
|
||||||
assert.equal(shiftKey, false)
|
assert.strictEqual(shiftKey, false)
|
||||||
assert.equal(ctrlKey, false)
|
assert.strictEqual(ctrlKey, false)
|
||||||
assert.equal(altKey, true)
|
assert.strictEqual(altKey, true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'Tab', modifiers: ['alt'] })
|
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'Tab', modifiers: ['alt'] })
|
||||||
|
@ -301,12 +301,12 @@ describe('webContents module', () => {
|
||||||
|
|
||||||
it('can send char events', (done) => {
|
it('can send char events', (done) => {
|
||||||
ipcMain.once('keypress', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
|
ipcMain.once('keypress', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
|
||||||
assert.equal(key, 'a')
|
assert.strictEqual(key, 'a')
|
||||||
assert.equal(code, 'KeyA')
|
assert.strictEqual(code, 'KeyA')
|
||||||
assert.equal(keyCode, 65)
|
assert.strictEqual(keyCode, 65)
|
||||||
assert.equal(shiftKey, false)
|
assert.strictEqual(shiftKey, false)
|
||||||
assert.equal(ctrlKey, false)
|
assert.strictEqual(ctrlKey, false)
|
||||||
assert.equal(altKey, false)
|
assert.strictEqual(altKey, false)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'A' })
|
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'A' })
|
||||||
|
@ -315,12 +315,12 @@ describe('webContents module', () => {
|
||||||
|
|
||||||
it('can send char events with modifiers', (done) => {
|
it('can send char events with modifiers', (done) => {
|
||||||
ipcMain.once('keypress', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
|
ipcMain.once('keypress', (event, key, code, keyCode, shiftKey, ctrlKey, altKey) => {
|
||||||
assert.equal(key, 'Z')
|
assert.strictEqual(key, 'Z')
|
||||||
assert.equal(code, 'KeyZ')
|
assert.strictEqual(code, 'KeyZ')
|
||||||
assert.equal(keyCode, 90)
|
assert.strictEqual(keyCode, 90)
|
||||||
assert.equal(shiftKey, true)
|
assert.strictEqual(shiftKey, true)
|
||||||
assert.equal(ctrlKey, true)
|
assert.strictEqual(ctrlKey, true)
|
||||||
assert.equal(altKey, false)
|
assert.strictEqual(altKey, false)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'Z' })
|
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'Z' })
|
||||||
|
@ -332,7 +332,7 @@ describe('webContents module', () => {
|
||||||
w.loadURL('about:blank')
|
w.loadURL('about:blank')
|
||||||
w.webContents.insertCSS('body { background-repeat: round; }')
|
w.webContents.insertCSS('body { background-repeat: round; }')
|
||||||
w.webContents.executeJavaScript('window.getComputedStyle(document.body).getPropertyValue("background-repeat")', (result) => {
|
w.webContents.executeJavaScript('window.getComputedStyle(document.body).getPropertyValue("background-repeat")', (result) => {
|
||||||
assert.equal(result, 'round')
|
assert.strictEqual(result, 'round')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -367,8 +367,8 @@ describe('webContents module', () => {
|
||||||
describe('when the web contents is hidden', () => {
|
describe('when the web contents is hidden', () => {
|
||||||
it('does not blur the focused window', (done) => {
|
it('does not blur the focused window', (done) => {
|
||||||
ipcMain.once('answer', (event, parentFocused, childFocused) => {
|
ipcMain.once('answer', (event, parentFocused, childFocused) => {
|
||||||
assert.equal(parentFocused, true)
|
assert.strictEqual(parentFocused, true)
|
||||||
assert.equal(childFocused, false)
|
assert.strictEqual(childFocused, false)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.show()
|
w.show()
|
||||||
|
@ -383,7 +383,7 @@ describe('webContents module', () => {
|
||||||
|
|
||||||
w.webContents.once('did-finish-load', () => {
|
w.webContents.once('did-finish-load', () => {
|
||||||
const pid = w.webContents.getOSProcessId()
|
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`)
|
assert(pid > 0, `pid ${pid} is not greater than 0`)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
@ -424,10 +424,10 @@ describe('webContents module', () => {
|
||||||
w.loadURL('about:blank')
|
w.loadURL('about:blank')
|
||||||
w.webContents.on('did-finish-load', () => {
|
w.webContents.on('did-finish-load', () => {
|
||||||
w.webContents.getZoomLevel((zoomLevel) => {
|
w.webContents.getZoomLevel((zoomLevel) => {
|
||||||
assert.equal(zoomLevel, 0.0)
|
assert.strictEqual(zoomLevel, 0.0)
|
||||||
w.webContents.setZoomLevel(0.5)
|
w.webContents.setZoomLevel(0.5)
|
||||||
w.webContents.getZoomLevel((zoomLevel) => {
|
w.webContents.getZoomLevel((zoomLevel) => {
|
||||||
assert.equal(zoomLevel, 0.5)
|
assert.strictEqual(zoomLevel, 0.5)
|
||||||
w.webContents.setZoomLevel(0)
|
w.webContents.setZoomLevel(0)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
@ -444,7 +444,7 @@ describe('webContents module', () => {
|
||||||
})
|
})
|
||||||
ipcMain.on('host1-zoom-level', (e, zoomLevel) => {
|
ipcMain.on('host1-zoom-level', (e, zoomLevel) => {
|
||||||
const expectedZoomLevel = hostZoomMap.host1
|
const expectedZoomLevel = hostZoomMap.host1
|
||||||
assert.equal(zoomLevel, expectedZoomLevel)
|
assert.strictEqual(zoomLevel, expectedZoomLevel)
|
||||||
if (finalNavigation) {
|
if (finalNavigation) {
|
||||||
done()
|
done()
|
||||||
} else {
|
} else {
|
||||||
|
@ -453,7 +453,7 @@ describe('webContents module', () => {
|
||||||
})
|
})
|
||||||
ipcMain.once('host2-zoom-level', (e, zoomLevel) => {
|
ipcMain.once('host2-zoom-level', (e, zoomLevel) => {
|
||||||
const expectedZoomLevel = hostZoomMap.host2
|
const expectedZoomLevel = hostZoomMap.host2
|
||||||
assert.equal(zoomLevel, expectedZoomLevel)
|
assert.strictEqual(zoomLevel, expectedZoomLevel)
|
||||||
finalNavigation = true
|
finalNavigation = true
|
||||||
w.webContents.goBack()
|
w.webContents.goBack()
|
||||||
})
|
})
|
||||||
|
@ -466,9 +466,9 @@ describe('webContents module', () => {
|
||||||
})
|
})
|
||||||
w2.webContents.on('did-finish-load', () => {
|
w2.webContents.on('did-finish-load', () => {
|
||||||
w.webContents.getZoomLevel((zoomLevel1) => {
|
w.webContents.getZoomLevel((zoomLevel1) => {
|
||||||
assert.equal(zoomLevel1, hostZoomMap.host3)
|
assert.strictEqual(zoomLevel1, hostZoomMap.host3)
|
||||||
w2.webContents.getZoomLevel((zoomLevel2) => {
|
w2.webContents.getZoomLevel((zoomLevel2) => {
|
||||||
assert.equal(zoomLevel1, zoomLevel2)
|
assert.strictEqual(zoomLevel1, zoomLevel2)
|
||||||
w2.setClosable(true)
|
w2.setClosable(true)
|
||||||
w2.close()
|
w2.close()
|
||||||
done()
|
done()
|
||||||
|
@ -496,10 +496,10 @@ describe('webContents module', () => {
|
||||||
if (error) return done(error)
|
if (error) return done(error)
|
||||||
w2.webContents.on('did-finish-load', () => {
|
w2.webContents.on('did-finish-load', () => {
|
||||||
w.webContents.getZoomLevel((zoomLevel1) => {
|
w.webContents.getZoomLevel((zoomLevel1) => {
|
||||||
assert.equal(zoomLevel1, hostZoomMap.host3)
|
assert.strictEqual(zoomLevel1, hostZoomMap.host3)
|
||||||
w2.webContents.getZoomLevel((zoomLevel2) => {
|
w2.webContents.getZoomLevel((zoomLevel2) => {
|
||||||
assert.equal(zoomLevel2, 0)
|
assert.strictEqual(zoomLevel2, 0)
|
||||||
assert.notEqual(zoomLevel1, zoomLevel2)
|
assert.notStrictEqual(zoomLevel1, zoomLevel2)
|
||||||
protocol.unregisterProtocol(zoomScheme, (error) => {
|
protocol.unregisterProtocol(zoomScheme, (error) => {
|
||||||
if (error) return done(error)
|
if (error) return done(error)
|
||||||
w2.setClosable(true)
|
w2.setClosable(true)
|
||||||
|
@ -529,7 +529,7 @@ describe('webContents module', () => {
|
||||||
w.webContents.on('did-frame-finish-load', (e, isMainFrame) => {
|
w.webContents.on('did-frame-finish-load', (e, isMainFrame) => {
|
||||||
if (!isMainFrame) {
|
if (!isMainFrame) {
|
||||||
w.webContents.getZoomLevel((zoomLevel) => {
|
w.webContents.getZoomLevel((zoomLevel) => {
|
||||||
assert.equal(zoomLevel, 2.0)
|
assert.strictEqual(zoomLevel, 2.0)
|
||||||
w.webContents.setZoomLevel(0)
|
w.webContents.setZoomLevel(0)
|
||||||
server.close()
|
server.close()
|
||||||
done()
|
done()
|
||||||
|
@ -550,10 +550,10 @@ describe('webContents module', () => {
|
||||||
})
|
})
|
||||||
w2.webContents.on('did-finish-load', () => {
|
w2.webContents.on('did-finish-load', () => {
|
||||||
w.webContents.getZoomLevel((zoomLevel1) => {
|
w.webContents.getZoomLevel((zoomLevel1) => {
|
||||||
assert.equal(zoomLevel1, finalZoomLevel)
|
assert.strictEqual(zoomLevel1, finalZoomLevel)
|
||||||
w2.webContents.getZoomLevel((zoomLevel2) => {
|
w2.webContents.getZoomLevel((zoomLevel2) => {
|
||||||
assert.equal(zoomLevel2, 0)
|
assert.strictEqual(zoomLevel2, 0)
|
||||||
assert.notEqual(zoomLevel1, zoomLevel2)
|
assert.notStrictEqual(zoomLevel1, zoomLevel2)
|
||||||
w2.setClosable(true)
|
w2.setClosable(true)
|
||||||
w2.close()
|
w2.close()
|
||||||
done()
|
done()
|
||||||
|
@ -579,13 +579,13 @@ describe('webContents module', () => {
|
||||||
w.webContents.executeJavaScript(source, () => {})
|
w.webContents.executeJavaScript(source, () => {})
|
||||||
} else {
|
} else {
|
||||||
w.webContents.getZoomLevel((zoomLevel) => {
|
w.webContents.getZoomLevel((zoomLevel) => {
|
||||||
assert.equal(zoomLevel, 0)
|
assert.strictEqual(zoomLevel, 0)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
ipcMain.once('zoom-level-set', (e, zoomLevel) => {
|
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'))
|
w.loadFile(path.join(fixtures, 'pages', 'd.html'))
|
||||||
initialNavigation = false
|
initialNavigation = false
|
||||||
})
|
})
|
||||||
|
@ -603,7 +603,7 @@ describe('webContents module', () => {
|
||||||
]
|
]
|
||||||
policies.forEach((policy) => {
|
policies.forEach((policy) => {
|
||||||
w.webContents.setWebRTCIPHandlingPolicy(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)', () => {
|
describe('setIgnoreMenuShortcuts(ignore)', () => {
|
||||||
it('does not throw', () => {
|
it('does not throw', () => {
|
||||||
assert.equal(w.webContents.setIgnoreMenuShortcuts(true), undefined)
|
assert.strictEqual(w.webContents.setIgnoreMenuShortcuts(true), undefined)
|
||||||
assert.equal(w.webContents.setIgnoreMenuShortcuts(false), undefined)
|
assert.strictEqual(w.webContents.setIgnoreMenuShortcuts(false), undefined)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -712,10 +712,10 @@ describe('webContents module', () => {
|
||||||
w.webContents.on('did-change-theme-color', (e, color) => {
|
w.webContents.on('did-change-theme-color', (e, color) => {
|
||||||
if (count === 0) {
|
if (count === 0) {
|
||||||
count += 1
|
count += 1
|
||||||
assert.equal(color, '#FFEEDD')
|
assert.strictEqual(color, '#FFEEDD')
|
||||||
w.loadFile(path.join(fixtures, 'pages', 'base-page.html'))
|
w.loadFile(path.join(fixtures, 'pages', 'base-page.html'))
|
||||||
} else if (count === 1) {
|
} else if (count === 1) {
|
||||||
assert.equal(color, null)
|
assert.strictEqual(color, null)
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -739,7 +739,7 @@ describe('webContents module', () => {
|
||||||
it('propagates referrer information to new target=_blank windows', (done) => {
|
it('propagates referrer information to new target=_blank windows', (done) => {
|
||||||
const server = http.createServer((req, res) => {
|
const server = http.createServer((req, res) => {
|
||||||
if (req.url === '/should_have_referrer') {
|
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()
|
return done()
|
||||||
}
|
}
|
||||||
res.end('<a id="a" href="/should_have_referrer" target="_blank">link</a>')
|
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 + '/'
|
const url = 'http://127.0.0.1:' + server.address().port + '/'
|
||||||
w.webContents.once('did-finish-load', () => {
|
w.webContents.once('did-finish-load', () => {
|
||||||
w.webContents.once('new-window', (event, newUrl, frameName, disposition, options, features, referrer) => {
|
w.webContents.once('new-window', (event, newUrl, frameName, disposition, options, features, referrer) => {
|
||||||
assert.equal(referrer.url, url)
|
assert.strictEqual(referrer.url, url)
|
||||||
assert.equal(referrer.policy, 'no-referrer-when-downgrade')
|
assert.strictEqual(referrer.policy, 'no-referrer-when-downgrade')
|
||||||
})
|
})
|
||||||
w.webContents.executeJavaScript('a.click()')
|
w.webContents.executeJavaScript('a.click()')
|
||||||
})
|
})
|
||||||
|
@ -762,7 +762,7 @@ describe('webContents module', () => {
|
||||||
xit('propagates referrer information to windows opened with window.open', (done) => {
|
xit('propagates referrer information to windows opened with window.open', (done) => {
|
||||||
const server = http.createServer((req, res) => {
|
const server = http.createServer((req, res) => {
|
||||||
if (req.url === '/should_have_referrer') {
|
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()
|
return done()
|
||||||
}
|
}
|
||||||
res.end('')
|
res.end('')
|
||||||
|
@ -771,8 +771,8 @@ describe('webContents module', () => {
|
||||||
const url = 'http://127.0.0.1:' + server.address().port + '/'
|
const url = 'http://127.0.0.1:' + server.address().port + '/'
|
||||||
w.webContents.once('did-finish-load', () => {
|
w.webContents.once('did-finish-load', () => {
|
||||||
w.webContents.once('new-window', (event, newUrl, frameName, disposition, options, features, referrer) => {
|
w.webContents.once('new-window', (event, newUrl, frameName, disposition, options, features, referrer) => {
|
||||||
assert.equal(referrer.url, url)
|
assert.strictEqual(referrer.url, url)
|
||||||
assert.equal(referrer.policy, 'no-referrer-when-downgrade')
|
assert.strictEqual(referrer.policy, 'no-referrer-when-downgrade')
|
||||||
})
|
})
|
||||||
w.webContents.executeJavaScript('window.open(location.href + "should_have_referrer")')
|
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.once('did-finish-load', () => {
|
||||||
w.webContents.executeJavaScript('37 + 5', (result) => {
|
w.webContents.executeJavaScript('37 + 5', (result) => {
|
||||||
assert.equal(result, 42)
|
assert.strictEqual(result, 42)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -130,7 +130,7 @@ describe('webFrame module', function () {
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
if (error) return done(error)
|
if (error) return done(error)
|
||||||
ipcMain.once('response', function (event, status) {
|
ipcMain.once('response', function (event, status) {
|
||||||
assert.equal(status, expected)
|
assert.strictEqual(status, expected)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.loadURL(url)
|
w.loadURL(url)
|
||||||
|
|
|
@ -67,7 +67,7 @@ describe('webRequest module', () => {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `${defaultURL}nofilter/test`,
|
url: `${defaultURL}nofilter/test`,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, '/nofilter/test')
|
assert.strictEqual(data, '/nofilter/test')
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `${defaultURL}filter/test`,
|
url: `${defaultURL}filter/test`,
|
||||||
success: () => done('unexpected success'),
|
success: () => done('unexpected success'),
|
||||||
|
@ -80,19 +80,19 @@ describe('webRequest module', () => {
|
||||||
|
|
||||||
it('receives details object', (done) => {
|
it('receives details object', (done) => {
|
||||||
ses.webRequest.onBeforeRequest((details, callback) => {
|
ses.webRequest.onBeforeRequest((details, callback) => {
|
||||||
assert.equal(typeof details.id, 'number')
|
assert.strictEqual(typeof details.id, 'number')
|
||||||
assert.equal(typeof details.timestamp, 'number')
|
assert.strictEqual(typeof details.timestamp, 'number')
|
||||||
assert.equal(typeof details.webContentsId, 'number')
|
assert.strictEqual(typeof details.webContentsId, 'number')
|
||||||
assert.equal(details.url, defaultURL)
|
assert.strictEqual(details.url, defaultURL)
|
||||||
assert.equal(details.method, 'GET')
|
assert.strictEqual(details.method, 'GET')
|
||||||
assert.equal(details.resourceType, 'xhr')
|
assert.strictEqual(details.resourceType, 'xhr')
|
||||||
assert(!details.uploadData)
|
assert(!details.uploadData)
|
||||||
callback({})
|
callback({})
|
||||||
})
|
})
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: defaultURL,
|
url: defaultURL,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, '/')
|
assert.strictEqual(data, '/')
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType) => done(errorType)
|
error: (xhr, errorType) => done(errorType)
|
||||||
|
@ -105,11 +105,11 @@ describe('webRequest module', () => {
|
||||||
type: 'string'
|
type: 'string'
|
||||||
}
|
}
|
||||||
ses.webRequest.onBeforeRequest((details, callback) => {
|
ses.webRequest.onBeforeRequest((details, callback) => {
|
||||||
assert.equal(details.url, defaultURL)
|
assert.strictEqual(details.url, defaultURL)
|
||||||
assert.equal(details.method, 'POST')
|
assert.strictEqual(details.method, 'POST')
|
||||||
assert.equal(details.uploadData.length, 1)
|
assert.strictEqual(details.uploadData.length, 1)
|
||||||
const data = qs.parse(details.uploadData[0].bytes.toString())
|
const data = qs.parse(details.uploadData[0].bytes.toString())
|
||||||
assert.deepEqual(data, postData)
|
assert.deepStrictEqual(data, postData)
|
||||||
callback({ cancel: true })
|
callback({ cancel: true })
|
||||||
})
|
})
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -132,7 +132,7 @@ describe('webRequest module', () => {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: defaultURL,
|
url: defaultURL,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, '/redirect')
|
assert.strictEqual(data, '/redirect')
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType) => done(errorType)
|
error: (xhr, errorType) => done(errorType)
|
||||||
|
@ -147,15 +147,15 @@ describe('webRequest module', () => {
|
||||||
|
|
||||||
it('receives details object', (done) => {
|
it('receives details object', (done) => {
|
||||||
ses.webRequest.onBeforeSendHeaders((details, callback) => {
|
ses.webRequest.onBeforeSendHeaders((details, callback) => {
|
||||||
assert.equal(typeof details.requestHeaders, 'object')
|
assert.strictEqual(typeof details.requestHeaders, 'object')
|
||||||
assert.equal(details.requestHeaders['Foo.Bar'], 'baz')
|
assert.strictEqual(details.requestHeaders['Foo.Bar'], 'baz')
|
||||||
callback({})
|
callback({})
|
||||||
})
|
})
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: defaultURL,
|
url: defaultURL,
|
||||||
headers: { 'Foo.Bar': 'baz' },
|
headers: { 'Foo.Bar': 'baz' },
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, '/')
|
assert.strictEqual(data, '/')
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType) => done(errorType)
|
error: (xhr, errorType) => done(errorType)
|
||||||
|
@ -171,7 +171,7 @@ describe('webRequest module', () => {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: defaultURL,
|
url: defaultURL,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, '/header/received')
|
assert.strictEqual(data, '/header/received')
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType) => done(errorType)
|
error: (xhr, errorType) => done(errorType)
|
||||||
|
@ -186,7 +186,7 @@ describe('webRequest module', () => {
|
||||||
callback({ requestHeaders: requestHeaders })
|
callback({ requestHeaders: requestHeaders })
|
||||||
})
|
})
|
||||||
ses.webRequest.onSendHeaders((details) => {
|
ses.webRequest.onSendHeaders((details) => {
|
||||||
assert.deepEqual(details.requestHeaders, requestHeaders)
|
assert.deepStrictEqual(details.requestHeaders, requestHeaders)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -203,12 +203,12 @@ describe('webRequest module', () => {
|
||||||
|
|
||||||
it('receives details object', (done) => {
|
it('receives details object', (done) => {
|
||||||
ses.webRequest.onSendHeaders((details) => {
|
ses.webRequest.onSendHeaders((details) => {
|
||||||
assert.equal(typeof details.requestHeaders, 'object')
|
assert.strictEqual(typeof details.requestHeaders, 'object')
|
||||||
})
|
})
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: defaultURL,
|
url: defaultURL,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, '/')
|
assert.strictEqual(data, '/')
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType) => done(errorType)
|
error: (xhr, errorType) => done(errorType)
|
||||||
|
@ -223,15 +223,15 @@ describe('webRequest module', () => {
|
||||||
|
|
||||||
it('receives details object', (done) => {
|
it('receives details object', (done) => {
|
||||||
ses.webRequest.onHeadersReceived((details, callback) => {
|
ses.webRequest.onHeadersReceived((details, callback) => {
|
||||||
assert.equal(details.statusLine, 'HTTP/1.1 200 OK')
|
assert.strictEqual(details.statusLine, 'HTTP/1.1 200 OK')
|
||||||
assert.equal(details.statusCode, 200)
|
assert.strictEqual(details.statusCode, 200)
|
||||||
assert.equal(details.responseHeaders['Custom'], 'Header')
|
assert.strictEqual(details.responseHeaders['Custom'], 'Header')
|
||||||
callback({})
|
callback({})
|
||||||
})
|
})
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: defaultURL,
|
url: defaultURL,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, '/')
|
assert.strictEqual(data, '/')
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType) => done(errorType)
|
error: (xhr, errorType) => done(errorType)
|
||||||
|
@ -247,8 +247,8 @@ describe('webRequest module', () => {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: defaultURL,
|
url: defaultURL,
|
||||||
success: (data, status, xhr) => {
|
success: (data, status, xhr) => {
|
||||||
assert.equal(xhr.getResponseHeader('Custom'), 'Changed')
|
assert.strictEqual(xhr.getResponseHeader('Custom'), 'Changed')
|
||||||
assert.equal(data, '/')
|
assert.strictEqual(data, '/')
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType) => done(errorType)
|
error: (xhr, errorType) => done(errorType)
|
||||||
|
@ -262,8 +262,8 @@ describe('webRequest module', () => {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: defaultURL,
|
url: defaultURL,
|
||||||
success: (data, status, xhr) => {
|
success: (data, status, xhr) => {
|
||||||
assert.equal(xhr.getResponseHeader('Custom'), 'Header')
|
assert.strictEqual(xhr.getResponseHeader('Custom'), 'Header')
|
||||||
assert.equal(data, '/')
|
assert.strictEqual(data, '/')
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType) => done(errorType)
|
error: (xhr, errorType) => done(errorType)
|
||||||
|
@ -278,7 +278,7 @@ describe('webRequest module', () => {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: defaultURL + 'serverRedirect',
|
url: defaultURL + 'serverRedirect',
|
||||||
success: (data, status, xhr) => {
|
success: (data, status, xhr) => {
|
||||||
assert.equal(xhr.getResponseHeader('Custom'), 'Header')
|
assert.strictEqual(xhr.getResponseHeader('Custom'), 'Header')
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType) => done(errorType)
|
error: (xhr, errorType) => done(errorType)
|
||||||
|
@ -297,7 +297,7 @@ describe('webRequest module', () => {
|
||||||
url: defaultURL,
|
url: defaultURL,
|
||||||
success: (data, status, xhr) => {},
|
success: (data, status, xhr) => {},
|
||||||
error: (xhr, errorType) => {
|
error: (xhr, errorType) => {
|
||||||
assert.equal(xhr.getResponseHeader('Custom'), 'Header')
|
assert.strictEqual(xhr.getResponseHeader('Custom'), 'Header')
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -311,16 +311,16 @@ describe('webRequest module', () => {
|
||||||
|
|
||||||
it('receives details object', (done) => {
|
it('receives details object', (done) => {
|
||||||
ses.webRequest.onResponseStarted((details) => {
|
ses.webRequest.onResponseStarted((details) => {
|
||||||
assert.equal(typeof details.fromCache, 'boolean')
|
assert.strictEqual(typeof details.fromCache, 'boolean')
|
||||||
assert.equal(details.statusLine, 'HTTP/1.1 200 OK')
|
assert.strictEqual(details.statusLine, 'HTTP/1.1 200 OK')
|
||||||
assert.equal(details.statusCode, 200)
|
assert.strictEqual(details.statusCode, 200)
|
||||||
assert.equal(details.responseHeaders['Custom'], 'Header')
|
assert.strictEqual(details.responseHeaders['Custom'], 'Header')
|
||||||
})
|
})
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: defaultURL,
|
url: defaultURL,
|
||||||
success: (data, status, xhr) => {
|
success: (data, status, xhr) => {
|
||||||
assert.equal(xhr.getResponseHeader('Custom'), 'Header')
|
assert.strictEqual(xhr.getResponseHeader('Custom'), 'Header')
|
||||||
assert.equal(data, '/')
|
assert.strictEqual(data, '/')
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType) => done(errorType)
|
error: (xhr, errorType) => done(errorType)
|
||||||
|
@ -344,15 +344,15 @@ describe('webRequest module', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
ses.webRequest.onBeforeRedirect((details) => {
|
ses.webRequest.onBeforeRedirect((details) => {
|
||||||
assert.equal(typeof details.fromCache, 'boolean')
|
assert.strictEqual(typeof details.fromCache, 'boolean')
|
||||||
assert.equal(details.statusLine, 'HTTP/1.1 307 Internal Redirect')
|
assert.strictEqual(details.statusLine, 'HTTP/1.1 307 Internal Redirect')
|
||||||
assert.equal(details.statusCode, 307)
|
assert.strictEqual(details.statusCode, 307)
|
||||||
assert.equal(details.redirectURL, redirectURL)
|
assert.strictEqual(details.redirectURL, redirectURL)
|
||||||
})
|
})
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: defaultURL,
|
url: defaultURL,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, '/redirect')
|
assert.strictEqual(data, '/redirect')
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType) => done(errorType)
|
error: (xhr, errorType) => done(errorType)
|
||||||
|
@ -367,14 +367,14 @@ describe('webRequest module', () => {
|
||||||
|
|
||||||
it('receives details object', (done) => {
|
it('receives details object', (done) => {
|
||||||
ses.webRequest.onCompleted((details) => {
|
ses.webRequest.onCompleted((details) => {
|
||||||
assert.equal(typeof details.fromCache, 'boolean')
|
assert.strictEqual(typeof details.fromCache, 'boolean')
|
||||||
assert.equal(details.statusLine, 'HTTP/1.1 200 OK')
|
assert.strictEqual(details.statusLine, 'HTTP/1.1 200 OK')
|
||||||
assert.equal(details.statusCode, 200)
|
assert.strictEqual(details.statusCode, 200)
|
||||||
})
|
})
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: defaultURL,
|
url: defaultURL,
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
assert.equal(data, '/')
|
assert.strictEqual(data, '/')
|
||||||
done()
|
done()
|
||||||
},
|
},
|
||||||
error: (xhr, errorType) => done(errorType)
|
error: (xhr, errorType) => done(errorType)
|
||||||
|
@ -393,7 +393,7 @@ describe('webRequest module', () => {
|
||||||
callback({ cancel: true })
|
callback({ cancel: true })
|
||||||
})
|
})
|
||||||
ses.webRequest.onErrorOccurred((details) => {
|
ses.webRequest.onErrorOccurred((details) => {
|
||||||
assert.equal(details.error, 'net::ERR_BLOCKED_BY_CLIENT')
|
assert.strictEqual(details.error, 'net::ERR_BLOCKED_BY_CLIENT')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe('asar package', function () {
|
||||||
describe('node api', function () {
|
describe('node api', function () {
|
||||||
it('supports paths specified as a Buffer', function () {
|
it('supports paths specified as a Buffer', function () {
|
||||||
var file = Buffer.from(path.join(fixtures, 'asar', 'a.asar', 'file1'))
|
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 () {
|
describe('fs.readFileSync', function () {
|
||||||
|
@ -32,30 +32,30 @@ describe('asar package', function () {
|
||||||
|
|
||||||
it('reads a normal file', function () {
|
it('reads a normal file', function () {
|
||||||
var file1 = path.join(fixtures, 'asar', 'a.asar', 'file1')
|
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')
|
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')
|
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 () {
|
it('reads from a empty file', function () {
|
||||||
var file = path.join(fixtures, 'asar', 'empty.asar', 'file1')
|
var file = path.join(fixtures, 'asar', 'empty.asar', 'file1')
|
||||||
var buffer = fs.readFileSync(file)
|
var buffer = fs.readFileSync(file)
|
||||||
assert.equal(buffer.length, 0)
|
assert.strictEqual(buffer.length, 0)
|
||||||
assert.equal(buffer.toString(), '')
|
assert.strictEqual(buffer.toString(), '')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('reads a linked file', function () {
|
it('reads a linked file', function () {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'link1')
|
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 () {
|
it('reads a file from linked directory', function () {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'file1')
|
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')
|
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 () {
|
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 () {
|
it('reads a normal file with unpacked files', function () {
|
||||||
var p = path.join(fixtures, 'asar', 'unpack.asar', 'a.txt')
|
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) {
|
it('reads a normal file', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
|
||||||
fs.readFile(p, function (err, content) {
|
fs.readFile(p, function (err, content) {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(String(content).trim(), 'file1')
|
assert.strictEqual(String(content).trim(), 'file1')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -95,8 +95,8 @@ describe('asar package', function () {
|
||||||
it('reads from a empty file', function (done) {
|
it('reads from a empty file', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'empty.asar', 'file1')
|
var p = path.join(fixtures, 'asar', 'empty.asar', 'file1')
|
||||||
fs.readFile(p, function (err, content) {
|
fs.readFile(p, function (err, content) {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(String(content), '')
|
assert.strictEqual(String(content), '')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -104,8 +104,8 @@ describe('asar package', function () {
|
||||||
it('reads from a empty file with encoding', function (done) {
|
it('reads from a empty file with encoding', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'empty.asar', 'file1')
|
var p = path.join(fixtures, 'asar', 'empty.asar', 'file1')
|
||||||
fs.readFile(p, 'utf8', function (err, content) {
|
fs.readFile(p, 'utf8', function (err, content) {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(content, '')
|
assert.strictEqual(content, '')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -113,8 +113,8 @@ describe('asar package', function () {
|
||||||
it('reads a linked file', function (done) {
|
it('reads a linked file', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'link1')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'link1')
|
||||||
fs.readFile(p, function (err, content) {
|
fs.readFile(p, function (err, content) {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(String(content).trim(), 'file1')
|
assert.strictEqual(String(content).trim(), 'file1')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -122,8 +122,8 @@ describe('asar package', function () {
|
||||||
it('reads a file from linked directory', function (done) {
|
it('reads a file from linked directory', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1')
|
||||||
fs.readFile(p, function (err, content) {
|
fs.readFile(p, function (err, content) {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(String(content).trim(), 'file1')
|
assert.strictEqual(String(content).trim(), 'file1')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -131,7 +131,7 @@ describe('asar package', function () {
|
||||||
it('throws ENOENT error when can not find file', function (done) {
|
it('throws ENOENT error when can not find file', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
|
||||||
fs.readFile(p, function (err) {
|
fs.readFile(p, function (err) {
|
||||||
assert.equal(err.code, 'ENOENT')
|
assert.strictEqual(err.code, 'ENOENT')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -147,10 +147,10 @@ describe('asar package', function () {
|
||||||
it('returns information of root', function () {
|
it('returns information of root', function () {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar')
|
var p = path.join(fixtures, 'asar', 'a.asar')
|
||||||
var stats = fs.lstatSync(p)
|
var stats = fs.lstatSync(p)
|
||||||
assert.equal(stats.isFile(), false)
|
assert.strictEqual(stats.isFile(), false)
|
||||||
assert.equal(stats.isDirectory(), true)
|
assert.strictEqual(stats.isDirectory(), true)
|
||||||
assert.equal(stats.isSymbolicLink(), false)
|
assert.strictEqual(stats.isSymbolicLink(), false)
|
||||||
assert.equal(stats.size, 0)
|
assert.strictEqual(stats.size, 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns information of a normal file', function () {
|
it('returns information of a normal file', function () {
|
||||||
|
@ -160,10 +160,10 @@ describe('asar package', function () {
|
||||||
file = ref2[j]
|
file = ref2[j]
|
||||||
p = path.join(fixtures, 'asar', 'a.asar', file)
|
p = path.join(fixtures, 'asar', 'a.asar', file)
|
||||||
stats = fs.lstatSync(p)
|
stats = fs.lstatSync(p)
|
||||||
assert.equal(stats.isFile(), true)
|
assert.strictEqual(stats.isFile(), true)
|
||||||
assert.equal(stats.isDirectory(), false)
|
assert.strictEqual(stats.isDirectory(), false)
|
||||||
assert.equal(stats.isSymbolicLink(), false)
|
assert.strictEqual(stats.isSymbolicLink(), false)
|
||||||
assert.equal(stats.size, 6)
|
assert.strictEqual(stats.size, 6)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -174,10 +174,10 @@ describe('asar package', function () {
|
||||||
file = ref2[j]
|
file = ref2[j]
|
||||||
p = path.join(fixtures, 'asar', 'a.asar', file)
|
p = path.join(fixtures, 'asar', 'a.asar', file)
|
||||||
stats = fs.lstatSync(p)
|
stats = fs.lstatSync(p)
|
||||||
assert.equal(stats.isFile(), false)
|
assert.strictEqual(stats.isFile(), false)
|
||||||
assert.equal(stats.isDirectory(), true)
|
assert.strictEqual(stats.isDirectory(), true)
|
||||||
assert.equal(stats.isSymbolicLink(), false)
|
assert.strictEqual(stats.isSymbolicLink(), false)
|
||||||
assert.equal(stats.size, 0)
|
assert.strictEqual(stats.size, 0)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -188,10 +188,10 @@ describe('asar package', function () {
|
||||||
file = ref2[j]
|
file = ref2[j]
|
||||||
p = path.join(fixtures, 'asar', 'a.asar', file)
|
p = path.join(fixtures, 'asar', 'a.asar', file)
|
||||||
stats = fs.lstatSync(p)
|
stats = fs.lstatSync(p)
|
||||||
assert.equal(stats.isFile(), false)
|
assert.strictEqual(stats.isFile(), false)
|
||||||
assert.equal(stats.isDirectory(), false)
|
assert.strictEqual(stats.isDirectory(), false)
|
||||||
assert.equal(stats.isSymbolicLink(), true)
|
assert.strictEqual(stats.isSymbolicLink(), true)
|
||||||
assert.equal(stats.size, 0)
|
assert.strictEqual(stats.size, 0)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -202,10 +202,10 @@ describe('asar package', function () {
|
||||||
file = ref2[j]
|
file = ref2[j]
|
||||||
p = path.join(fixtures, 'asar', 'a.asar', file)
|
p = path.join(fixtures, 'asar', 'a.asar', file)
|
||||||
stats = fs.lstatSync(p)
|
stats = fs.lstatSync(p)
|
||||||
assert.equal(stats.isFile(), false)
|
assert.strictEqual(stats.isFile(), false)
|
||||||
assert.equal(stats.isDirectory(), false)
|
assert.strictEqual(stats.isDirectory(), false)
|
||||||
assert.equal(stats.isSymbolicLink(), true)
|
assert.strictEqual(stats.isSymbolicLink(), true)
|
||||||
assert.equal(stats.size, 0)
|
assert.strictEqual(stats.size, 0)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -232,11 +232,11 @@ describe('asar package', function () {
|
||||||
it('returns information of root', function (done) {
|
it('returns information of root', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar')
|
var p = path.join(fixtures, 'asar', 'a.asar')
|
||||||
fs.lstat(p, function (err, stats) {
|
fs.lstat(p, function (err, stats) {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(stats.isFile(), false)
|
assert.strictEqual(stats.isFile(), false)
|
||||||
assert.equal(stats.isDirectory(), true)
|
assert.strictEqual(stats.isDirectory(), true)
|
||||||
assert.equal(stats.isSymbolicLink(), false)
|
assert.strictEqual(stats.isSymbolicLink(), false)
|
||||||
assert.equal(stats.size, 0)
|
assert.strictEqual(stats.size, 0)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -244,11 +244,11 @@ describe('asar package', function () {
|
||||||
it('returns information of a normal file', function (done) {
|
it('returns information of a normal file', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'file1')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'file1')
|
||||||
fs.lstat(p, function (err, stats) {
|
fs.lstat(p, function (err, stats) {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(stats.isFile(), true)
|
assert.strictEqual(stats.isFile(), true)
|
||||||
assert.equal(stats.isDirectory(), false)
|
assert.strictEqual(stats.isDirectory(), false)
|
||||||
assert.equal(stats.isSymbolicLink(), false)
|
assert.strictEqual(stats.isSymbolicLink(), false)
|
||||||
assert.equal(stats.size, 6)
|
assert.strictEqual(stats.size, 6)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -256,11 +256,11 @@ describe('asar package', function () {
|
||||||
it('returns information of a normal directory', function (done) {
|
it('returns information of a normal directory', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'dir1')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'dir1')
|
||||||
fs.lstat(p, function (err, stats) {
|
fs.lstat(p, function (err, stats) {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(stats.isFile(), false)
|
assert.strictEqual(stats.isFile(), false)
|
||||||
assert.equal(stats.isDirectory(), true)
|
assert.strictEqual(stats.isDirectory(), true)
|
||||||
assert.equal(stats.isSymbolicLink(), false)
|
assert.strictEqual(stats.isSymbolicLink(), false)
|
||||||
assert.equal(stats.size, 0)
|
assert.strictEqual(stats.size, 0)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -268,11 +268,11 @@ describe('asar package', function () {
|
||||||
it('returns information of a linked file', function (done) {
|
it('returns information of a linked file', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link1')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link1')
|
||||||
fs.lstat(p, function (err, stats) {
|
fs.lstat(p, function (err, stats) {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(stats.isFile(), false)
|
assert.strictEqual(stats.isFile(), false)
|
||||||
assert.equal(stats.isDirectory(), false)
|
assert.strictEqual(stats.isDirectory(), false)
|
||||||
assert.equal(stats.isSymbolicLink(), true)
|
assert.strictEqual(stats.isSymbolicLink(), true)
|
||||||
assert.equal(stats.size, 0)
|
assert.strictEqual(stats.size, 0)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -280,11 +280,11 @@ describe('asar package', function () {
|
||||||
it('returns information of a linked directory', function (done) {
|
it('returns information of a linked directory', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2')
|
||||||
fs.lstat(p, function (err, stats) {
|
fs.lstat(p, function (err, stats) {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(stats.isFile(), false)
|
assert.strictEqual(stats.isFile(), false)
|
||||||
assert.equal(stats.isDirectory(), false)
|
assert.strictEqual(stats.isDirectory(), false)
|
||||||
assert.equal(stats.isSymbolicLink(), true)
|
assert.strictEqual(stats.isSymbolicLink(), true)
|
||||||
assert.equal(stats.size, 0)
|
assert.strictEqual(stats.size, 0)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -292,7 +292,7 @@ describe('asar package', function () {
|
||||||
it('throws ENOENT error when can not find file', function (done) {
|
it('throws ENOENT error when can not find file', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'file4')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'file4')
|
||||||
fs.lstat(p, function (err) {
|
fs.lstat(p, function (err) {
|
||||||
assert.equal(err.code, 'ENOENT')
|
assert.strictEqual(err.code, 'ENOENT')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -303,42 +303,42 @@ describe('asar package', function () {
|
||||||
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
||||||
const p = 'a.asar'
|
const p = 'a.asar'
|
||||||
const r = fs.realpathSync(path.join(parent, p))
|
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', () => {
|
it('returns real path of a normal file', () => {
|
||||||
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('a.asar', 'file1')
|
const p = path.join('a.asar', 'file1')
|
||||||
const r = fs.realpathSync(path.join(parent, p))
|
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', () => {
|
it('returns real path of a normal directory', () => {
|
||||||
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('a.asar', 'dir1')
|
const p = path.join('a.asar', 'dir1')
|
||||||
const r = fs.realpathSync(path.join(parent, p))
|
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', () => {
|
it('returns real path of a linked file', () => {
|
||||||
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('a.asar', 'link2', 'link1')
|
const p = path.join('a.asar', 'link2', 'link1')
|
||||||
const r = fs.realpathSync(path.join(parent, p))
|
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', () => {
|
it('returns real path of a linked directory', () => {
|
||||||
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('a.asar', 'link2', 'link2')
|
const p = path.join('a.asar', 'link2', 'link2')
|
||||||
const r = fs.realpathSync(path.join(parent, p))
|
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', () => {
|
it('returns real path of an unpacked file', () => {
|
||||||
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('unpack.asar', 'a.txt')
|
const p = path.join('unpack.asar', 'a.txt')
|
||||||
const r = fs.realpathSync(path.join(parent, p))
|
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', () => {
|
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 parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
||||||
const p = 'a.asar'
|
const p = 'a.asar'
|
||||||
const r = fs.realpathSync.native(path.join(parent, p))
|
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', () => {
|
it('returns real path of a normal file', () => {
|
||||||
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('a.asar', 'file1')
|
const p = path.join('a.asar', 'file1')
|
||||||
const r = fs.realpathSync.native(path.join(parent, p))
|
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', () => {
|
it('returns real path of a normal directory', () => {
|
||||||
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('a.asar', 'dir1')
|
const p = path.join('a.asar', 'dir1')
|
||||||
const r = fs.realpathSync.native(path.join(parent, p))
|
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', () => {
|
it('returns real path of a linked file', () => {
|
||||||
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('a.asar', 'link2', 'link1')
|
const p = path.join('a.asar', 'link2', 'link1')
|
||||||
const r = fs.realpathSync.native(path.join(parent, p))
|
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', () => {
|
it('returns real path of a linked directory', () => {
|
||||||
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('a.asar', 'link2', 'link2')
|
const p = path.join('a.asar', 'link2', 'link2')
|
||||||
const r = fs.realpathSync.native(path.join(parent, p))
|
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', () => {
|
it('returns real path of an unpacked file', () => {
|
||||||
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('unpack.asar', 'a.txt')
|
const p = path.join('unpack.asar', 'a.txt')
|
||||||
const r = fs.realpathSync.native(path.join(parent, p))
|
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', () => {
|
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 parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
||||||
const p = 'a.asar'
|
const p = 'a.asar'
|
||||||
fs.realpath(path.join(parent, p), (err, r) => {
|
fs.realpath(path.join(parent, p), (err, r) => {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(r, path.join(parent, p))
|
assert.strictEqual(r, path.join(parent, p))
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -415,8 +415,8 @@ describe('asar package', function () {
|
||||||
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('a.asar', 'file1')
|
const p = path.join('a.asar', 'file1')
|
||||||
fs.realpath(path.join(parent, p), (err, r) => {
|
fs.realpath(path.join(parent, p), (err, r) => {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(r, path.join(parent, p))
|
assert.strictEqual(r, path.join(parent, p))
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -425,8 +425,8 @@ describe('asar package', function () {
|
||||||
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('a.asar', 'dir1')
|
const p = path.join('a.asar', 'dir1')
|
||||||
fs.realpath(path.join(parent, p), (err, r) => {
|
fs.realpath(path.join(parent, p), (err, r) => {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(r, path.join(parent, p))
|
assert.strictEqual(r, path.join(parent, p))
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -435,8 +435,8 @@ describe('asar package', function () {
|
||||||
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('a.asar', 'link2', 'link1')
|
const p = path.join('a.asar', 'link2', 'link1')
|
||||||
fs.realpath(path.join(parent, p), (err, r) => {
|
fs.realpath(path.join(parent, p), (err, r) => {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(r, path.join(parent, 'a.asar', 'file1'))
|
assert.strictEqual(r, path.join(parent, 'a.asar', 'file1'))
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -445,8 +445,8 @@ describe('asar package', function () {
|
||||||
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('a.asar', 'link2', 'link2')
|
const p = path.join('a.asar', 'link2', 'link2')
|
||||||
fs.realpath(path.join(parent, p), (err, r) => {
|
fs.realpath(path.join(parent, p), (err, r) => {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(r, path.join(parent, 'a.asar', 'dir1'))
|
assert.strictEqual(r, path.join(parent, 'a.asar', 'dir1'))
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -455,8 +455,8 @@ describe('asar package', function () {
|
||||||
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('unpack.asar', 'a.txt')
|
const p = path.join('unpack.asar', 'a.txt')
|
||||||
fs.realpath(path.join(parent, p), (err, r) => {
|
fs.realpath(path.join(parent, p), (err, r) => {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(r, path.join(parent, p))
|
assert.strictEqual(r, path.join(parent, p))
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -465,7 +465,7 @@ describe('asar package', function () {
|
||||||
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('a.asar', 'not-exist')
|
const p = path.join('a.asar', 'not-exist')
|
||||||
fs.realpath(path.join(parent, p), err => {
|
fs.realpath(path.join(parent, p), err => {
|
||||||
assert.equal(err.code, 'ENOENT')
|
assert.strictEqual(err.code, 'ENOENT')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -476,8 +476,8 @@ describe('asar package', function () {
|
||||||
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
||||||
const p = 'a.asar'
|
const p = 'a.asar'
|
||||||
fs.realpath.native(path.join(parent, p), (err, r) => {
|
fs.realpath.native(path.join(parent, p), (err, r) => {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(r, path.join(parent, p))
|
assert.strictEqual(r, path.join(parent, p))
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -486,8 +486,8 @@ describe('asar package', function () {
|
||||||
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('a.asar', 'file1')
|
const p = path.join('a.asar', 'file1')
|
||||||
fs.realpath.native(path.join(parent, p), (err, r) => {
|
fs.realpath.native(path.join(parent, p), (err, r) => {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(r, path.join(parent, p))
|
assert.strictEqual(r, path.join(parent, p))
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -496,8 +496,8 @@ describe('asar package', function () {
|
||||||
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('a.asar', 'dir1')
|
const p = path.join('a.asar', 'dir1')
|
||||||
fs.realpath.native(path.join(parent, p), (err, r) => {
|
fs.realpath.native(path.join(parent, p), (err, r) => {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(r, path.join(parent, p))
|
assert.strictEqual(r, path.join(parent, p))
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -506,8 +506,8 @@ describe('asar package', function () {
|
||||||
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('a.asar', 'link2', 'link1')
|
const p = path.join('a.asar', 'link2', 'link1')
|
||||||
fs.realpath.native(path.join(parent, p), (err, r) => {
|
fs.realpath.native(path.join(parent, p), (err, r) => {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(r, path.join(parent, 'a.asar', 'file1'))
|
assert.strictEqual(r, path.join(parent, 'a.asar', 'file1'))
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -516,8 +516,8 @@ describe('asar package', function () {
|
||||||
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('a.asar', 'link2', 'link2')
|
const p = path.join('a.asar', 'link2', 'link2')
|
||||||
fs.realpath.native(path.join(parent, p), (err, r) => {
|
fs.realpath.native(path.join(parent, p), (err, r) => {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(r, path.join(parent, 'a.asar', 'dir1'))
|
assert.strictEqual(r, path.join(parent, 'a.asar', 'dir1'))
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -526,8 +526,8 @@ describe('asar package', function () {
|
||||||
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('unpack.asar', 'a.txt')
|
const p = path.join('unpack.asar', 'a.txt')
|
||||||
fs.realpath.native(path.join(parent, p), (err, r) => {
|
fs.realpath.native(path.join(parent, p), (err, r) => {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(r, path.join(parent, p))
|
assert.strictEqual(r, path.join(parent, p))
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -536,7 +536,7 @@ describe('asar package', function () {
|
||||||
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
const parent = fs.realpathSync.native(path.join(fixtures, 'asar'))
|
||||||
const p = path.join('a.asar', 'not-exist')
|
const p = path.join('a.asar', 'not-exist')
|
||||||
fs.realpath.native(path.join(parent, p), err => {
|
fs.realpath.native(path.join(parent, p), err => {
|
||||||
assert.equal(err.code, 'ENOENT')
|
assert.strictEqual(err.code, 'ENOENT')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -546,19 +546,19 @@ describe('asar package', function () {
|
||||||
it('reads dirs from root', function () {
|
it('reads dirs from root', function () {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar')
|
var p = path.join(fixtures, 'asar', 'a.asar')
|
||||||
var dirs = fs.readdirSync(p)
|
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 () {
|
it('reads dirs from a normal dir', function () {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'dir1')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'dir1')
|
||||||
var dirs = fs.readdirSync(p)
|
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 () {
|
it('reads dirs from a linked dir', function () {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2')
|
||||||
var dirs = fs.readdirSync(p)
|
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 () {
|
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) {
|
it('reads dirs from root', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar')
|
var p = path.join(fixtures, 'asar', 'a.asar')
|
||||||
fs.readdir(p, function (err, dirs) {
|
fs.readdir(p, function (err, dirs) {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
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'])
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -583,16 +583,16 @@ describe('asar package', function () {
|
||||||
it('reads dirs from a normal dir', function (done) {
|
it('reads dirs from a normal dir', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'dir1')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'dir1')
|
||||||
fs.readdir(p, function (err, dirs) {
|
fs.readdir(p, function (err, dirs) {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2'])
|
assert.deepStrictEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2'])
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
it('reads dirs from a linked dir', function (done) {
|
it('reads dirs from a linked dir', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2')
|
||||||
fs.readdir(p, function (err, dirs) {
|
fs.readdir(p, function (err, dirs) {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2'])
|
assert.deepStrictEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2'])
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -600,7 +600,7 @@ describe('asar package', function () {
|
||||||
it('throws ENOENT error when can not find file', function (done) {
|
it('throws ENOENT error when can not find file', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
|
||||||
fs.readdir(p, function (err) {
|
fs.readdir(p, function (err) {
|
||||||
assert.equal(err.code, 'ENOENT')
|
assert.strictEqual(err.code, 'ENOENT')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -616,7 +616,7 @@ describe('asar package', function () {
|
||||||
fd = fs.openSync(p, 'r')
|
fd = fs.openSync(p, 'r')
|
||||||
buffer = Buffer.alloc(6)
|
buffer = Buffer.alloc(6)
|
||||||
fs.readSync(fd, buffer, 0, 6, 0)
|
fs.readSync(fd, buffer, 0, 6, 0)
|
||||||
assert.equal(String(buffer).trim(), 'file1')
|
assert.strictEqual(String(buffer).trim(), 'file1')
|
||||||
fs.closeSync(fd)
|
fs.closeSync(fd)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -634,11 +634,11 @@ describe('asar package', function () {
|
||||||
it('opens a normal file', function (done) {
|
it('opens a normal file', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
|
||||||
fs.open(p, 'r', function (err, fd) {
|
fs.open(p, 'r', function (err, fd) {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
var buffer = Buffer.alloc(6)
|
var buffer = Buffer.alloc(6)
|
||||||
fs.read(fd, buffer, 0, 6, 0, function (err) {
|
fs.read(fd, buffer, 0, 6, 0, function (err) {
|
||||||
assert.equal(err, null)
|
assert.strictEqual(err, null)
|
||||||
assert.equal(String(buffer).trim(), 'file1')
|
assert.strictEqual(String(buffer).trim(), 'file1')
|
||||||
fs.close(fd, done)
|
fs.close(fd, done)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -647,7 +647,7 @@ describe('asar package', function () {
|
||||||
it('throws ENOENT error when can not find file', function (done) {
|
it('throws ENOENT error when can not find file', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
|
||||||
fs.open(p, 'r', function (err) {
|
fs.open(p, 'r', function (err) {
|
||||||
assert.equal(err.code, 'ENOENT')
|
assert.strictEqual(err.code, 'ENOENT')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -657,7 +657,7 @@ describe('asar package', function () {
|
||||||
it('throws error when calling inside asar archive', function (done) {
|
it('throws error when calling inside asar archive', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
|
||||||
fs.mkdir(p, function (err) {
|
fs.mkdir(p, function (err) {
|
||||||
assert.equal(err.code, 'ENOTDIR')
|
assert.strictEqual(err.code, 'ENOTDIR')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -677,7 +677,7 @@ describe('asar package', function () {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
fs.exists(p, function (exists) {
|
fs.exists(p, function (exists) {
|
||||||
assert.equal(exists, true)
|
assert.strictEqual(exists, true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -686,7 +686,7 @@ describe('asar package', function () {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
fs.exists(p, function (exists) {
|
fs.exists(p, function (exists) {
|
||||||
assert.equal(exists, false)
|
assert.strictEqual(exists, false)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -695,7 +695,7 @@ describe('asar package', function () {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
util.promisify(fs.exists)(p).then(exists => {
|
util.promisify(fs.exists)(p).then(exists => {
|
||||||
assert.equal(exists, true)
|
assert.strictEqual(exists, true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -704,7 +704,7 @@ describe('asar package', function () {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
util.promisify(fs.exists)(p).then(exists => {
|
util.promisify(fs.exists)(p).then(exists => {
|
||||||
assert.equal(exists, false)
|
assert.strictEqual(exists, false)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -714,14 +714,14 @@ describe('asar package', function () {
|
||||||
it('handles an existing file', function () {
|
it('handles an existing file', function () {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
|
||||||
assert.doesNotThrow(function () {
|
assert.doesNotThrow(function () {
|
||||||
assert.equal(fs.existsSync(p), true)
|
assert.strictEqual(fs.existsSync(p), true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('handles a non-existent file', function () {
|
it('handles a non-existent file', function () {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
|
||||||
assert.doesNotThrow(function () {
|
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) {
|
it('throws an error when called with write mode', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
|
||||||
fs.access(p, fs.constants.R_OK | fs.constants.W_OK, function (err) {
|
fs.access(p, fs.constants.R_OK | fs.constants.W_OK, function (err) {
|
||||||
assert.equal(err.code, 'EACCES')
|
assert.strictEqual(err.code, 'EACCES')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -746,7 +746,7 @@ describe('asar package', function () {
|
||||||
it('throws an error when called on non-existent file', function (done) {
|
it('throws an error when called on non-existent file', function (done) {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
|
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
|
||||||
fs.access(p, function (err) {
|
fs.access(p, function (err) {
|
||||||
assert.equal(err.code, 'ENOENT')
|
assert.strictEqual(err.code, 'ENOENT')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -794,7 +794,7 @@ describe('asar package', function () {
|
||||||
it('opens a normal js file', function (done) {
|
it('opens a normal js file', function (done) {
|
||||||
var child = ChildProcess.fork(path.join(fixtures, 'asar', 'a.asar', 'ping.js'))
|
var child = ChildProcess.fork(path.join(fixtures, 'asar', 'a.asar', 'ping.js'))
|
||||||
child.on('message', function (msg) {
|
child.on('message', function (msg) {
|
||||||
assert.equal(msg, 'message')
|
assert.strictEqual(msg, 'message')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
child.send('message')
|
child.send('message')
|
||||||
|
@ -804,7 +804,7 @@ describe('asar package', function () {
|
||||||
var file = path.join(fixtures, 'asar', 'a.asar', 'file1')
|
var file = path.join(fixtures, 'asar', 'a.asar', 'file1')
|
||||||
var child = ChildProcess.fork(path.join(fixtures, 'module', 'asar.js'))
|
var child = ChildProcess.fork(path.join(fixtures, 'module', 'asar.js'))
|
||||||
child.on('message', function (content) {
|
child.on('message', function (content) {
|
||||||
assert.equal(content, fs.readFileSync(file).toString())
|
assert.strictEqual(content, fs.readFileSync(file).toString())
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
child.send(file)
|
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) {
|
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) {
|
ChildProcess.exec('echo ' + echo + ' foo bar', function (error, stdout) {
|
||||||
assert.equal(error, null)
|
assert.strictEqual(error, null)
|
||||||
assert.equal(stdout.toString().replace(/\r/g, ''), echo + ' foo bar\n')
|
assert.strictEqual(stdout.toString().replace(/\r/g, ''), echo + ' foo bar\n')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can be promisified', () => {
|
it('can be promisified', () => {
|
||||||
return util.promisify(ChildProcess.exec)('echo ' + echo + ' foo bar').then(({ stdout }) => {
|
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) {
|
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')
|
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()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -853,20 +853,20 @@ describe('asar package', function () {
|
||||||
|
|
||||||
it('executes binaries', function (done) {
|
it('executes binaries', function (done) {
|
||||||
execFile(echo, ['test'], function (error, stdout) {
|
execFile(echo, ['test'], function (error, stdout) {
|
||||||
assert.equal(error, null)
|
assert.strictEqual(error, null)
|
||||||
assert.equal(stdout, 'test\n')
|
assert.strictEqual(stdout, 'test\n')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
xit('execFileSync executes binaries', function () {
|
xit('execFileSync executes binaries', function () {
|
||||||
var output = execFileSync(echo, ['test'])
|
var output = execFileSync(echo, ['test'])
|
||||||
assert.equal(String(output), 'test\n')
|
assert.strictEqual(String(output), 'test\n')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can be promisified', () => {
|
it('can be promisified', () => {
|
||||||
return util.promisify(ChildProcess.execFile)(echo, ['test']).then(({ stdout }) => {
|
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 () {
|
it('read a normal file', function () {
|
||||||
var file1 = path.join(fixtures, 'asar', 'a.asar', 'file1')
|
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')
|
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')
|
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 () {
|
it('reads a normal file with unpacked files', function () {
|
||||||
var p = path.join(fixtures, 'asar', 'unpack.asar', 'a.txt')
|
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 file = path.join(fixtures, 'asar', 'a.asar', 'file1')
|
||||||
var dir = path.join(fixtures, 'asar', 'a.asar', 'dir1')
|
var dir = path.join(fixtures, 'asar', 'a.asar', 'dir1')
|
||||||
fs.readFile(file, function (error) {
|
fs.readFile(file, function (error) {
|
||||||
assert.equal(error.code, errorName)
|
assert.strictEqual(error.code, errorName)
|
||||||
fs.lstat(file, function (error) {
|
fs.lstat(file, function (error) {
|
||||||
assert.equal(error.code, errorName)
|
assert.strictEqual(error.code, errorName)
|
||||||
fs.realpath(file, function (error) {
|
fs.realpath(file, function (error) {
|
||||||
assert.equal(error.code, errorName)
|
assert.strictEqual(error.code, errorName)
|
||||||
fs.readdir(dir, function (error) {
|
fs.readdir(dir, function (error) {
|
||||||
assert.equal(error.code, errorName)
|
assert.strictEqual(error.code, errorName)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -960,7 +960,7 @@ describe('asar package', function () {
|
||||||
var asar = path.join(fixtures, 'asar', 'a.asar')
|
var asar = path.join(fixtures, 'asar', 'a.asar')
|
||||||
var content1 = fs.readFileSync(asar)
|
var content1 = fs.readFileSync(asar)
|
||||||
var content2 = originalFs.readFileSync(asar)
|
var content2 = originalFs.readFileSync(asar)
|
||||||
assert.equal(content1.compare(content2), 0)
|
assert.strictEqual(content1.compare(content2), 0)
|
||||||
assert.throws(function () {
|
assert.throws(function () {
|
||||||
fs.readdirSync(asar)
|
fs.readdirSync(asar)
|
||||||
}, /ENOTDIR/)
|
}, /ENOTDIR/)
|
||||||
|
@ -971,7 +971,7 @@ describe('asar package', function () {
|
||||||
assert.throws(function () {
|
assert.throws(function () {
|
||||||
ChildProcess.execSync(path.join(__dirname, 'does-not-exist.txt'))
|
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) {
|
forked.on('message', function (stats) {
|
||||||
assert.equal(stats.isFile, true)
|
assert.strictEqual(stats.isFile, true)
|
||||||
assert.equal(stats.size, 778)
|
assert.strictEqual(stats.size, 778)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1003,8 +1003,8 @@ describe('asar package', function () {
|
||||||
})
|
})
|
||||||
spawned.stdout.on('close', function () {
|
spawned.stdout.on('close', function () {
|
||||||
const stats = JSON.parse(output)
|
const stats = JSON.parse(output)
|
||||||
assert.equal(stats.isFile, true)
|
assert.strictEqual(stats.isFile, true)
|
||||||
assert.equal(stats.size, 778)
|
assert.strictEqual(stats.size, 778)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1021,7 +1021,7 @@ describe('asar package', function () {
|
||||||
it('can request a file in package', function (done) {
|
it('can request a file in package', function (done) {
|
||||||
var p = path.resolve(fixtures, 'asar', 'a.asar', 'file1')
|
var p = path.resolve(fixtures, 'asar', 'a.asar', 'file1')
|
||||||
$.get('file://' + p, function (data) {
|
$.get('file://' + p, function (data) {
|
||||||
assert.equal(data.trim(), 'file1')
|
assert.strictEqual(data.trim(), 'file1')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1029,7 +1029,7 @@ describe('asar package', function () {
|
||||||
it('can request a file in package with unpacked files', function (done) {
|
it('can request a file in package with unpacked files', function (done) {
|
||||||
var p = path.resolve(fixtures, 'asar', 'unpack.asar', 'a.txt')
|
var p = path.resolve(fixtures, 'asar', 'unpack.asar', 'a.txt')
|
||||||
$.get('file://' + p, function (data) {
|
$.get('file://' + p, function (data) {
|
||||||
assert.equal(data.trim(), 'a')
|
assert.strictEqual(data.trim(), 'a')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1037,7 +1037,7 @@ describe('asar package', function () {
|
||||||
it('can request a linked file in package', function (done) {
|
it('can request a linked file in package', function (done) {
|
||||||
var p = path.resolve(fixtures, 'asar', 'a.asar', 'link2', 'link1')
|
var p = path.resolve(fixtures, 'asar', 'a.asar', 'link2', 'link1')
|
||||||
$.get('file://' + p, function (data) {
|
$.get('file://' + p, function (data) {
|
||||||
assert.equal(data.trim(), 'file1')
|
assert.strictEqual(data.trim(), 'file1')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1045,7 +1045,7 @@ describe('asar package', function () {
|
||||||
it('can request a file in filesystem', function (done) {
|
it('can request a file in filesystem', function (done) {
|
||||||
var p = path.resolve(fixtures, 'asar', 'file')
|
var p = path.resolve(fixtures, 'asar', 'file')
|
||||||
$.get('file://' + p, function (data) {
|
$.get('file://' + p, function (data) {
|
||||||
assert.equal(data.trim(), 'file')
|
assert.strictEqual(data.trim(), 'file')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1055,7 +1055,7 @@ describe('asar package', function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'file://' + p,
|
url: 'file://' + p,
|
||||||
error: function (err) {
|
error: function (err) {
|
||||||
assert.equal(err.status, 404)
|
assert.strictEqual(err.status, 404)
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1073,7 +1073,7 @@ describe('asar package', function () {
|
||||||
})
|
})
|
||||||
var p = path.resolve(fixtures, 'asar', 'web.asar', 'index.html')
|
var p = path.resolve(fixtures, 'asar', 'web.asar', 'index.html')
|
||||||
ipcMain.once('dirname', function (event, dirname) {
|
ipcMain.once('dirname', function (event, dirname) {
|
||||||
assert.equal(dirname, path.dirname(p))
|
assert.strictEqual(dirname, path.dirname(p))
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.loadFile(p)
|
w.loadFile(p)
|
||||||
|
@ -1092,7 +1092,7 @@ describe('asar package', function () {
|
||||||
var p = path.resolve(fixtures, 'asar', 'script.asar', 'index.html')
|
var p = path.resolve(fixtures, 'asar', 'script.asar', 'index.html')
|
||||||
w.loadFile(p)
|
w.loadFile(p)
|
||||||
ipcMain.once('ping', function (event, message) {
|
ipcMain.once('ping', function (event, message) {
|
||||||
assert.equal(message, 'pong')
|
assert.strictEqual(message, 'pong')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1134,7 +1134,7 @@ describe('asar package', function () {
|
||||||
it('is available in forked scripts', function (done) {
|
it('is available in forked scripts', function (done) {
|
||||||
var child = ChildProcess.fork(path.join(fixtures, 'module', 'original-fs.js'))
|
var child = ChildProcess.fork(path.join(fixtures, 'module', 'original-fs.js'))
|
||||||
child.on('message', function (msg) {
|
child.on('message', function (msg) {
|
||||||
assert.equal(msg, 'object')
|
assert.strictEqual(msg, 'object')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
child.send('message')
|
child.send('message')
|
||||||
|
@ -1146,10 +1146,10 @@ describe('asar package', function () {
|
||||||
|
|
||||||
it('recognize asar archvies', function () {
|
it('recognize asar archvies', function () {
|
||||||
var p = path.join(fixtures, 'asar', 'a.asar', 'link1')
|
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 () {
|
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 () {
|
it('reads image from asar archive', function () {
|
||||||
var p = path.join(fixtures, 'asar', 'logo.asar', 'logo.png')
|
var p = path.join(fixtures, 'asar', 'logo.asar', 'logo.png')
|
||||||
var logo = nativeImage.createFromPath(p)
|
var logo = nativeImage.createFromPath(p)
|
||||||
assert.deepEqual(logo.getSize(), {
|
assert.deepStrictEqual(logo.getSize(), {
|
||||||
width: 55,
|
width: 55,
|
||||||
height: 55
|
height: 55
|
||||||
})
|
})
|
||||||
|
@ -1177,7 +1177,7 @@ describe('asar package', function () {
|
||||||
it('reads image from asar archive with unpacked files', function () {
|
it('reads image from asar archive with unpacked files', function () {
|
||||||
var p = path.join(fixtures, 'asar', 'unpack.asar', 'atom.png')
|
var p = path.join(fixtures, 'asar', 'unpack.asar', 'atom.png')
|
||||||
var logo = nativeImage.createFromPath(p)
|
var logo = nativeImage.createFromPath(p)
|
||||||
assert.deepEqual(logo.getSize(), {
|
assert.deepStrictEqual(logo.getSize(), {
|
||||||
width: 1024,
|
width: 1024,
|
||||||
height: 1024
|
height: 1024
|
||||||
})
|
})
|
||||||
|
|
|
@ -38,7 +38,7 @@ describe('chromium feature', () => {
|
||||||
appProcess.stdout.on('data', (data) => { output += data })
|
appProcess.stdout.on('data', (data) => { output += data })
|
||||||
appProcess.stdout.on('end', () => {
|
appProcess.stdout.on('end', () => {
|
||||||
output = output.replace(/(\r\n|\n|\r)/gm, '')
|
output = output.replace(/(\r\n|\n|\r)/gm, '')
|
||||||
assert.equal(output, result)
|
assert.strictEqual(output, result)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ describe('chromium feature', () => {
|
||||||
w.webContents.on('ipc-message', (event, args) => {
|
w.webContents.on('ipc-message', (event, args) => {
|
||||||
if (args[0] === 'deviceIds') deviceIds.push(args[1])
|
if (args[0] === 'deviceIds') deviceIds.push(args[1])
|
||||||
if (deviceIds.length === 2) {
|
if (deviceIds.length === 2) {
|
||||||
assert.notDeepEqual(deviceIds[0], deviceIds[1])
|
assert.notDeepStrictEqual(deviceIds[0], deviceIds[1])
|
||||||
closeWindow(w).then(() => {
|
closeWindow(w).then(() => {
|
||||||
w = null
|
w = null
|
||||||
done()
|
done()
|
||||||
|
@ -168,15 +168,15 @@ describe('chromium feature', () => {
|
||||||
|
|
||||||
describe('navigator.language', () => {
|
describe('navigator.language', () => {
|
||||||
it('should not be empty', () => {
|
it('should not be empty', () => {
|
||||||
assert.notEqual(navigator.language, '')
|
assert.notStrictEqual(navigator.language, '')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('navigator.languages', (done) => {
|
describe('navigator.languages', (done) => {
|
||||||
it('should return the system locale only', () => {
|
it('should return the system locale only', () => {
|
||||||
let appLocale = app.getLocale()
|
let appLocale = app.getLocale()
|
||||||
assert.equal(navigator.languages.length, 1)
|
assert.strictEqual(navigator.languages.length, 1)
|
||||||
assert.equal(navigator.languages[0], appLocale)
|
assert.strictEqual(navigator.languages[0], appLocale)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ describe('chromium feature', () => {
|
||||||
} else if (args[0] === 'error') {
|
} else if (args[0] === 'error') {
|
||||||
done(args[1])
|
done(args[1])
|
||||||
} else if (args[0] === 'response') {
|
} 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({
|
session.fromPartition('sw-file-scheme-spec').clearStorageData({
|
||||||
storages: ['serviceworkers']
|
storages: ['serviceworkers']
|
||||||
}, () => done())
|
}, () => done())
|
||||||
|
@ -230,7 +230,7 @@ describe('chromium feature', () => {
|
||||||
} else if (args[0] === 'error') {
|
} else if (args[0] === 'error') {
|
||||||
done(`unexpected error : ${args[1]}`)
|
done(`unexpected error : ${args[1]}`)
|
||||||
} else if (args[0] === 'response') {
|
} else if (args[0] === 'response') {
|
||||||
assert.equal(args[1], 'Hello from serviceWorker!')
|
assert.strictEqual(args[1], 'Hello from serviceWorker!')
|
||||||
customSession.clearStorageData({
|
customSession.clearStorageData({
|
||||||
storages: ['serviceworkers']
|
storages: ['serviceworkers']
|
||||||
}, () => {
|
}, () => {
|
||||||
|
@ -287,15 +287,15 @@ describe('chromium feature', () => {
|
||||||
describe('window.open', () => {
|
describe('window.open', () => {
|
||||||
it('returns a BrowserWindowProxy object', () => {
|
it('returns a BrowserWindowProxy object', () => {
|
||||||
const b = window.open('about:blank', '', 'show=no')
|
const b = window.open('about:blank', '', 'show=no')
|
||||||
assert.equal(b.closed, false)
|
assert.strictEqual(b.closed, false)
|
||||||
assert.equal(b.constructor.name, 'BrowserWindowProxy')
|
assert.strictEqual(b.constructor.name, 'BrowserWindowProxy')
|
||||||
b.close()
|
b.close()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('accepts "nodeIntegration" as feature', (done) => {
|
it('accepts "nodeIntegration" as feature', (done) => {
|
||||||
let b
|
let b
|
||||||
listener = (event) => {
|
listener = (event) => {
|
||||||
assert.equal(event.data.isProcessGlobalUndefined, true)
|
assert.strictEqual(event.data.isProcessGlobalUndefined, true)
|
||||||
b.close()
|
b.close()
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
|
@ -309,7 +309,7 @@ describe('chromium feature', () => {
|
||||||
const ref1 = remote.getCurrentWindow().getSize()
|
const ref1 = remote.getCurrentWindow().getSize()
|
||||||
const width = ref1[0]
|
const width = ref1[0]
|
||||||
const height = ref1[1]
|
const height = ref1[1]
|
||||||
assert.equal(event.data, `size: ${width} ${height}`)
|
assert.strictEqual(event.data, `size: ${width} ${height}`)
|
||||||
b.close()
|
b.close()
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,7 @@ describe('chromium feature', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
w.webContents.once('new-window', (e, url, frameName, disposition, options) => {
|
w.webContents.once('new-window', (e, url, frameName, disposition, options) => {
|
||||||
assert.equal(options.show, w.isVisible())
|
assert.strictEqual(options.show, w.isVisible())
|
||||||
w.close()
|
w.close()
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
@ -340,7 +340,7 @@ describe('chromium feature', () => {
|
||||||
it('disables node integration when it is disabled on the parent window', (done) => {
|
it('disables node integration when it is disabled on the parent window', (done) => {
|
||||||
let b
|
let b
|
||||||
listener = (event) => {
|
listener = (event) => {
|
||||||
assert.equal(event.data.isProcessGlobalUndefined, true)
|
assert.strictEqual(event.data.isProcessGlobalUndefined, true)
|
||||||
b.close()
|
b.close()
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,7 @@ describe('chromium feature', () => {
|
||||||
it('disables webviewTag when node integration is disabled on the parent window', (done) => {
|
it('disables webviewTag when node integration is disabled on the parent window', (done) => {
|
||||||
let b
|
let b
|
||||||
listener = (event) => {
|
listener = (event) => {
|
||||||
assert.equal(event.data.isWebViewUndefined, true)
|
assert.strictEqual(event.data.isWebViewUndefined, true)
|
||||||
b.close()
|
b.close()
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
|
@ -383,7 +383,7 @@ describe('chromium feature', () => {
|
||||||
app.once('web-contents-created', (event, contents) => {
|
app.once('web-contents-created', (event, contents) => {
|
||||||
contents.once('did-finish-load', () => {
|
contents.once('did-finish-load', () => {
|
||||||
contents.executeJavaScript('typeof process').then((typeofProcessGlobal) => {
|
contents.executeJavaScript('typeof process').then((typeofProcessGlobal) => {
|
||||||
assert.equal(typeofProcessGlobal, 'undefined')
|
assert.strictEqual(typeofProcessGlobal, 'undefined')
|
||||||
b.close()
|
b.close()
|
||||||
done()
|
done()
|
||||||
}).catch(done)
|
}).catch(done)
|
||||||
|
@ -398,7 +398,7 @@ describe('chromium feature', () => {
|
||||||
contents.once('did-finish-load', () => {
|
contents.once('did-finish-load', () => {
|
||||||
app.once('browser-window-created', (event, window) => {
|
app.once('browser-window-created', (event, window) => {
|
||||||
const preferences = window.webContents.getLastWebPreferences()
|
const preferences = window.webContents.getLastWebPreferences()
|
||||||
assert.equal(preferences.javascript, false)
|
assert.strictEqual(preferences.javascript, false)
|
||||||
window.destroy()
|
window.destroy()
|
||||||
b.close()
|
b.close()
|
||||||
done()
|
done()
|
||||||
|
@ -420,7 +420,7 @@ describe('chromium feature', () => {
|
||||||
it('disables the <webview> tag when it is disabled on the parent window', (done) => {
|
it('disables the <webview> tag when it is disabled on the parent window', (done) => {
|
||||||
let b
|
let b
|
||||||
listener = (event) => {
|
listener = (event) => {
|
||||||
assert.equal(event.data.isWebViewGlobalUndefined, true)
|
assert.strictEqual(event.data.isWebViewGlobalUndefined, true)
|
||||||
b.close()
|
b.close()
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
|
@ -444,7 +444,7 @@ describe('chromium feature', () => {
|
||||||
height: 450
|
height: 450
|
||||||
}
|
}
|
||||||
listener = (event) => {
|
listener = (event) => {
|
||||||
assert.equal(event.data, `size: ${size.width} ${size.height}`)
|
assert.strictEqual(event.data, `size: ${size.width} ${size.height}`)
|
||||||
b.close()
|
b.close()
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
|
@ -456,8 +456,8 @@ describe('chromium feature', () => {
|
||||||
w = BrowserWindow.fromId(ipcRenderer.sendSync('create-window-with-options-cycle'))
|
w = BrowserWindow.fromId(ipcRenderer.sendSync('create-window-with-options-cycle'))
|
||||||
w.loadFile(path.join(fixtures, 'pages', 'window-open.html'))
|
w.loadFile(path.join(fixtures, 'pages', 'window-open.html'))
|
||||||
w.webContents.once('new-window', (event, url, frameName, disposition, options) => {
|
w.webContents.once('new-window', (event, url, frameName, disposition, options) => {
|
||||||
assert.equal(options.show, false)
|
assert.strictEqual(options.show, false)
|
||||||
assert.deepEqual(options.foo, {
|
assert.deepStrictEqual(options.foo, {
|
||||||
bar: null,
|
bar: null,
|
||||||
baz: {
|
baz: {
|
||||||
hello: {
|
hello: {
|
||||||
|
@ -484,7 +484,7 @@ describe('chromium feature', () => {
|
||||||
}
|
}
|
||||||
app.once('browser-window-created', (event, window) => {
|
app.once('browser-window-created', (event, window) => {
|
||||||
window.webContents.once('did-finish-load', () => {
|
window.webContents.once('did-finish-load', () => {
|
||||||
assert.equal(b.location, targetURL)
|
assert.strictEqual(b.location, targetURL)
|
||||||
b.close()
|
b.close()
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
@ -514,14 +514,14 @@ describe('chromium feature', () => {
|
||||||
webContents.once('did-finish-load', () => {
|
webContents.once('did-finish-load', () => {
|
||||||
const { location } = b
|
const { location } = b
|
||||||
b.close()
|
b.close()
|
||||||
assert.equal(location, 'about:blank')
|
assert.strictEqual(location, 'about:blank')
|
||||||
|
|
||||||
let c
|
let c
|
||||||
app.once('browser-window-created', (event, { webContents }) => {
|
app.once('browser-window-created', (event, { webContents }) => {
|
||||||
webContents.once('did-finish-load', () => {
|
webContents.once('did-finish-load', () => {
|
||||||
const { location } = c
|
const { location } = c
|
||||||
c.close()
|
c.close()
|
||||||
assert.equal(location, 'about:blank')
|
assert.strictEqual(location, 'about:blank')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -544,7 +544,7 @@ describe('chromium feature', () => {
|
||||||
it('sets the window title to the specified frameName', (done) => {
|
it('sets the window title to the specified frameName', (done) => {
|
||||||
let b
|
let b
|
||||||
app.once('browser-window-created', (event, createdWindow) => {
|
app.once('browser-window-created', (event, createdWindow) => {
|
||||||
assert.equal(createdWindow.getTitle(), 'hello')
|
assert.strictEqual(createdWindow.getTitle(), 'hello')
|
||||||
b.close()
|
b.close()
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
@ -554,7 +554,7 @@ describe('chromium feature', () => {
|
||||||
it('does not throw an exception when the frameName is a built-in object property', (done) => {
|
it('does not throw an exception when the frameName is a built-in object property', (done) => {
|
||||||
let b
|
let b
|
||||||
app.once('browser-window-created', (event, createdWindow) => {
|
app.once('browser-window-created', (event, createdWindow) => {
|
||||||
assert.equal(createdWindow.getTitle(), '__proto__')
|
assert.strictEqual(createdWindow.getTitle(), '__proto__')
|
||||||
b.close()
|
b.close()
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
@ -575,7 +575,7 @@ describe('chromium feature', () => {
|
||||||
it('is null for main window', (done) => {
|
it('is null for main window', (done) => {
|
||||||
w = new BrowserWindow({ show: false })
|
w = new BrowserWindow({ show: false })
|
||||||
w.webContents.once('ipc-message', (event, args) => {
|
w.webContents.once('ipc-message', (event, args) => {
|
||||||
assert.deepEqual(args, ['opener', null])
|
assert.deepStrictEqual(args, ['opener', null])
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.loadFile(path.join(fixtures, 'pages', 'window-opener.html'))
|
w.loadFile(path.join(fixtures, 'pages', 'window-opener.html'))
|
||||||
|
@ -584,7 +584,7 @@ describe('chromium feature', () => {
|
||||||
it('is not null for window opened by window.open', (done) => {
|
it('is not null for window opened by window.open', (done) => {
|
||||||
let b
|
let b
|
||||||
listener = (event) => {
|
listener = (event) => {
|
||||||
assert.equal(event.data, 'object')
|
assert.strictEqual(event.data, 'object')
|
||||||
b.close()
|
b.close()
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
|
@ -614,7 +614,7 @@ describe('chromium feature', () => {
|
||||||
|
|
||||||
it('does nothing when origin of current window does not match opener', (done) => {
|
it('does nothing when origin of current window does not match opener', (done) => {
|
||||||
listener = (event) => {
|
listener = (event) => {
|
||||||
assert.equal(event.data, undefined)
|
assert.strictEqual(event.data, undefined)
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
window.addEventListener('message', listener)
|
window.addEventListener('message', listener)
|
||||||
|
@ -623,7 +623,7 @@ describe('chromium feature', () => {
|
||||||
|
|
||||||
it('works when origin matches', (done) => {
|
it('works when origin matches', (done) => {
|
||||||
listener = (event) => {
|
listener = (event) => {
|
||||||
assert.equal(event.data, location.href)
|
assert.strictEqual(event.data, location.href)
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
window.addEventListener('message', listener)
|
window.addEventListener('message', listener)
|
||||||
|
@ -632,7 +632,7 @@ describe('chromium feature', () => {
|
||||||
|
|
||||||
it('works when origin does not match opener but has node integration', (done) => {
|
it('works when origin does not match opener but has node integration', (done) => {
|
||||||
listener = (event) => {
|
listener = (event) => {
|
||||||
assert.equal(event.data, location.href)
|
assert.strictEqual(event.data, location.href)
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
window.addEventListener('message', listener)
|
window.addEventListener('message', listener)
|
||||||
|
@ -663,7 +663,7 @@ describe('chromium feature', () => {
|
||||||
it('does nothing when origin of webview src URL does not match opener', (done) => {
|
it('does nothing when origin of webview src URL does not match opener', (done) => {
|
||||||
webview = new WebView()
|
webview = new WebView()
|
||||||
webview.addEventListener('console-message', (e) => {
|
webview.addEventListener('console-message', (e) => {
|
||||||
assert.equal(e.message, 'null')
|
assert.strictEqual(e.message, 'null')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
webview.setAttribute('allowpopups', 'on')
|
webview.setAttribute('allowpopups', 'on')
|
||||||
|
@ -681,7 +681,7 @@ describe('chromium feature', () => {
|
||||||
it('works when origin matches', (done) => {
|
it('works when origin matches', (done) => {
|
||||||
webview = new WebView()
|
webview = new WebView()
|
||||||
webview.addEventListener('console-message', (e) => {
|
webview.addEventListener('console-message', (e) => {
|
||||||
assert.equal(e.message, webview.src)
|
assert.strictEqual(e.message, webview.src)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
webview.setAttribute('allowpopups', 'on')
|
webview.setAttribute('allowpopups', 'on')
|
||||||
|
@ -700,7 +700,7 @@ describe('chromium feature', () => {
|
||||||
webview = new WebView()
|
webview = new WebView()
|
||||||
webview.addEventListener('console-message', (e) => {
|
webview.addEventListener('console-message', (e) => {
|
||||||
webview.remove()
|
webview.remove()
|
||||||
assert.equal(e.message, webview.src)
|
assert.strictEqual(e.message, webview.src)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
webview.setAttribute('allowpopups', 'on')
|
webview.setAttribute('allowpopups', 'on')
|
||||||
|
@ -724,10 +724,10 @@ describe('chromium feature', () => {
|
||||||
window.removeEventListener('message', listener)
|
window.removeEventListener('message', listener)
|
||||||
b.close()
|
b.close()
|
||||||
const message = JSON.parse(event.data)
|
const message = JSON.parse(event.data)
|
||||||
assert.equal(message.data, 'testing')
|
assert.strictEqual(message.data, 'testing')
|
||||||
assert.equal(message.origin, 'file://')
|
assert.strictEqual(message.origin, 'file://')
|
||||||
assert.equal(message.sourceEqualsOpener, true)
|
assert.strictEqual(message.sourceEqualsOpener, true)
|
||||||
assert.equal(event.origin, 'file://')
|
assert.strictEqual(event.origin, 'file://')
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
window.addEventListener('message', listener)
|
window.addEventListener('message', listener)
|
||||||
|
@ -754,8 +754,8 @@ describe('chromium feature', () => {
|
||||||
listener = (event) => {
|
listener = (event) => {
|
||||||
window.removeEventListener('message', listener)
|
window.removeEventListener('message', listener)
|
||||||
b.close()
|
b.close()
|
||||||
assert.equal(event.source, b)
|
assert.strictEqual(event.source, b)
|
||||||
assert.equal(event.origin, 'file://')
|
assert.strictEqual(event.origin, 'file://')
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
window.addEventListener('message', listener)
|
window.addEventListener('message', listener)
|
||||||
|
@ -766,7 +766,7 @@ describe('chromium feature', () => {
|
||||||
const webview = new WebView()
|
const webview = new WebView()
|
||||||
webview.addEventListener('console-message', (e) => {
|
webview.addEventListener('console-message', (e) => {
|
||||||
webview.remove()
|
webview.remove()
|
||||||
assert.equal(e.message, 'message')
|
assert.strictEqual(e.message, 'message')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
webview.allowpopups = true
|
webview.allowpopups = true
|
||||||
|
@ -806,7 +806,7 @@ describe('chromium feature', () => {
|
||||||
listener = (event) => {
|
listener = (event) => {
|
||||||
window.removeEventListener('message', listener)
|
window.removeEventListener('message', listener)
|
||||||
b.close()
|
b.close()
|
||||||
assert.equal(event.data, 'deliver')
|
assert.strictEqual(event.data, 'deliver')
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
window.addEventListener('message', listener)
|
window.addEventListener('message', listener)
|
||||||
|
@ -838,7 +838,7 @@ describe('chromium feature', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const webgl = document.createElement('canvas').getContext('webgl')
|
const webgl = document.createElement('canvas').getContext('webgl')
|
||||||
assert.notEqual(webgl, null)
|
assert.notStrictEqual(webgl, null)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -847,7 +847,7 @@ describe('chromium feature', () => {
|
||||||
const worker = new Worker('../fixtures/workers/worker.js')
|
const worker = new Worker('../fixtures/workers/worker.js')
|
||||||
const message = 'ping'
|
const message = 'ping'
|
||||||
worker.onmessage = (event) => {
|
worker.onmessage = (event) => {
|
||||||
assert.equal(event.data, message)
|
assert.strictEqual(event.data, message)
|
||||||
worker.terminate()
|
worker.terminate()
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
|
@ -857,7 +857,7 @@ describe('chromium feature', () => {
|
||||||
it('Worker has no node integration by default', (done) => {
|
it('Worker has no node integration by default', (done) => {
|
||||||
let worker = new Worker('../fixtures/workers/worker_node.js')
|
let worker = new Worker('../fixtures/workers/worker_node.js')
|
||||||
worker.onmessage = (event) => {
|
worker.onmessage = (event) => {
|
||||||
assert.equal(event.data, 'undefined undefined undefined undefined')
|
assert.strictEqual(event.data, 'undefined undefined undefined undefined')
|
||||||
worker.terminate()
|
worker.terminate()
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
|
@ -866,7 +866,7 @@ describe('chromium feature', () => {
|
||||||
it('Worker has node integration with nodeIntegrationInWorker', (done) => {
|
it('Worker has node integration with nodeIntegrationInWorker', (done) => {
|
||||||
let webview = new WebView()
|
let webview = new WebView()
|
||||||
webview.addEventListener('ipc-message', (e) => {
|
webview.addEventListener('ipc-message', (e) => {
|
||||||
assert.equal(e.channel, 'object function object function')
|
assert.strictEqual(e.channel, 'object function object function')
|
||||||
webview.remove()
|
webview.remove()
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
@ -879,7 +879,7 @@ describe('chromium feature', () => {
|
||||||
const worker = new SharedWorker('../fixtures/workers/shared_worker.js')
|
const worker = new SharedWorker('../fixtures/workers/shared_worker.js')
|
||||||
const message = 'ping'
|
const message = 'ping'
|
||||||
worker.port.onmessage = (event) => {
|
worker.port.onmessage = (event) => {
|
||||||
assert.equal(event.data, message)
|
assert.strictEqual(event.data, message)
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
worker.port.postMessage(message)
|
worker.port.postMessage(message)
|
||||||
|
@ -888,7 +888,7 @@ describe('chromium feature', () => {
|
||||||
it('SharedWorker has no node integration by default', (done) => {
|
it('SharedWorker has no node integration by default', (done) => {
|
||||||
let worker = new SharedWorker('../fixtures/workers/shared_worker_node.js')
|
let worker = new SharedWorker('../fixtures/workers/shared_worker_node.js')
|
||||||
worker.port.onmessage = (event) => {
|
worker.port.onmessage = (event) => {
|
||||||
assert.equal(event.data, 'undefined undefined undefined undefined')
|
assert.strictEqual(event.data, 'undefined undefined undefined undefined')
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -899,7 +899,7 @@ describe('chromium feature', () => {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
})
|
})
|
||||||
webview.addEventListener('ipc-message', (e) => {
|
webview.addEventListener('ipc-message', (e) => {
|
||||||
assert.equal(e.channel, 'object function object function')
|
assert.strictEqual(e.channel, 'object function object function')
|
||||||
webview.remove()
|
webview.remove()
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
@ -924,7 +924,7 @@ describe('chromium feature', () => {
|
||||||
iframe.src = `file://${fixtures}/pages/set-global.html`
|
iframe.src = `file://${fixtures}/pages/set-global.html`
|
||||||
document.body.appendChild(iframe)
|
document.body.appendChild(iframe)
|
||||||
iframe.onload = () => {
|
iframe.onload = () => {
|
||||||
assert.equal(iframe.contentWindow.test, 'undefined undefined undefined')
|
assert.strictEqual(iframe.contentWindow.test, 'undefined undefined undefined')
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -933,7 +933,7 @@ describe('chromium feature', () => {
|
||||||
describe('storage', () => {
|
describe('storage', () => {
|
||||||
it('requesting persitent quota works', (done) => {
|
it('requesting persitent quota works', (done) => {
|
||||||
navigator.webkitPersistentStorage.requestQuota(1024 * 1024, (grantedBytes) => {
|
navigator.webkitPersistentStorage.requestQuota(1024 * 1024, (grantedBytes) => {
|
||||||
assert.equal(grantedBytes, 1048576)
|
assert.strictEqual(grantedBytes, 1048576)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -973,7 +973,7 @@ describe('chromium feature', () => {
|
||||||
|
|
||||||
it('cannot access localStorage', (done) => {
|
it('cannot access localStorage', (done) => {
|
||||||
ipcMain.once('local-storage-response', (event, error) => {
|
ipcMain.once('local-storage-response', (event, error) => {
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
error,
|
error,
|
||||||
'Failed to read the \'localStorage\' property from \'Window\': Access is denied for this document.')
|
'Failed to read the \'localStorage\' property from \'Window\': Access is denied for this document.')
|
||||||
done()
|
done()
|
||||||
|
@ -983,7 +983,7 @@ describe('chromium feature', () => {
|
||||||
|
|
||||||
it('cannot access sessionStorage', (done) => {
|
it('cannot access sessionStorage', (done) => {
|
||||||
ipcMain.once('session-storage-response', (event, error) => {
|
ipcMain.once('session-storage-response', (event, error) => {
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
error,
|
error,
|
||||||
'Failed to read the \'sessionStorage\' property from \'Window\': Access is denied for this document.')
|
'Failed to read the \'sessionStorage\' property from \'Window\': Access is denied for this document.')
|
||||||
done()
|
done()
|
||||||
|
@ -993,7 +993,7 @@ describe('chromium feature', () => {
|
||||||
|
|
||||||
it('cannot access WebSQL database', (done) => {
|
it('cannot access WebSQL database', (done) => {
|
||||||
ipcMain.once('web-sql-response', (event, error) => {
|
ipcMain.once('web-sql-response', (event, error) => {
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
error,
|
error,
|
||||||
'An attempt was made to break through the security policy of the user agent.')
|
'An attempt was made to break through the security policy of the user agent.')
|
||||||
done()
|
done()
|
||||||
|
@ -1003,7 +1003,7 @@ describe('chromium feature', () => {
|
||||||
|
|
||||||
it('cannot access indexedDB', (done) => {
|
it('cannot access indexedDB', (done) => {
|
||||||
ipcMain.once('indexed-db-response', (event, error) => {
|
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()
|
done()
|
||||||
})
|
})
|
||||||
contents.loadURL(`${protocolName}://host/indexedDB`)
|
contents.loadURL(`${protocolName}://host/indexedDB`)
|
||||||
|
@ -1148,15 +1148,15 @@ describe('chromium feature', () => {
|
||||||
|
|
||||||
this.createBrowserWindow({ plugins: true, preload: preloadFile })
|
this.createBrowserWindow({ plugins: true, preload: preloadFile })
|
||||||
ipcMain.once('pdf-loaded', (event, state) => {
|
ipcMain.once('pdf-loaded', (event, state) => {
|
||||||
assert.equal(state, 'success')
|
assert.strictEqual(state, 'success')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.webContents.on('page-title-updated', () => {
|
w.webContents.on('page-title-updated', () => {
|
||||||
const parsedURL = url.parse(w.webContents.getURL(), true)
|
const parsedURL = url.parse(w.webContents.getURL(), true)
|
||||||
assert.equal(parsedURL.protocol, 'chrome:')
|
assert.strictEqual(parsedURL.protocol, 'chrome:')
|
||||||
assert.equal(parsedURL.hostname, 'pdf-viewer')
|
assert.strictEqual(parsedURL.hostname, 'pdf-viewer')
|
||||||
assert.equal(parsedURL.query.src, pagePath)
|
assert.strictEqual(parsedURL.query.src, pagePath)
|
||||||
assert.equal(w.webContents.getTitle(), 'cat.pdf')
|
assert.strictEqual(w.webContents.getTitle(), 'cat.pdf')
|
||||||
})
|
})
|
||||||
w.loadFile(path.join(fixtures, 'pages', page))
|
w.loadFile(path.join(fixtures, 'pages', page))
|
||||||
}
|
}
|
||||||
|
@ -1165,15 +1165,15 @@ describe('chromium feature', () => {
|
||||||
it('opens when loading a pdf resource as top level navigation', (done) => {
|
it('opens when loading a pdf resource as top level navigation', (done) => {
|
||||||
this.createBrowserWindow({ plugins: true, preload: 'preload-pdf-loaded.js' })
|
this.createBrowserWindow({ plugins: true, preload: 'preload-pdf-loaded.js' })
|
||||||
ipcMain.once('pdf-loaded', (event, state) => {
|
ipcMain.once('pdf-loaded', (event, state) => {
|
||||||
assert.equal(state, 'success')
|
assert.strictEqual(state, 'success')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.webContents.on('page-title-updated', () => {
|
w.webContents.on('page-title-updated', () => {
|
||||||
const parsedURL = url.parse(w.webContents.getURL(), true)
|
const parsedURL = url.parse(w.webContents.getURL(), true)
|
||||||
assert.equal(parsedURL.protocol, 'chrome:')
|
assert.strictEqual(parsedURL.protocol, 'chrome:')
|
||||||
assert.equal(parsedURL.hostname, 'pdf-viewer')
|
assert.strictEqual(parsedURL.hostname, 'pdf-viewer')
|
||||||
assert.equal(parsedURL.query.src, this.pdfSource)
|
assert.strictEqual(parsedURL.query.src, this.pdfSource)
|
||||||
assert.equal(w.webContents.getTitle(), 'cat.pdf')
|
assert.strictEqual(w.webContents.getTitle(), 'cat.pdf')
|
||||||
})
|
})
|
||||||
w.webContents.loadURL(this.pdfSource)
|
w.webContents.loadURL(this.pdfSource)
|
||||||
})
|
})
|
||||||
|
@ -1181,17 +1181,17 @@ describe('chromium feature', () => {
|
||||||
it('opens a pdf link given params, the query string should be escaped', (done) => {
|
it('opens a pdf link given params, the query string should be escaped', (done) => {
|
||||||
this.createBrowserWindow({ plugins: true, preload: 'preload-pdf-loaded.js' })
|
this.createBrowserWindow({ plugins: true, preload: 'preload-pdf-loaded.js' })
|
||||||
ipcMain.once('pdf-loaded', (event, state) => {
|
ipcMain.once('pdf-loaded', (event, state) => {
|
||||||
assert.equal(state, 'success')
|
assert.strictEqual(state, 'success')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.webContents.on('page-title-updated', () => {
|
w.webContents.on('page-title-updated', () => {
|
||||||
const parsedURL = url.parse(w.webContents.getURL(), true)
|
const parsedURL = url.parse(w.webContents.getURL(), true)
|
||||||
assert.equal(parsedURL.protocol, 'chrome:')
|
assert.strictEqual(parsedURL.protocol, 'chrome:')
|
||||||
assert.equal(parsedURL.hostname, 'pdf-viewer')
|
assert.strictEqual(parsedURL.hostname, 'pdf-viewer')
|
||||||
assert.equal(parsedURL.query.src, this.pdfSourceWithParams)
|
assert.strictEqual(parsedURL.query.src, this.pdfSourceWithParams)
|
||||||
assert.equal(parsedURL.query.b, undefined)
|
assert.strictEqual(parsedURL.query.b, undefined)
|
||||||
assert(parsedURL.search.endsWith('%3Fa%3D1%26b%3D2'))
|
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)
|
w.webContents.loadURL(this.pdfSourceWithParams)
|
||||||
})
|
})
|
||||||
|
@ -1200,9 +1200,9 @@ describe('chromium feature', () => {
|
||||||
this.createBrowserWindow({ plugins: false, preload: 'preload-pdf-loaded.js' })
|
this.createBrowserWindow({ plugins: false, preload: 'preload-pdf-loaded.js' })
|
||||||
ipcRenderer.sendSync('set-download-option', false, false)
|
ipcRenderer.sendSync('set-download-option', false, false)
|
||||||
ipcRenderer.once('download-done', (event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename) => {
|
ipcRenderer.once('download-done', (event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename) => {
|
||||||
assert.equal(state, 'completed')
|
assert.strictEqual(state, 'completed')
|
||||||
assert.equal(filename, 'cat.pdf')
|
assert.strictEqual(filename, 'cat.pdf')
|
||||||
assert.equal(mimeType, 'application/pdf')
|
assert.strictEqual(mimeType, 'application/pdf')
|
||||||
fs.unlinkSync(path.join(fixtures, 'mock.pdf'))
|
fs.unlinkSync(path.join(fixtures, 'mock.pdf'))
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
@ -1211,8 +1211,8 @@ describe('chromium feature', () => {
|
||||||
|
|
||||||
it('should not open when pdf is requested as sub resource', (done) => {
|
it('should not open when pdf is requested as sub resource', (done) => {
|
||||||
fetch(this.pdfSource).then((res) => {
|
fetch(this.pdfSource).then((res) => {
|
||||||
assert.equal(res.status, 200)
|
assert.strictEqual(res.status, 200)
|
||||||
assert.notEqual(document.title, 'cat.pdf')
|
assert.notStrictEqual(document.title, 'cat.pdf')
|
||||||
done()
|
done()
|
||||||
}).catch((e) => done(e))
|
}).catch((e) => done(e))
|
||||||
})
|
})
|
||||||
|
@ -1256,11 +1256,11 @@ describe('chromium feature', () => {
|
||||||
w = new BrowserWindow({ show: false })
|
w = new BrowserWindow({ show: false })
|
||||||
w.webContents.once('did-finish-load', () => {
|
w.webContents.once('did-finish-load', () => {
|
||||||
// History should have current page by now.
|
// 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({}, "")', () => {
|
w.webContents.executeJavaScript('window.history.pushState({}, "")', () => {
|
||||||
// Initial page + pushed state
|
// Initial page + pushed state
|
||||||
assert.equal(w.webContents.length(), 2)
|
assert.strictEqual(w.webContents.length(), 2)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
4
spec/fixtures/module/delete-buffer.js
vendored
4
spec/fixtures/module/delete-buffer.js
vendored
|
@ -6,6 +6,6 @@ delete window.Buffer
|
||||||
delete global.Buffer
|
delete global.Buffer
|
||||||
|
|
||||||
// Test that remote.js doesn't use Buffer global
|
// 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')
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe('modules support', () => {
|
||||||
const runas = path.join(fixtures, 'module', 'runas.js')
|
const runas = path.join(fixtures, 'module', 'runas.js')
|
||||||
const child = require('child_process').fork(runas)
|
const child = require('child_process').fork(runas)
|
||||||
child.on('message', (msg) => {
|
child.on('message', (msg) => {
|
||||||
assert.equal(msg, 'ok')
|
assert.strictEqual(msg, 'ok')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -42,7 +42,7 @@ describe('modules support', () => {
|
||||||
const libm = ffi.Library('libm', {
|
const libm = ffi.Library('libm', {
|
||||||
ceil: ['double', ['double']]
|
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', () => {
|
describe('Q.when', () => {
|
||||||
it('emits the fullfil callback', (done) => {
|
it('emits the fullfil callback', (done) => {
|
||||||
Q(true).then((val) => {
|
Q(true).then((val) => {
|
||||||
assert.equal(val, true)
|
assert.strictEqual(val, true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -92,7 +92,7 @@ describe('modules support', () => {
|
||||||
describe('when the path is inside the resources path', () => {
|
describe('when the path is inside the resources path', () => {
|
||||||
it('does not include paths outside of the resources path', () => {
|
it('does not include paths outside of the resources path', () => {
|
||||||
let modulePath = process.resourcesPath
|
let modulePath = process.resourcesPath
|
||||||
assert.deepEqual(Module._nodeModulePaths(modulePath), [
|
assert.deepStrictEqual(Module._nodeModulePaths(modulePath), [
|
||||||
path.join(process.resourcesPath, 'node_modules')
|
path.join(process.resourcesPath, 'node_modules')
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -102,26 +102,26 @@ describe('modules support', () => {
|
||||||
assert(nodeModulePaths.includes(path.join(modulePath, '..', 'node_modules')))
|
assert(nodeModulePaths.includes(path.join(modulePath, '..', 'node_modules')))
|
||||||
|
|
||||||
modulePath = path.join(process.resourcesPath, 'foo')
|
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, 'foo', 'node_modules'),
|
||||||
path.join(process.resourcesPath, 'node_modules')
|
path.join(process.resourcesPath, 'node_modules')
|
||||||
])
|
])
|
||||||
|
|
||||||
modulePath = path.join(process.resourcesPath, 'node_modules', 'foo')
|
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', 'foo', 'node_modules'),
|
||||||
path.join(process.resourcesPath, 'node_modules')
|
path.join(process.resourcesPath, 'node_modules')
|
||||||
])
|
])
|
||||||
|
|
||||||
modulePath = path.join(process.resourcesPath, 'node_modules', 'foo', 'bar')
|
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', 'bar', 'node_modules'),
|
||||||
path.join(process.resourcesPath, 'node_modules', 'foo', 'node_modules'),
|
path.join(process.resourcesPath, 'node_modules', 'foo', 'node_modules'),
|
||||||
path.join(process.resourcesPath, 'node_modules')
|
path.join(process.resourcesPath, 'node_modules')
|
||||||
])
|
])
|
||||||
|
|
||||||
modulePath = path.join(process.resourcesPath, 'node_modules', 'foo', 'node_modules', 'bar')
|
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', 'bar', 'node_modules'),
|
||||||
path.join(process.resourcesPath, 'node_modules', 'foo', 'node_modules'),
|
path.join(process.resourcesPath, 'node_modules', 'foo', 'node_modules'),
|
||||||
path.join(process.resourcesPath, 'node_modules')
|
path.join(process.resourcesPath, 'node_modules')
|
||||||
|
@ -132,7 +132,7 @@ describe('modules support', () => {
|
||||||
describe('when the path is outside the resources path', () => {
|
describe('when the path is outside the resources path', () => {
|
||||||
it('includes paths outside of the resources path', () => {
|
it('includes paths outside of the resources path', () => {
|
||||||
let modulePath = path.resolve('/foo')
|
let modulePath = path.resolve('/foo')
|
||||||
assert.deepEqual(Module._nodeModulePaths(modulePath), [
|
assert.deepStrictEqual(Module._nodeModulePaths(modulePath), [
|
||||||
path.join(modulePath, 'node_modules'),
|
path.join(modulePath, 'node_modules'),
|
||||||
path.resolve('/node_modules')
|
path.resolve('/node_modules')
|
||||||
])
|
])
|
||||||
|
@ -156,7 +156,7 @@ describe('modules support', () => {
|
||||||
it('searches for module under app directory', async () => {
|
it('searches for module under app directory', async () => {
|
||||||
w.loadURL('about:blank')
|
w.loadURL('about:blank')
|
||||||
const result = await w.webContents.executeJavaScript('typeof require("q").when')
|
const result = await w.webContents.executeJavaScript('typeof require("q").when')
|
||||||
assert.equal(result, 'function')
|
assert.strictEqual(result, 'function')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe('node feature', () => {
|
||||||
it('works in current process', (done) => {
|
it('works in current process', (done) => {
|
||||||
const child = ChildProcess.fork(path.join(fixtures, 'module', 'ping.js'))
|
const child = ChildProcess.fork(path.join(fixtures, 'module', 'ping.js'))
|
||||||
child.on('message', (msg) => {
|
child.on('message', (msg) => {
|
||||||
assert.equal(msg, 'message')
|
assert.strictEqual(msg, 'message')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
child.send('message')
|
child.send('message')
|
||||||
|
@ -25,7 +25,7 @@ describe('node feature', () => {
|
||||||
const args = ['--expose_gc', '-test', '1']
|
const args = ['--expose_gc', '-test', '1']
|
||||||
const child = ChildProcess.fork(path.join(fixtures, 'module', 'process_args.js'), args)
|
const child = ChildProcess.fork(path.join(fixtures, 'module', 'process_args.js'), args)
|
||||||
child.on('message', (msg) => {
|
child.on('message', (msg) => {
|
||||||
assert.deepEqual(args, msg.slice(2))
|
assert.deepStrictEqual(args, msg.slice(2))
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
child.send('message')
|
child.send('message')
|
||||||
|
@ -34,7 +34,7 @@ describe('node feature', () => {
|
||||||
it('works in forked process', (done) => {
|
it('works in forked process', (done) => {
|
||||||
const child = ChildProcess.fork(path.join(fixtures, 'module', 'fork_ping.js'))
|
const child = ChildProcess.fork(path.join(fixtures, 'module', 'fork_ping.js'))
|
||||||
child.on('message', (msg) => {
|
child.on('message', (msg) => {
|
||||||
assert.equal(msg, 'message')
|
assert.strictEqual(msg, 'message')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
child.send('message')
|
child.send('message')
|
||||||
|
@ -45,7 +45,7 @@ describe('node feature', () => {
|
||||||
path: process.env['PATH']
|
path: process.env['PATH']
|
||||||
})
|
})
|
||||||
child.on('message', (msg) => {
|
child.on('message', (msg) => {
|
||||||
assert.equal(msg, 'message')
|
assert.strictEqual(msg, 'message')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
child.send('message')
|
child.send('message')
|
||||||
|
@ -55,7 +55,7 @@ describe('node feature', () => {
|
||||||
const fork = remote.require('child_process').fork
|
const fork = remote.require('child_process').fork
|
||||||
const child = fork(path.join(fixtures, 'module', 'ping.js'))
|
const child = fork(path.join(fixtures, 'module', 'ping.js'))
|
||||||
child.on('message', (msg) => {
|
child.on('message', (msg) => {
|
||||||
assert.equal(msg, 'message')
|
assert.strictEqual(msg, 'message')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
child.send('message')
|
child.send('message')
|
||||||
|
@ -64,7 +64,7 @@ describe('node feature', () => {
|
||||||
it('has String::localeCompare working in script', (done) => {
|
it('has String::localeCompare working in script', (done) => {
|
||||||
const child = ChildProcess.fork(path.join(fixtures, 'module', 'locale-compare.js'))
|
const child = ChildProcess.fork(path.join(fixtures, 'module', 'locale-compare.js'))
|
||||||
child.on('message', (msg) => {
|
child.on('message', (msg) => {
|
||||||
assert.deepEqual(msg, [0, -1, 1])
|
assert.deepStrictEqual(msg, [0, -1, 1])
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
child.send('message')
|
child.send('message')
|
||||||
|
@ -73,7 +73,7 @@ describe('node feature', () => {
|
||||||
it('has setImmediate working in script', (done) => {
|
it('has setImmediate working in script', (done) => {
|
||||||
const child = ChildProcess.fork(path.join(fixtures, 'module', 'set-immediate.js'))
|
const child = ChildProcess.fork(path.join(fixtures, 'module', 'set-immediate.js'))
|
||||||
child.on('message', (msg) => {
|
child.on('message', (msg) => {
|
||||||
assert.equal(msg, 'ok')
|
assert.strictEqual(msg, 'ok')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
child.send('message')
|
child.send('message')
|
||||||
|
@ -86,8 +86,8 @@ describe('node feature', () => {
|
||||||
data += String(chunk)
|
data += String(chunk)
|
||||||
})
|
})
|
||||||
child.on('close', (code) => {
|
child.on('close', (code) => {
|
||||||
assert.equal(code, 0)
|
assert.strictEqual(code, 0)
|
||||||
assert.equal(data, 'pipes stdio')
|
assert.strictEqual(data, 'pipes stdio')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -96,7 +96,7 @@ describe('node feature', () => {
|
||||||
const source = "process.on('message', (message) => { process.send(message) })"
|
const source = "process.on('message', (message) => { process.send(message) })"
|
||||||
const forked = ChildProcess.fork('--eval', [source])
|
const forked = ChildProcess.fork('--eval', [source])
|
||||||
forked.once('message', (message) => {
|
forked.once('message', (message) => {
|
||||||
assert.equal(message, 'hello')
|
assert.strictEqual(message, 'hello')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
forked.send('hello')
|
forked.send('hello')
|
||||||
|
@ -122,7 +122,7 @@ describe('node feature', () => {
|
||||||
output += data
|
output += data
|
||||||
})
|
})
|
||||||
child.stdout.on('close', () => {
|
child.stdout.on('close', () => {
|
||||||
assert.deepEqual(JSON.parse(output), {
|
assert.deepStrictEqual(JSON.parse(output), {
|
||||||
processLog: process.platform === 'win32' ? 'function' : 'undefined',
|
processLog: process.platform === 'win32' ? 'function' : 'undefined',
|
||||||
processType: 'undefined',
|
processType: 'undefined',
|
||||||
window: 'undefined'
|
window: 'undefined'
|
||||||
|
@ -164,14 +164,14 @@ describe('node feature', () => {
|
||||||
describe('error thrown in main process node context', () => {
|
describe('error thrown in main process node context', () => {
|
||||||
it('gets emitted as a process uncaughtException event', () => {
|
it('gets emitted as a process uncaughtException event', () => {
|
||||||
const error = ipcRenderer.sendSync('handle-uncaught-exception', 'hello')
|
const error = ipcRenderer.sendSync('handle-uncaught-exception', 'hello')
|
||||||
assert.equal(error, 'hello')
|
assert.strictEqual(error, 'hello')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('promise rejection in main process node context', () => {
|
describe('promise rejection in main process node context', () => {
|
||||||
it('gets emitted as a process unhandledRejection event', () => {
|
it('gets emitted as a process unhandledRejection event', () => {
|
||||||
const error = ipcRenderer.sendSync('handle-unhandled-rejection', 'hello')
|
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 }) => {
|
child.on('message', ({ cmd, debuggerEnabled, secondSessionOpened, success }) => {
|
||||||
if (cmd === 'assert') {
|
if (cmd === 'assert') {
|
||||||
assert.equal(debuggerEnabled, true)
|
assert.strictEqual(debuggerEnabled, true)
|
||||||
assert.equal(secondSessionOpened, true)
|
assert.strictEqual(secondSessionOpened, true)
|
||||||
assert.equal(success, true)
|
assert.strictEqual(success, true)
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -291,10 +291,10 @@ describe('node feature', () => {
|
||||||
const script = path.join(fixtures, 'module', 'create_socket.js')
|
const script = path.join(fixtures, 'module', 'create_socket.js')
|
||||||
const child = ChildProcess.fork(script, [socketPath])
|
const child = ChildProcess.fork(script, [socketPath])
|
||||||
child.on('exit', (code) => {
|
child.on('exit', (code) => {
|
||||||
assert.equal(code, 0)
|
assert.strictEqual(code, 0)
|
||||||
const client = require('net').connect(socketPath)
|
const client = require('net').connect(socketPath)
|
||||||
client.on('error', (error) => {
|
client.on('error', (error) => {
|
||||||
assert.equal(error.code, 'ECONNREFUSED')
|
assert.strictEqual(error.code, 'ECONNREFUSED')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -306,23 +306,23 @@ describe('node feature', () => {
|
||||||
const p = document.createElement('p')
|
const p = document.createElement('p')
|
||||||
p.innerText = '闲云潭影日悠悠,物换星移几度秋'
|
p.innerText = '闲云潭影日悠悠,物换星移几度秋'
|
||||||
const b = Buffer.from(p.innerText)
|
const b = Buffer.from(p.innerText)
|
||||||
assert.equal(b.toString(), '闲云潭影日悠悠,物换星移几度秋')
|
assert.strictEqual(b.toString(), '闲云潭影日悠悠,物换星移几度秋')
|
||||||
assert.equal(Buffer.byteLength(p.innerText), 45)
|
assert.strictEqual(Buffer.byteLength(p.innerText), 45)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('correctly parses external one-byte UTF8 string', () => {
|
it('correctly parses external one-byte UTF8 string', () => {
|
||||||
const p = document.createElement('p')
|
const p = document.createElement('p')
|
||||||
p.innerText = 'Jøhänñéß'
|
p.innerText = 'Jøhänñéß'
|
||||||
const b = Buffer.from(p.innerText)
|
const b = Buffer.from(p.innerText)
|
||||||
assert.equal(b.toString(), 'Jøhänñéß')
|
assert.strictEqual(b.toString(), 'Jøhänñéß')
|
||||||
assert.equal(Buffer.byteLength(p.innerText), 13)
|
assert.strictEqual(Buffer.byteLength(p.innerText), 13)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does not crash when creating large Buffers', () => {
|
it('does not crash when creating large Buffers', () => {
|
||||||
let buffer = Buffer.from(new Array(4096).join(' '))
|
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(' '))
|
buffer = Buffer.from(new Array(4097).join(' '))
|
||||||
assert.equal(buffer.length, 4096)
|
assert.strictEqual(buffer.length, 4096)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does not crash for crypto operations', () => {
|
it('does not crash for crypto operations', () => {
|
||||||
|
@ -335,7 +335,7 @@ describe('node feature', () => {
|
||||||
let input = Buffer.from(data, 'base64')
|
let input = Buffer.from(data, 'base64')
|
||||||
let decipher = crypto.createDecipheriv('aes-128-cbc', Buffer.from(key, 'base64'), iv)
|
let decipher = crypto.createDecipheriv('aes-128-cbc', Buffer.from(key, 'base64'), iv)
|
||||||
let result = Buffer.concat([decipher.update(input), decipher.final()])
|
let result = Buffer.concat([decipher.update(input), decipher.final()])
|
||||||
assert.equal(cipherText, result)
|
assert.strictEqual(cipherText, result)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -361,7 +361,7 @@ describe('node feature', () => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.equal(typeof process.stdout.isTTY, 'boolean')
|
assert.strictEqual(typeof process.stdout.isTTY, 'boolean')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should have isTTY undefined on Windows', function () {
|
it('should have isTTY undefined on Windows', function () {
|
||||||
|
@ -371,7 +371,7 @@ describe('node feature', () => {
|
||||||
return
|
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', () => {
|
it('returns null when read from', () => {
|
||||||
assert.equal(process.stdin.read(), null)
|
assert.strictEqual(process.stdin.read(), null)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -124,11 +124,11 @@ describe('<webview> tag', function () {
|
||||||
const message = await startLoadingWebViewAndWaitForMessage(webview, {
|
const message = await startLoadingWebViewAndWaitForMessage(webview, {
|
||||||
src: '../fixtures/pages/e.html'
|
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', () => {
|
it('ignores empty values', () => {
|
||||||
assert.equal(webview.src, '')
|
assert.strictEqual(webview.src, '')
|
||||||
|
|
||||||
for (const emptyValue of ['', null, undefined]) {
|
for (const emptyValue of ['', null, undefined]) {
|
||||||
webview.src = emptyValue
|
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) => {
|
it('disables node integration on child windows when it is disabled on the webview', (done) => {
|
||||||
app.once('browser-window-created', (event, window) => {
|
app.once('browser-window-created', (event, window) => {
|
||||||
assert.equal(window.webContents.getWebPreferences().nodeIntegration, false)
|
assert.strictEqual(window.webContents.getWebPreferences().nodeIntegration, false)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ describe('<webview> tag', function () {
|
||||||
webview.reload()
|
webview.reload()
|
||||||
|
|
||||||
const { message } = await waitForEvent(webview, 'console-message')
|
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)
|
webview.send('ping', message)
|
||||||
|
|
||||||
const { channel, args } = await waitForEvent(webview, 'ipc-message')
|
const { channel, args } = await waitForEvent(webview, 'ipc-message')
|
||||||
assert.equal(channel, 'pong')
|
assert.strictEqual(channel, 'pong')
|
||||||
assert.deepEqual(args, [message])
|
assert.deepStrictEqual(args, [message])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('works without script tag in page', async () => {
|
it('works without script tag in page', async () => {
|
||||||
|
@ -317,11 +317,11 @@ describe('<webview> tag', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('ignores empty values', () => {
|
it('ignores empty values', () => {
|
||||||
assert.equal(webview.preload, '')
|
assert.strictEqual(webview.preload, '')
|
||||||
|
|
||||||
for (const emptyValue of ['', null, undefined]) {
|
for (const emptyValue of ['', null, undefined]) {
|
||||||
webview.preload = emptyValue
|
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) => {
|
const server = http.createServer((req, res) => {
|
||||||
res.end()
|
res.end()
|
||||||
server.close()
|
server.close()
|
||||||
assert.equal(req.headers.referer, referrer)
|
assert.strictEqual(req.headers.referer, referrer)
|
||||||
done()
|
done()
|
||||||
}).listen(0, '127.0.0.1', () => {
|
}).listen(0, '127.0.0.1', () => {
|
||||||
const port = server.address().port
|
const port = server.address().port
|
||||||
|
@ -528,7 +528,7 @@ describe('<webview> tag', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
const [, data] = await emittedOnce(ipcMain, 'isolated-world')
|
const [, data] = await emittedOnce(ipcMain, 'isolated-world')
|
||||||
assert.deepEqual(data, {
|
assert.deepStrictEqual(data, {
|
||||||
preloadContext: {
|
preloadContext: {
|
||||||
preloadProperty: 'number',
|
preloadProperty: 'number',
|
||||||
pageProperty: 'undefined',
|
pageProperty: 'undefined',
|
||||||
|
@ -559,8 +559,8 @@ describe('<webview> tag', function () {
|
||||||
})
|
})
|
||||||
const { url, frameName } = await waitForEvent(webview, 'new-window')
|
const { url, frameName } = await waitForEvent(webview, 'new-window')
|
||||||
|
|
||||||
assert.equal(url, 'http://host/')
|
assert.strictEqual(url, 'http://host/')
|
||||||
assert.equal(frameName, 'host')
|
assert.strictEqual(frameName, 'host')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('emits when link with target is called', async () => {
|
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')
|
const { url, frameName } = await waitForEvent(webview, 'new-window')
|
||||||
|
|
||||||
assert.equal(url, 'http://host/')
|
assert.strictEqual(url, 'http://host/')
|
||||||
assert.equal(frameName, 'target')
|
assert.strictEqual(frameName, 'target')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -582,8 +582,8 @@ describe('<webview> tag', function () {
|
||||||
})
|
})
|
||||||
const { channel, args } = await waitForEvent(webview, 'ipc-message')
|
const { channel, args } = await waitForEvent(webview, 'ipc-message')
|
||||||
|
|
||||||
assert.equal(channel, 'channel')
|
assert.strictEqual(channel, 'channel')
|
||||||
assert.deepEqual(args, ['arg1', 'arg2'])
|
assert.deepStrictEqual(args, ['arg1', 'arg2'])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -594,7 +594,7 @@ describe('<webview> tag', function () {
|
||||||
})
|
})
|
||||||
const { title, explicitSet } = await waitForEvent(webview, 'page-title-set')
|
const { title, explicitSet } = await waitForEvent(webview, 'page-title-set')
|
||||||
|
|
||||||
assert.equal(title, 'test')
|
assert.strictEqual(title, 'test')
|
||||||
assert(explicitSet)
|
assert(explicitSet)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -607,11 +607,11 @@ describe('<webview> tag', function () {
|
||||||
const { favicons } = await waitForEvent(webview, 'page-favicon-updated')
|
const { favicons } = await waitForEvent(webview, 'page-favicon-updated')
|
||||||
|
|
||||||
assert(favicons)
|
assert(favicons)
|
||||||
assert.equal(favicons.length, 2)
|
assert.strictEqual(favicons.length, 2)
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
assert(/^file:\/\/\/[A-Z]:\/favicon.png$/i.test(favicons[0]))
|
assert(/^file:\/\/\/[A-Z]:\/favicon.png$/i.test(favicons[0]))
|
||||||
} else {
|
} 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')
|
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 })
|
loadWebView(webview, { src: pageUrl })
|
||||||
const { url } = await waitForEvent(webview, 'did-navigate')
|
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 })
|
loadWebView(webview, { src: pageUrl })
|
||||||
const event = await waitForEvent(webview, 'did-navigate-in-page')
|
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 () => {
|
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`
|
src: `file://${fixtures}/pages/webview-did-navigate-in-page-with-history.html`
|
||||||
})
|
})
|
||||||
const { url } = await waitForEvent(webview, 'did-navigate-in-page')
|
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 () => {
|
it('emits when window.location.hash is changed', async () => {
|
||||||
|
@ -676,7 +676,7 @@ describe('<webview> tag', function () {
|
||||||
})
|
})
|
||||||
loadWebView(webview, { src: pageUrl })
|
loadWebView(webview, { src: pageUrl })
|
||||||
const event = await waitForEvent(webview, 'did-navigate-in-page')
|
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()
|
webview.reload()
|
||||||
|
|
||||||
const { channel } = await waitForOnbeforeunload
|
const { channel } = await waitForOnbeforeunload
|
||||||
assert.equal(channel, 'onbeforeunload')
|
assert.strictEqual(channel, 'onbeforeunload')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -785,13 +785,13 @@ describe('<webview> tag', function () {
|
||||||
let loadCount = 1
|
let loadCount = 1
|
||||||
const listener = (e) => {
|
const listener = (e) => {
|
||||||
if (loadCount === 1) {
|
if (loadCount === 1) {
|
||||||
assert.equal(e.channel, 'history')
|
assert.strictEqual(e.channel, 'history')
|
||||||
assert.equal(e.args[0], 1)
|
assert.strictEqual(e.args[0], 1)
|
||||||
assert(!webview.canGoBack())
|
assert(!webview.canGoBack())
|
||||||
assert(!webview.canGoForward())
|
assert(!webview.canGoForward())
|
||||||
} else if (loadCount === 2) {
|
} else if (loadCount === 2) {
|
||||||
assert.equal(e.channel, 'history')
|
assert.strictEqual(e.channel, 'history')
|
||||||
assert.equal(e.args[0], 2)
|
assert.strictEqual(e.args[0], 2)
|
||||||
assert(!webview.canGoBack())
|
assert(!webview.canGoBack())
|
||||||
assert(webview.canGoForward())
|
assert(webview.canGoForward())
|
||||||
webview.removeEventListener('ipc-message', listener)
|
webview.removeEventListener('ipc-message', listener)
|
||||||
|
@ -837,8 +837,8 @@ describe('<webview> tag', function () {
|
||||||
})
|
})
|
||||||
const event = await waitForEvent(webview, 'ipc-message')
|
const event = await waitForEvent(webview, 'ipc-message')
|
||||||
|
|
||||||
assert.equal(event.channel, 'history')
|
assert.strictEqual(event.channel, 'history')
|
||||||
assert.equal(event.args[0], 2)
|
assert.strictEqual(event.args[0], 2)
|
||||||
assert(webview.canGoBack())
|
assert(webview.canGoBack())
|
||||||
|
|
||||||
webview.clearHistory()
|
webview.clearHistory()
|
||||||
|
@ -863,7 +863,7 @@ describe('<webview> tag', function () {
|
||||||
server.listen(0, '127.0.0.1', () => {
|
server.listen(0, '127.0.0.1', () => {
|
||||||
const port = server.address().port
|
const port = server.address().port
|
||||||
webview.addEventListener('ipc-message', (e) => {
|
webview.addEventListener('ipc-message', (e) => {
|
||||||
assert.equal(e.channel, message)
|
assert.strictEqual(e.channel, message)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
loadWebView(webview, {
|
loadWebView(webview, {
|
||||||
|
@ -925,7 +925,7 @@ describe('<webview> tag', function () {
|
||||||
resolve(result)
|
resolve(result)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
assert.equal(result, expectedResult)
|
assert.strictEqual(result, expectedResult)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -945,8 +945,8 @@ describe('<webview> tag', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
const { channel, args } = await waitForIpcMessage
|
const { channel, args } = await waitForIpcMessage
|
||||||
assert.equal(channel, 'keyup')
|
assert.strictEqual(channel, 'keyup')
|
||||||
assert.deepEqual(args, ['C', 'KeyC', 67, true, false])
|
assert.deepStrictEqual(args, ['C', 'KeyC', 67, true, false])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can send mouse event', async () => {
|
it('can send mouse event', async () => {
|
||||||
|
@ -965,8 +965,8 @@ describe('<webview> tag', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
const { channel, args } = await waitForIpcMessage
|
const { channel, args } = await waitForIpcMessage
|
||||||
assert.equal(channel, 'mouseup')
|
assert.strictEqual(channel, 'mouseup')
|
||||||
assert.deepEqual(args, [10, 20, false, true])
|
assert.deepStrictEqual(args, [10, 20, false, true])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -990,11 +990,11 @@ describe('<webview> tag', function () {
|
||||||
let requestId = null
|
let requestId = null
|
||||||
let activeMatchOrdinal = []
|
let activeMatchOrdinal = []
|
||||||
const listener = (e) => {
|
const listener = (e) => {
|
||||||
assert.equal(e.result.requestId, requestId)
|
assert.strictEqual(e.result.requestId, requestId)
|
||||||
assert.equal(e.result.matches, 3)
|
assert.strictEqual(e.result.matches, 3)
|
||||||
activeMatchOrdinal.push(e.result.activeMatchOrdinal)
|
activeMatchOrdinal.push(e.result.activeMatchOrdinal)
|
||||||
if (e.result.activeMatchOrdinal === e.result.matches) {
|
if (e.result.activeMatchOrdinal === e.result.matches) {
|
||||||
assert.deepEqual(activeMatchOrdinal, [1, 2, 3])
|
assert.deepStrictEqual(activeMatchOrdinal, [1, 2, 3])
|
||||||
webview.stopFindInPage('clearSelection')
|
webview.stopFindInPage('clearSelection')
|
||||||
done()
|
done()
|
||||||
} else {
|
} else {
|
||||||
|
@ -1036,7 +1036,7 @@ describe('<webview> tag', function () {
|
||||||
return callback(true)
|
return callback(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.equal(permission, requestedPermission)
|
assert.strictEqual(permission, requestedPermission)
|
||||||
callback(false)
|
callback(false)
|
||||||
if (completed) completed()
|
if (completed) completed()
|
||||||
}
|
}
|
||||||
|
@ -1048,8 +1048,8 @@ describe('<webview> tag', function () {
|
||||||
if (isCI) return done()
|
if (isCI) return done()
|
||||||
|
|
||||||
webview.addEventListener('ipc-message', (e) => {
|
webview.addEventListener('ipc-message', (e) => {
|
||||||
assert.equal(e.channel, 'message')
|
assert.strictEqual(e.channel, 'message')
|
||||||
assert.deepEqual(e.args, ['PermissionDeniedError'])
|
assert.deepStrictEqual(e.args, ['PermissionDeniedError'])
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
webview.src = `file://${fixtures}/pages/permissions/media.html`
|
webview.src = `file://${fixtures}/pages/permissions/media.html`
|
||||||
|
@ -1061,8 +1061,8 @@ describe('<webview> tag', function () {
|
||||||
|
|
||||||
it('emits when using navigator.geolocation api', (done) => {
|
it('emits when using navigator.geolocation api', (done) => {
|
||||||
webview.addEventListener('ipc-message', (e) => {
|
webview.addEventListener('ipc-message', (e) => {
|
||||||
assert.equal(e.channel, 'message')
|
assert.strictEqual(e.channel, 'message')
|
||||||
assert.deepEqual(e.args, ['User denied Geolocation'])
|
assert.deepStrictEqual(e.args, ['User denied Geolocation'])
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
webview.src = `file://${fixtures}/pages/permissions/geolocation.html`
|
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) => {
|
it('emits when using navigator.requestMIDIAccess without sysex api', (done) => {
|
||||||
webview.addEventListener('ipc-message', (e) => {
|
webview.addEventListener('ipc-message', (e) => {
|
||||||
assert.equal(e.channel, 'message')
|
assert.strictEqual(e.channel, 'message')
|
||||||
assert.deepEqual(e.args, ['SecurityError'])
|
assert.deepStrictEqual(e.args, ['SecurityError'])
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
webview.src = `file://${fixtures}/pages/permissions/midi.html`
|
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) => {
|
it('emits when using navigator.requestMIDIAccess with sysex api', (done) => {
|
||||||
webview.addEventListener('ipc-message', (e) => {
|
webview.addEventListener('ipc-message', (e) => {
|
||||||
assert.equal(e.channel, 'message')
|
assert.strictEqual(e.channel, 'message')
|
||||||
assert.deepEqual(e.args, ['SecurityError'])
|
assert.deepStrictEqual(e.args, ['SecurityError'])
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
webview.src = `file://${fixtures}/pages/permissions/midi-sysex.html`
|
webview.src = `file://${fixtures}/pages/permissions/midi-sysex.html`
|
||||||
|
@ -1107,8 +1107,8 @@ describe('<webview> tag', function () {
|
||||||
|
|
||||||
it('emits when using Notification.requestPermission', (done) => {
|
it('emits when using Notification.requestPermission', (done) => {
|
||||||
webview.addEventListener('ipc-message', (e) => {
|
webview.addEventListener('ipc-message', (e) => {
|
||||||
assert.equal(e.channel, 'message')
|
assert.strictEqual(e.channel, 'message')
|
||||||
assert.deepEqual(e.args, ['granted'])
|
assert.deepStrictEqual(e.args, ['granted'])
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
webview.src = `file://${fixtures}/pages/permissions/notification.html`
|
webview.src = `file://${fixtures}/pages/permissions/notification.html`
|
||||||
|
@ -1116,7 +1116,7 @@ describe('<webview> tag', function () {
|
||||||
webview.setAttribute('nodeintegration', 'on')
|
webview.setAttribute('nodeintegration', 'on')
|
||||||
session.fromPartition(webview.partition).setPermissionRequestHandler((webContents, permission, callback) => {
|
session.fromPartition(webview.partition).setPermissionRequestHandler((webContents, permission, callback) => {
|
||||||
if (webContents.id === webview.getWebContents().id) {
|
if (webContents.id === webview.getWebContents().id) {
|
||||||
assert.equal(permission, 'notifications')
|
assert.strictEqual(permission, 'notifications')
|
||||||
setTimeout(() => { callback(true) }, 10)
|
setTimeout(() => { callback(true) }, 10)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1152,15 +1152,15 @@ describe('<webview> tag', function () {
|
||||||
|
|
||||||
const [, visibilityState, hidden] = await pongSignal2
|
const [, visibilityState, hidden] = await pongSignal2
|
||||||
assert(!hidden)
|
assert(!hidden)
|
||||||
assert.equal(visibilityState, 'visible')
|
assert.strictEqual(visibilityState, 'visible')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('inherits the parent window visibility state and receives visibilitychange events', async () => {
|
it('inherits the parent window visibility state and receives visibilitychange events', async () => {
|
||||||
const w = await openTheWindow({ show: false })
|
const w = await openTheWindow({ show: false })
|
||||||
w.loadFile(path.join(fixtures, 'pages', 'webview-visibilitychange.html'))
|
w.loadFile(path.join(fixtures, 'pages', 'webview-visibilitychange.html'))
|
||||||
let [, visibilityState, hidden] = await emittedOnce(ipcMain, 'pong')
|
let [, visibilityState, hidden] = await emittedOnce(ipcMain, 'pong')
|
||||||
assert.equal(visibilityState, 'hidden')
|
assert.strictEqual(visibilityState, 'hidden')
|
||||||
assert.equal(hidden, true)
|
assert.strictEqual(hidden, true)
|
||||||
|
|
||||||
// We have to start waiting for the event
|
// We have to start waiting for the event
|
||||||
// before we ask the webContents to resize.
|
// before we ask the webContents to resize.
|
||||||
|
@ -1168,8 +1168,8 @@ describe('<webview> tag', function () {
|
||||||
w.webContents.emit('-window-visibility-change', 'visible')
|
w.webContents.emit('-window-visibility-change', 'visible')
|
||||||
|
|
||||||
return getResponse.then(([, visibilityState, hidden]) => {
|
return getResponse.then(([, visibilityState, hidden]) => {
|
||||||
assert.equal(visibilityState, 'visible')
|
assert.strictEqual(visibilityState, 'visible')
|
||||||
assert.equal(hidden, false)
|
assert.strictEqual(hidden, false)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1221,7 +1221,7 @@ describe('<webview> tag', function () {
|
||||||
src: `file://${fixtures}/pages/a.html`
|
src: `file://${fixtures}/pages/a.html`
|
||||||
})
|
})
|
||||||
|
|
||||||
assert.equal(message, 'undefined')
|
assert.strictEqual(message, 'undefined')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue