mostly more globals

This commit is contained in:
Zeke Sikelianos 2016-03-28 16:11:00 -07:00 committed by Kevin Sawicki
parent c4b6cf4a8e
commit 9db733a4ff
6 changed files with 38 additions and 30 deletions

View file

@ -1,3 +1,5 @@
/* globals fetch */
const assert = require('assert') const assert = require('assert')
const path = require('path') const path = require('path')
const webFrame = require('electron').webFrame const webFrame = require('electron').webFrame

View file

@ -1,3 +1,5 @@
/* globals xit */
const assert = require('assert') const assert = require('assert')
const child_process = require('child_process') const child_process = require('child_process')
const fs = require('fs') const fs = require('fs')
@ -560,7 +562,9 @@ describe('asar package', function () {
if (process.platform !== 'darwin') { if (process.platform !== 'darwin') {
return return
} }
ref2 = require('child_process'), execFile = ref2.execFile, execFileSync = ref2.execFileSync ref2 = require('child_process')
execFile = ref2.execFile
execFileSync = ref2.execFileSync
echo = path.join(fixtures, 'asar', 'echo.asar', 'echo') echo = path.join(fixtures, 'asar', 'echo.asar', 'echo')
it('executes binaries', function (done) { it('executes binaries', function (done) {
@ -609,18 +613,18 @@ describe('asar package', function () {
it('disables asar support in sync API', function () { it('disables asar support in sync API', 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')
assert.throws((function () { assert.throws(function () {
fs.readFileSync(file) fs.readFileSync(file)
}), new RegExp(errorName)) }, new RegExp(errorName))
assert.throws((function () { assert.throws(function () {
fs.lstatSync(file) fs.lstatSync(file)
}), new RegExp(errorName)) }, new RegExp(errorName))
assert.throws((function () { assert.throws(function () {
fs.realpathSync(file) fs.realpathSync(file)
}), new RegExp(errorName)) }, new RegExp(errorName))
assert.throws((function () { assert.throws(function () {
fs.readdirSync(dir) fs.readdirSync(dir)
}), new RegExp(errorName)) }, new RegExp(errorName))
}) })
it('disables asar support in async API', function (done) { it('disables asar support in async API', function (done) {
@ -647,9 +651,9 @@ describe('asar package', function () {
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.equal(content1.compare(content2), 0)
assert.throws((function () { assert.throws(function () {
fs.readdirSync(asar) fs.readdirSync(asar)
}), /ENOTDIR/) }, /ENOTDIR/)
}) })
}) })
}) })
@ -785,9 +789,9 @@ describe('asar package', function () {
it('throws error when calling inside asar archive', function () { it('throws error when calling inside asar archive', function () {
var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist') var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
assert.throws((function () { assert.throws(function () {
mkdirp.sync(p) mkdirp.sync(p)
}), new RegExp('ENOTDIR')) }, new RegExp('ENOTDIR'))
}) })
}) })

View file

@ -1,3 +1,5 @@
/* globals xdescribe, Worker, SharedWorker, WebSocket, HTMLElement */
const assert = require('assert') const assert = require('assert')
const http = require('http') const http = require('http')
const path = require('path') const path = require('path')
@ -295,15 +297,15 @@ describe('chromium feature', function () {
describe('creating a Uint8Array under browser side', function () { describe('creating a Uint8Array under browser side', function () {
it('does not crash', function () { it('does not crash', function () {
var RUint8Array = remote.getGlobal('Uint8Array') var RUint8Array = remote.getGlobal('Uint8Array')
new RUint8Array var arr = new RUint8Array()
assert(arr)
}) })
}) })
describe('webgl', function () { describe('webgl', function () {
it('can be get as context in canvas', function () { it('can be get as context in canvas', function () {
if (process.platform === 'linux') { if (process.platform === 'linux') return
return
}
var webgl = document.createElement('canvas').getContext('webgl') var webgl = document.createElement('canvas').getContext('webgl')
assert.notEqual(webgl, null) assert.notEqual(webgl, null)
}) })
@ -387,7 +389,8 @@ describe('chromium feature', function () {
done('user agent is empty') done('user agent is empty')
} }
}) })
new WebSocket('ws://127.0.0.1:' + port) var socket = new WebSocket(`ws://127.0.0.1: ${port}`)
assert(socket)
}) })
}) })
}) })

View file

@ -24,6 +24,6 @@ class DerivedClass extends BaseClass {
} }
module.exports = { module.exports = {
base: new BaseClass, base: new BaseClass(),
derived: new DerivedClass, derived: new DerivedClass()
} }

View file

@ -116,7 +116,7 @@ app.on('ready', function () {
setImmediate(function () { setImmediate(function () {
try { try {
item.getURL() item.getURL()
} catch(err) { } catch (err) {
window.webContents.send('download-error', url, filename, err.message) window.webContents.send('download-error', url, filename, err.message)
} }
}) })
@ -132,8 +132,7 @@ app.on('ready', function () {
item.getContentDisposition(), item.getContentDisposition(),
item.getFilename()) item.getFilename())
}) })
if (need_cancel) if (need_cancel) item.cancel()
item.cancel()
} }
}) })
event.returnValue = 'done' event.returnValue = 'done'

View file

@ -45,7 +45,7 @@ function getIndexJsInServer (callback) {
request(TARGET_URL, function (e, res, body) { request(TARGET_URL, function (e, res, body) {
if (e) { if (e) {
callback(e) callback(e)
} else if (res.statusCode != 200) { } else if (res.statusCode !== 200) {
callback(new Error('Server returned ' + res.statusCode)) callback(new Error('Server returned ' + res.statusCode))
} else { } else {
callback(null, JSON.parse(body)) callback(null, JSON.parse(body))
@ -54,9 +54,9 @@ function getIndexJsInServer (callback) {
} }
function findObjectByVersion (all, version) { function findObjectByVersion (all, version) {
for (var i in all) for (var i in all) {
if (all[i].version == version) if (all[i].version === version) return i
return i }
return -1 return -1
} }
@ -69,11 +69,11 @@ app.on('ready', function () {
var current = getInfoForCurrentVersion() var current = getInfoForCurrentVersion()
var found = findObjectByVersion(all, current.version) var found = findObjectByVersion(all, current.version)
if (found == -1) if (found === -1) {
all.unshift(current) all.unshift(current)
else } else {
all[found] = current all[found] = current
}
fs.writeFileSync(process.argv[2], JSON.stringify(all)) fs.writeFileSync(process.argv[2], JSON.stringify(all))
process.exit(0) process.exit(0)
}) })