build: update eslint + eslint plugins (#22777)

* build: run eslint --fix

* chore: manually fix all hasOwnProperty errors

* chore: manually fix all void 0 vs undefined errors

* chore: manually fix all async-in-promise errors

* chore: manually fix lexical declaration in case block
This commit is contained in:
Samuel Attard 2020-03-20 08:12:18 -07:00 коммит произвёл GitHub
Родитель 42f138282f
Коммит b87b501161
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
62 изменённых файлов: 280 добавлений и 280 удалений

Просмотреть файл

@ -93,7 +93,7 @@ exports.checkForUpdate = function (updateURL, callback) {
try {
// Last line of output is the JSON details about the releases
const json = stdout.trim().split('\n').pop()
update = (ref = JSON.parse(json)) != null ? (ref1 = ref.releasesToApply) != null ? typeof ref1.pop === 'function' ? ref1.pop() : void 0 : void 0 : void 0
update = (ref = JSON.parse(json)) != null ? (ref1 = ref.releasesToApply) != null ? typeof ref1.pop === 'function' ? ref1.pop() : undefined : undefined : undefined
} catch {
// Disabled for backwards compatibility:
// eslint-disable-next-line standard/no-callback-literal

Просмотреть файл

@ -254,7 +254,7 @@ const roles = {
exports.roleList = roles
const canExecuteRole = (role) => {
if (!roles.hasOwnProperty(role)) return false
if (!Object.prototype.hasOwnProperty.call(roles, role)) return false
if (!isMac) return true
// macOS handles all roles natively except for a few
@ -262,20 +262,20 @@ const canExecuteRole = (role) => {
}
exports.getDefaultLabel = (role) => {
return roles.hasOwnProperty(role) ? roles[role].label : ''
return Object.prototype.hasOwnProperty.call(roles, role) ? roles[role].label : ''
}
exports.getDefaultAccelerator = (role) => {
if (roles.hasOwnProperty(role)) return roles[role].accelerator
if (Object.prototype.hasOwnProperty.call(roles, role)) return roles[role].accelerator
}
exports.shouldRegisterAccelerator = (role) => {
const hasRoleRegister = roles.hasOwnProperty(role) && roles[role].registerAccelerator !== undefined
const hasRoleRegister = Object.prototype.hasOwnProperty.call(roles, role) && roles[role].registerAccelerator !== undefined
return hasRoleRegister ? roles[role].registerAccelerator : true
}
exports.getDefaultSubmenu = (role) => {
if (!roles.hasOwnProperty(role)) return
if (!Object.prototype.hasOwnProperty.call(roles, role)) return
let { submenu } = roles[role]

Просмотреть файл

@ -71,7 +71,7 @@ Menu.prototype.popup = function (options = {}) {
window = wins[0]
}
if (!window) {
throw new Error(`Cannot open Menu without a TopLevelWindow present`)
throw new Error('Cannot open Menu without a TopLevelWindow present')
}
}
@ -106,7 +106,7 @@ Menu.prototype.append = function (item) {
}
Menu.prototype.insert = function (pos, item) {
if ((item ? item.constructor : void 0) !== MenuItem) {
if ((item ? item.constructor : undefined) !== MenuItem) {
throw new TypeError('Invalid item')
}
@ -194,8 +194,8 @@ function areValidTemplateItems (template) {
return template.every(item =>
item != null &&
typeof item === 'object' &&
(item.hasOwnProperty('label') ||
item.hasOwnProperty('role') ||
(Object.prototype.hasOwnProperty.call(item, 'label') ||
Object.prototype.hasOwnProperty.call(item, 'role') ||
item.type === 'separator'))
}

Просмотреть файл

@ -11,7 +11,7 @@ Object.setPrototypeOf(module.exports, new Proxy({}, {
const netLog = session.defaultSession.netLog
if (!Object.getPrototypeOf(netLog).hasOwnProperty(property)) return
if (!Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(netLog), property)) return
// check for properties on the prototype chain that aren't functions
if (typeof netLog[property] !== 'function') return netLog[property]

Просмотреть файл

@ -124,10 +124,12 @@ class SlurpStream extends Writable {
super()
this._data = Buffer.alloc(0)
}
_write (chunk, encoding, callback) {
this._data = Buffer.concat([this._data, chunk])
callback()
}
data () { return this._data }
}
@ -399,7 +401,7 @@ class ClientRequest extends Writable {
this._urlLoader.on('redirect', (event, redirectInfo, headers) => {
const { statusCode, newMethod, newUrl } = redirectInfo
if (this._redirectPolicy === 'error') {
this._die(new Error(`Attempted to redirect, but redirect policy was 'error'`))
this._die(new Error('Attempted to redirect, but redirect policy was \'error\''))
} else if (this._redirectPolicy === 'manual') {
let _followRedirect = false
this._followRedirectCb = () => { _followRedirect = true }

Просмотреть файл

@ -9,7 +9,7 @@ Object.setPrototypeOf(protocol, new Proxy({}, {
if (!app.isReady()) return
const protocol = session.defaultSession!.protocol
if (!Object.getPrototypeOf(protocol).hasOwnProperty(property)) return
if (!Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(protocol), property)) return
// Returning a native function directly would throw error.
return (...args: any[]) => (protocol[property as keyof Electron.Protocol] as Function)(...args)

Просмотреть файл

@ -103,7 +103,7 @@ class TouchBar extends EventEmitter {
const { id } = window
// Already added to window
if (this.windowListeners.hasOwnProperty(id)) return
if (Object.prototype.hasOwnProperty.call(this.windowListeners, id)) return
window._touchBar = this

Просмотреть файл

@ -263,8 +263,8 @@ WebContents.prototype.printToPDF = function (options) {
if (options.pageRanges !== undefined) {
const pageRanges = options.pageRanges
if (!pageRanges.hasOwnProperty('from') || !pageRanges.hasOwnProperty('to')) {
const error = new Error(`pageRanges must be an Object with 'from' and 'to' properties`)
if (!Object.prototype.hasOwnProperty.call(pageRanges, 'from') || !Object.prototype.hasOwnProperty.call(pageRanges, 'to')) {
const error = new Error('pageRanges must be an Object with \'from\' and \'to\' properties')
return Promise.reject(error)
}
@ -333,7 +333,7 @@ WebContents.prototype.printToPDF = function (options) {
return Promise.reject(error)
}
} else {
printSettings.mediaSize = PDFPageSizes['A4']
printSettings.mediaSize = PDFPageSizes.A4
}
// Chromium expects this in a 0-100 range number, not as float

Просмотреть файл

@ -10,12 +10,15 @@ export class MessagePortMain extends EventEmitter {
this.emit(channel, event)
}
}
start () {
return this._internalPort.start()
}
close () {
return this._internalPort.close()
}
postMessage (...args: any[]) {
if (Array.isArray(args[1])) {
args[1] = args[1].map((o: any) => o instanceof MessagePortMain ? o._internalPort : o)

Просмотреть файл

@ -196,7 +196,7 @@ const throwRPCError = function (message: string) {
const removeRemoteListenersAndLogWarning = (sender: any, callIntoRenderer: (...args: any[]) => void) => {
const location = v8Util.getHiddenValue(callIntoRenderer, 'location')
let message = `Attempting to call a function in a renderer window that has been closed or released.` +
let message = 'Attempting to call a function in a renderer window that has been closed or released.' +
`\nFunction provided here: ${location}`
if (sender instanceof EventEmitter) {
@ -281,11 +281,12 @@ const unwrapArgs = function (sender: electron.WebContents, frameId: number, cont
}
return ret
}
case 'function-with-return-value':
case 'function-with-return-value': {
const returnValue = metaToValue(meta.value)
return function () {
return returnValue
}
}
case 'function': {
// Merge contextId and meta.id, since meta.id can be the same in
// different webContents.

Просмотреть файл

@ -30,7 +30,7 @@ Object.defineProperty(electronModule, 'exports', {
get: () => require('electron')
})
Module._cache['electron'] = electronModule
Module._cache.electron = electronModule
const originalResolveFilename = Module._resolveFilename
Module._resolveFilename = function (request: string, parent: NodeModule, isMain: boolean) {

Просмотреть файл

@ -15,7 +15,7 @@ v8Util.setHiddenValue(global, 'ipc-internal', v8Util.getHiddenValue(isolatedWorl
// The process object created by webpack is not an event emitter, fix it so
// the API is more compatible with non-sandboxed renderers.
for (const prop of Object.keys(EventEmitter.prototype)) {
if (process.hasOwnProperty(prop)) {
if (Object.prototype.hasOwnProperty.call(process, prop)) {
delete process[prop]
}
}

Просмотреть файл

@ -109,7 +109,7 @@ function setObjectMembers (ref, object, metaId, members) {
if (!Array.isArray(members)) return
for (const member of members) {
if (object.hasOwnProperty(member.name)) continue
if (Object.prototype.hasOwnProperty.call(object, member.name)) continue
const descriptor = { enumerable: member.enumerable }
if (member.type === 'method') {
@ -188,7 +188,7 @@ function proxyFunctionProperties (remoteMemberFunction, metaId, name) {
return true
},
get: (target, property, receiver) => {
if (!target.hasOwnProperty(property)) loadRemoteProperties()
if (!Object.prototype.hasOwnProperty.call(target, property)) loadRemoteProperties()
const value = target[property]
if (property === 'toString' && typeof value === 'function') {
return value.bind(target)

Просмотреть файл

@ -45,7 +45,7 @@ const replacePlaceholders = (message: string, placeholders: Record<string, Place
const getMessage = (extensionId: number, messageName: string, substitutions: string[]) => {
const messages = getMessages(extensionId)
if (messages.hasOwnProperty(messageName)) {
if (Object.prototype.hasOwnProperty.call(messages, messageName)) {
const { message, placeholders } = messages[messageName]
return replacePlaceholders(message, placeholders, substitutions)
}

Просмотреть файл

@ -14,7 +14,7 @@ export const handle = function <T extends IPCHandler> (channel: string, handler:
}
export function invokeSync<T> (command: string, ...args: any[]): T {
const [ error, result ] = ipcRendererInternal.sendSync(command, ...args)
const [error, result] = ipcRendererInternal.sendSync(command, ...args)
if (error) {
throw error

Просмотреть файл

@ -222,7 +222,7 @@ const warnAboutExperimentalFeatures = function (webPreferences?: Electron.WebPre
*/
const warnAboutEnableBlinkFeatures = function (webPreferences?: Electron.WebPreferences) {
if (!webPreferences ||
!webPreferences.hasOwnProperty('enableBlinkFeatures') ||
!Object.prototype.hasOwnProperty.call(webPreferences, 'enableBlinkFeatures') ||
(webPreferences.enableBlinkFeatures && webPreferences.enableBlinkFeatures.length === 0)) {
return
}

Просмотреть файл

@ -24,10 +24,10 @@ const WEB_VIEW_EVENTS: Record<string, Array<string>> = {
'did-frame-navigate': ['url', 'httpResponseCode', 'httpStatusText', 'isMainFrame', 'frameProcessId', 'frameRoutingId'],
'did-navigate-in-page': ['url', 'isMainFrame', 'frameProcessId', 'frameRoutingId'],
'focus-change': ['focus', 'guestInstanceId'],
'close': [],
'crashed': [],
close: [],
crashed: [],
'plugin-crashed': ['name', 'version'],
'destroyed': [],
destroyed: [],
'page-title-updated': ['title', 'explicitSet'],
'page-favicon-updated': ['favicons'],
'enter-html-full-screen': [],

Просмотреть файл

@ -72,7 +72,7 @@ export class WebViewImpl {
// heard back from createGuest yet. We will not reset the flag in this case so
// that we don't end up allocating a second guest.
if (this.guestInstanceId) {
this.guestInstanceId = void 0
this.guestInstanceId = undefined
}
this.beforeFirstNavigation = true
@ -173,7 +173,7 @@ export class WebViewImpl {
}
for (const attributeName in this.attributes) {
if (this.attributes.hasOwnProperty(attributeName)) {
if (Object.prototype.hasOwnProperty.call(this.attributes, attributeName)) {
params[attributeName] = this.attributes[attributeName].getValue()
}
}

Просмотреть файл

@ -126,6 +126,7 @@ class BrowserWindowProxy {
public get location (): LocationProxy | any {
return this._location
}
public set location (url: string | any) {
url = resolveURL(url, this.location.href)
this._invokeWebContentsMethod('loadURL', url)

Просмотреть файл

@ -20,7 +20,7 @@ v8Util.setHiddenValue(global, 'ipc-internal', new EventEmitter())
// The process object created by webpack is not an event emitter, fix it so
// the API is more compatible with non-sandboxed renderers.
for (const prop of Object.keys(EventEmitter.prototype)) {
if (process.hasOwnProperty(prop)) {
if (Object.prototype.hasOwnProperty.call(process, prop)) {
delete process[prop]
}
}

Просмотреть файл

@ -38,7 +38,7 @@ async function downloadArtifact (name, buildNum, dest) {
url: circleArtifactUrl,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
Accept: 'application/json'
}
}, true).catch(err => {
if (args.verbose) {

Просмотреть файл

@ -15,7 +15,7 @@ const DEPOT_TOOLS = path.resolve(SOURCE_ROOT, '..', 'third_party', 'depot_tools'
const OUT_DIR = getOutDir({ outDir: args.outDir })
if (!OUT_DIR) {
throw new Error(`No viable out dir: one of Debug, Testing, or Release must exist.`)
throw new Error('No viable out dir: one of Debug, Testing, or Release must exist.')
}
const env = Object.assign({

Просмотреть файл

@ -57,7 +57,7 @@ function isObjCHeader (filename) {
return /\/(mac|cocoa)\//.test(filename)
}
const LINTERS = [ {
const LINTERS = [{
key: 'c++',
roots: ['shell'],
test: filename => filename.endsWith('.cc') || (filename.endsWith('.h') && !isObjCHeader(filename)),
@ -104,7 +104,7 @@ const LINTERS = [ {
test: filename => filename.endsWith('.js') || filename.endsWith('.ts'),
run: (opts, filenames) => {
const cmd = path.join(SOURCE_ROOT, 'node_modules', '.bin', 'eslint')
const args = [ '--cache', '--ext', '.js,.ts', ...filenames ]
const args = ['--cache', '--ext', '.js,.ts', ...filenames]
if (opts.fix) args.unshift('--fix')
spawnAndCheckExitCode(cmd, args, { cwd: SOURCE_ROOT })
}
@ -202,7 +202,7 @@ const LINTERS = [ {
function parseCommandLine () {
let help
const opts = minimist(process.argv.slice(2), {
boolean: [ 'c++', 'objc', 'javascript', 'python', 'gn', 'patches', 'help', 'changed', 'fix', 'verbose', 'only' ],
boolean: ['c++', 'objc', 'javascript', 'python', 'gn', 'patches', 'help', 'changed', 'fix', 'verbose', 'only'],
alias: { 'c++': ['cc', 'cpp', 'cxx'], javascript: ['js', 'es'], python: 'py', changed: 'c', help: 'h', verbose: 'v' },
unknown: arg => { help = true }
})

Просмотреть файл

@ -66,8 +66,8 @@ async function makeRequest (requestOptions, parseResponse) {
async function circleCIcall (targetBranch, job, options) {
console.log(`Triggering CircleCI to run build job: ${job} on branch: ${targetBranch} with release flag.`)
const buildRequest = {
'branch': targetBranch,
'parameters': {
branch: targetBranch,
parameters: {
'run-lint': false,
'run-build-linux': false,
'run-build-mac': false
@ -185,7 +185,7 @@ async function circleCIRequest (url, method, requestBody) {
url,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
Accept: 'application/json'
},
body: requestBody ? JSON.stringify(requestBody) : null
}, true).catch(err => {

Просмотреть файл

@ -144,8 +144,8 @@ async function getReleaseNotes (range, newVersion, explicitLinks) {
async function main () {
const opts = minimist(process.argv.slice(2), {
boolean: [ 'explicit-links', 'help' ],
string: [ 'version' ]
boolean: ['explicit-links', 'help'],
string: ['version']
})
opts.range = opts._.shift()
if (opts.help || !opts.range) {

Просмотреть файл

@ -18,7 +18,7 @@ const CHECK_INTERVAL = 5000
const CACHE_DIR = path.resolve(__dirname, '.cache')
const NO_NOTES = 'No notes'
const FOLLOW_REPOS = [ 'electron/electron', 'electron/node' ]
const FOLLOW_REPOS = ['electron/electron', 'electron/node']
const breakTypes = new Set(['breaking-change'])
const docTypes = new Set(['doc', 'docs'])
@ -222,7 +222,7 @@ const parseCommitMessage = (commitMessage, owner, repo, commit = {}) => {
// Edge case: manual backport where commit has `owner/repo#pull` notation
if (commitMessage.toLowerCase().includes('backport') &&
((match = commitMessage.match(/\b(\w+)\/(\w+)#(\d+)\b/)))) {
const [ , owner, repo, number ] = match
const [, owner, repo, number] = match
if (FOLLOW_REPOS.includes(`${owner}/${repo}`)) {
setPullRequest(commit, owner, repo, number)
}
@ -231,7 +231,7 @@ const parseCommitMessage = (commitMessage, owner, repo, commit = {}) => {
// Edge case: manual backport where commit has a link to the backport PR
if (commitMessage.includes('ackport') &&
((match = commitMessage.match(/https:\/\/github\.com\/(\w+)\/(\w+)\/pull\/(\d+)/)))) {
const [ , owner, repo, number ] = match
const [, owner, repo, number] = match
if (FOLLOW_REPOS.includes(`${owner}/${repo}`)) {
setPullRequest(commit, owner, repo, number)
}
@ -257,8 +257,8 @@ const parseCommitMessage = (commitMessage, owner, repo, commit = {}) => {
}
const getLocalCommitHashes = async (dir, ref) => {
const args = ['log', '-z', `--format=%H`, ref]
return (await runGit(dir, args)).split(`\0`).map(hash => hash.trim())
const args = ['log', '-z', '--format=%H', ref]
return (await runGit(dir, args)).split('\0').map(hash => hash.trim())
}
/*
@ -272,13 +272,13 @@ const getLocalCommitDetails = async (module, point1, point2) => {
const fieldSep = '||'
const format = ['%H', '%P', '%aE', '%B'].join(fieldSep)
const args = ['log', '-z', '--cherry-pick', '--right-only', '--first-parent', `--format=${format}`, `${point1}..${point2}`]
const commits = (await runGit(dir, args)).split(`\0`).map(field => field.trim())
const commits = (await runGit(dir, args)).split('\0').map(field => field.trim())
const details = []
for (const commit of commits) {
if (!commit) {
continue
}
const [ hash, parentHashes, email, commitMessage ] = commit.split(fieldSep, 4).map(field => field.trim())
const [hash, parentHashes, email, commitMessage] = commit.split(fieldSep, 4).map(field => field.trim())
details.push(parseCommitMessage(commitMessage, owner, repo, {
email,
hash,
@ -496,7 +496,7 @@ const getNotes = async (fromRef, toRef, newVersion) => {
if (!shouldIncludeMultibranchChanges(newVersion)) {
// load all the prDatas
await Promise.all(
pool.commits.map(commit => new Promise(async (resolve) => {
pool.commits.map(commit => (async () => {
const { pr } = commit
if (typeof pr === 'object') {
const prData = await getPullRequest(pr.number, pr.owner, pr.repo)
@ -504,8 +504,7 @@ const getNotes = async (fromRef, toRef, newVersion) => {
commit.prData = prData
}
}
resolve()
}))
})())
)
// remove items that already landed in a previous major/minor series
@ -616,22 +615,22 @@ const renderCommit = (commit, explicitLinks) => {
}
const commonVerbs = {
'Added': [ 'Add' ],
'Backported': [ 'Backport' ],
'Cleaned': [ 'Clean' ],
'Disabled': [ 'Disable' ],
'Ensured': [ 'Ensure' ],
'Exported': [ 'Export' ],
'Fixed': [ 'Fix', 'Fixes' ],
'Handled': [ 'Handle' ],
'Improved': [ 'Improve' ],
'Made': [ 'Make' ],
'Removed': [ 'Remove' ],
'Repaired': [ 'Repair' ],
'Reverted': [ 'Revert' ],
'Stopped': [ 'Stop' ],
'Updated': [ 'Update' ],
'Upgraded': [ 'Upgrade' ]
Added: ['Add'],
Backported: ['Backport'],
Cleaned: ['Clean'],
Disabled: ['Disable'],
Ensured: ['Ensure'],
Exported: ['Export'],
Fixed: ['Fix', 'Fixes'],
Handled: ['Handle'],
Improved: ['Improve'],
Made: ['Make'],
Removed: ['Remove'],
Repaired: ['Repair'],
Reverted: ['Revert'],
Stopped: ['Stop'],
Updated: ['Update'],
Upgraded: ['Upgrade']
}
for (const [key, values] of Object.entries(commonVerbs)) {
for (const value of values) {
@ -649,7 +648,7 @@ const renderCommit = (commit, explicitLinks) => {
}
const renderNotes = (notes, explicitLinks) => {
const rendered = [ `# Release Notes for ${notes.name}\n\n` ]
const rendered = [`# Release Notes for ${notes.name}\n\n`]
const renderSection = (title, commits) => {
if (commits.length === 0) {

Просмотреть файл

@ -23,8 +23,8 @@ const pass = '✓'.green
const fail = '✗'.red
if (!bumpType && !args.notesOnly) {
console.log(`Usage: prepare-release [stable | minor | beta | nightly]` +
` (--stable) (--notesOnly) (--automaticRelease) (--branch)`)
console.log('Usage: prepare-release [stable | minor | beta | nightly]' +
' (--stable) (--notesOnly) (--automaticRelease) (--branch)')
process.exit(1)
}
@ -66,7 +66,7 @@ async function createRelease (branchToTarget, isBeta) {
const releaseNotes = await getReleaseNotes(branchToTarget, newVersion)
await tagRelease(newVersion)
console.log(`Checking for existing draft release.`)
console.log('Checking for existing draft release.')
const releases = await octokit.repos.listReleases({
owner: 'electron',
repo: targetRepo
@ -87,14 +87,14 @@ async function createRelease (branchToTarget, isBeta) {
let releaseIsPrelease = false
if (isBeta) {
if (newVersion.indexOf('nightly') > 0) {
releaseBody = `Note: This is a nightly release. Please file new issues ` +
`for any bugs you find in it.\n \n This release is published to npm ` +
`under the nightly tag and can be installed via npm install electron@nightly, ` +
releaseBody = 'Note: This is a nightly release. Please file new issues ' +
'for any bugs you find in it.\n \n This release is published to npm ' +
'under the nightly tag and can be installed via npm install electron@nightly, ' +
`or npm i electron-nightly@${newVersion.substr(1)}.\n \n ${releaseNotes.text}`
} else {
releaseBody = `Note: This is a beta release. Please file new issues ` +
`for any bugs you find in it.\n \n This release is published to npm ` +
`under the beta tag and can be installed via npm install electron@beta, ` +
releaseBody = 'Note: This is a beta release. Please file new issues ' +
'for any bugs you find in it.\n \n This release is published to npm ' +
'under the beta tag and can be installed via npm install electron@beta, ' +
`or npm i electron@${newVersion.substr(1)}.\n \n ${releaseNotes.text}`
}
releaseIsPrelease = true
@ -124,7 +124,7 @@ async function pushRelease (branch) {
const pushDetails = await GitProcess.exec(['push', 'origin', `HEAD:${branch}`, '--follow-tags'], ELECTRON_DIR)
if (pushDetails.exitCode === 0) {
console.log(`${pass} Successfully pushed the release. Wait for ` +
`release builds to finish before running "npm run release".`)
'release builds to finish before running "npm run release".')
} else {
console.log(`${fail} Error pushing the release: ${pushDetails.stderr}`)
process.exit(1)
@ -140,7 +140,7 @@ async function runReleaseBuilds (branch) {
async function tagRelease (version) {
console.log(`Tagging release ${version}.`)
const checkoutDetails = await GitProcess.exec([ 'tag', '-a', '-m', version, version ], ELECTRON_DIR)
const checkoutDetails = await GitProcess.exec(['tag', '-a', '-m', version, version], ELECTRON_DIR)
if (checkoutDetails.exitCode === 0) {
console.log(`${pass} Successfully tagged ${version}.`)
} else {
@ -181,8 +181,8 @@ async function promptForVersion (version) {
// function to determine if there have been commits to master since the last release
async function changesToRelease () {
const lastCommitWasRelease = new RegExp(`^Bump v[0-9.]*(-beta[0-9.]*)?(-nightly[0-9.]*)?$`, 'g')
const lastCommit = await GitProcess.exec(['log', '-n', '1', `--pretty=format:'%s'`], ELECTRON_DIR)
const lastCommitWasRelease = new RegExp('^Bump v[0-9.]*(-beta[0-9.]*)?(-nightly[0-9.]*)?$', 'g')
const lastCommit = await GitProcess.exec(['log', '-n', '1', '--pretty=format:\'%s\''], ELECTRON_DIR)
return !lastCommitWasRelease.test(lastCommit.stdout)
}
@ -204,7 +204,7 @@ async function prepareRelease (isBeta, notesOnly) {
await pushRelease(currentBranch)
await runReleaseBuilds(currentBranch)
} else {
console.log(`There are no new changes to this branch since the last release, aborting release.`)
console.log('There are no new changes to this branch since the last release, aborting release.')
process.exit(1)
}
}

Просмотреть файл

@ -92,7 +92,7 @@ new Promise((resolve, reject) => {
request.get({
url: tsdAsset.url,
headers: {
'accept': 'application/octet-stream',
accept: 'application/octet-stream',
'user-agent': 'electron-npm-publisher'
}
}, (err, response, body) => {

Просмотреть файл

@ -9,7 +9,7 @@ const args = require('minimist')(process.argv.slice(2), {
'automaticRelease',
'verboseNugget'
],
default: { 'verboseNugget': false }
default: { verboseNugget: false }
})
const fs = require('fs')
const { execSync } = require('child_process')
@ -54,7 +54,7 @@ async function getDraftRelease (version, skipValidation) {
check(draft.prerelease, 'draft is a prerelease')
}
check(draft.body.length > 50 && !draft.body.includes('(placeholder)'), 'draft has release notes')
check((failureCount === 0), `Draft release looks good to go.`, true)
check((failureCount === 0), 'Draft release looks good to go.', true)
}
return draft
}
@ -68,7 +68,7 @@ async function validateReleaseAssets (release, validatingRelease) {
requiredAssets.forEach(asset => {
check(extantAssets.includes(asset), asset)
})
check((failureCount === 0), `All required GitHub assets exist for release`, true)
check((failureCount === 0), 'All required GitHub assets exist for release', true)
if (!validatingRelease || !release.draft) {
if (release.draft) {
@ -129,9 +129,9 @@ function assetsForVersion (version, validatingRelease) {
`electron-${version}-win32-arm64-pdb.zip`,
`electron-${version}-win32-arm64-symbols.zip`,
`electron-${version}-win32-arm64.zip`,
`electron-api.json`,
`electron.d.ts`,
`hunspell_dictionaries.zip`,
'electron-api.json',
'electron.d.ts',
'hunspell_dictionaries.zip',
`ffmpeg-${version}-darwin-x64.zip`,
`ffmpeg-${version}-linux-arm64.zip`,
`ffmpeg-${version}-linux-armv7l.zip`,
@ -161,7 +161,7 @@ function assetsForVersion (version, validatingRelease) {
}
function s3UrlsForVersion (version) {
const bucket = `https://gh-contractor-zcbenz.s3.amazonaws.com/`
const bucket = 'https://gh-contractor-zcbenz.s3.amazonaws.com/'
const patterns = [
`${bucket}atom-shell/dist/${version}/iojs-${version}-headers.tar.gz`,
`${bucket}atom-shell/dist/${version}/iojs-${version}.tar.gz`,
@ -302,7 +302,7 @@ async function makeRelease (releaseToValidate) {
await validateReleaseAssets(draftRelease)
await publishRelease(draftRelease)
console.log(`${pass} SUCCESS!!! Release has been published. Please run ` +
`"npm run publish-to-npm" to publish release to npm.`)
'"npm run publish-to-npm" to publish release to npm.')
}
}
@ -321,7 +321,7 @@ async function makeTempDir () {
async function verifyAssets (release) {
const downloadDir = await makeTempDir()
console.log(`Downloading files from GitHub to verify shasums`)
console.log('Downloading files from GitHub to verify shasums')
const shaSumFile = 'SHASUMS256.txt'
let filesToCheck = await Promise.all(release.assets.map(async asset => {

Просмотреть файл

@ -20,10 +20,10 @@ const getHeaders = (filePath, fileName) => {
const extension = fileName.split('.').pop()
const size = fs.statSync(filePath).size
const options = {
'json': 'text/json',
'zip': 'application/zip',
'txt': 'text/plain',
'ts': 'application/typescript'
json: 'text/json',
zip: 'application/zip',
txt: 'text/plain',
ts: 'application/typescript'
}
return {
@ -74,7 +74,7 @@ function uploadToGitHub () {
uploadToGitHub()
}
}).catch((getReleaseErr) => {
console.log(`Fatal: Unable to get current release assets via getRelease! Error was:`, getReleaseErr)
console.log('Fatal: Unable to get current release assets via getRelease! Error was:', getReleaseErr)
})
} else {
console.log(`Error retrying uploading ${fileName} to GitHub:`, err)

Просмотреть файл

@ -16,9 +16,9 @@ const readFile = promisify(fs.readFile)
function parseCommandLine () {
let help
const opts = minimist(process.argv.slice(2), {
string: [ 'bump', 'version' ],
boolean: [ 'dryRun', 'help' ],
alias: { 'version': ['v'] },
string: ['bump', 'version'],
boolean: ['dryRun', 'help'],
alias: { version: ['v'] },
unknown: arg => { help = true }
})
if (help || opts.help || !opts.bump) {

Просмотреть файл

@ -443,7 +443,7 @@ describe('app module', () => {
await w.loadURL('about:blank')
const promise = emittedOnce(app, 'desktop-capturer-get-sources')
w.webContents.executeJavaScript(`require('electron').desktopCapturer.getSources({ types: ['screen'] })`)
w.webContents.executeJavaScript('require(\'electron\').desktopCapturer.getSources({ types: [\'screen\'] })')
const [, webContents] = await promise
expect(webContents).to.equal(w.webContents)
@ -462,7 +462,7 @@ describe('app module', () => {
await w.loadURL('about:blank')
const promise = emittedOnce(app, 'remote-require')
w.webContents.executeJavaScript(`require('electron').remote.require('test')`)
w.webContents.executeJavaScript('require(\'electron\').remote.require(\'test\')')
const [, webContents, moduleName] = await promise
expect(webContents).to.equal(w.webContents)
@ -480,7 +480,7 @@ describe('app module', () => {
await w.loadURL('about:blank')
const promise = emittedOnce(app, 'remote-get-global')
w.webContents.executeJavaScript(`require('electron').remote.getGlobal('test')`)
w.webContents.executeJavaScript('require(\'electron\').remote.getGlobal(\'test\')')
const [, webContents, globalName] = await promise
expect(webContents).to.equal(w.webContents)
@ -498,7 +498,7 @@ describe('app module', () => {
await w.loadURL('about:blank')
const promise = emittedOnce(app, 'remote-get-builtin')
w.webContents.executeJavaScript(`require('electron').remote.app`)
w.webContents.executeJavaScript('require(\'electron\').remote.app')
const [, webContents, moduleName] = await promise
expect(webContents).to.equal(w.webContents)
@ -516,7 +516,7 @@ describe('app module', () => {
await w.loadURL('about:blank')
const promise = emittedOnce(app, 'remote-get-current-window')
w.webContents.executeJavaScript(`{ require('electron').remote.getCurrentWindow() }`)
w.webContents.executeJavaScript('{ require(\'electron\').remote.getCurrentWindow() }')
const [, webContents] = await promise
expect(webContents).to.equal(w.webContents)
@ -533,7 +533,7 @@ describe('app module', () => {
await w.loadURL('about:blank')
const promise = emittedOnce(app, 'remote-get-current-web-contents')
w.webContents.executeJavaScript(`{ require('electron').remote.getCurrentWebContents() }`)
w.webContents.executeJavaScript('{ require(\'electron\').remote.getCurrentWebContents() }')
const [, webContents] = await promise
expect(webContents).to.equal(w.webContents)
@ -596,7 +596,7 @@ describe('app module', () => {
const updateExe = path.resolve(path.dirname(process.execPath), '..', 'Update.exe')
const processStartArgs = [
'--processStart', `"${path.basename(process.execPath)}"`,
'--process-start-args', `"--hidden"`
'--process-start-args', '"--hidden"'
]
before(function () {
@ -809,7 +809,7 @@ describe('app module', () => {
const updateExe = path.resolve(path.dirname(process.execPath), '..', 'Update.exe')
const processStartArgs = [
'--processStart', `"${path.basename(process.execPath)}"`,
'--process-start-args', `"--hidden"`
'--process-start-args', '"--hidden"'
]
let Winreg: any

Просмотреть файл

@ -45,7 +45,7 @@ describe('BrowserWindow module', () => {
show: false,
// apparently void 0 had different behaviour from undefined in the
// issue that this test is supposed to catch.
webContents: void 0
webContents: void 0 // eslint-disable-line no-void
} as any)
w.destroy()
}).not.to.throw()
@ -940,9 +940,9 @@ describe('BrowserWindow module', () => {
})
})
describe(`BrowserWindow.getNormalBounds()`, () => {
describe(`Normal state`, () => {
it(`checks normal bounds after resize`, (done) => {
describe('BrowserWindow.getNormalBounds()', () => {
describe('Normal state', () => {
it('checks normal bounds after resize', (done) => {
const size = [300, 400]
w.once('resize', () => {
expectBoundsEqual(w.getNormalBounds(), w.getBounds())
@ -950,7 +950,7 @@ describe('BrowserWindow module', () => {
})
w.setSize(size[0], size[1])
})
it(`checks normal bounds after move`, (done) => {
it('checks normal bounds after move', (done) => {
const pos = [10, 10]
w.once('move', () => {
expectBoundsEqual(w.getNormalBounds(), w.getBounds())
@ -959,8 +959,8 @@ describe('BrowserWindow module', () => {
w.setPosition(pos[0], pos[1])
})
})
ifdescribe(process.platform !== 'linux')(`Maximized state`, () => {
it(`checks normal bounds when maximized`, (done) => {
ifdescribe(process.platform !== 'linux')('Maximized state', () => {
it('checks normal bounds when maximized', (done) => {
const bounds = w.getBounds()
w.once('maximize', () => {
expectBoundsEqual(w.getNormalBounds(), bounds)
@ -969,7 +969,7 @@ describe('BrowserWindow module', () => {
w.show()
w.maximize()
})
it(`checks normal bounds when unmaximized`, (done) => {
it('checks normal bounds when unmaximized', (done) => {
const bounds = w.getBounds()
w.once('maximize', () => {
w.unmaximize()
@ -982,8 +982,8 @@ describe('BrowserWindow module', () => {
w.maximize()
})
})
ifdescribe(process.platform !== 'linux')(`Minimized state`, () => {
it(`checks normal bounds when minimized`, (done) => {
ifdescribe(process.platform !== 'linux')('Minimized state', () => {
it('checks normal bounds when minimized', (done) => {
const bounds = w.getBounds()
w.once('minimize', () => {
expectBoundsEqual(w.getNormalBounds(), bounds)
@ -992,7 +992,7 @@ describe('BrowserWindow module', () => {
w.show()
w.minimize()
})
it(`checks normal bounds when restored`, (done) => {
it('checks normal bounds when restored', (done) => {
const bounds = w.getBounds()
w.once('minimize', () => {
w.restore()
@ -1005,8 +1005,8 @@ describe('BrowserWindow module', () => {
w.minimize()
})
})
ifdescribe(process.platform === 'win32')(`Fullscreen state`, () => {
it(`checks normal bounds when fullscreen'ed`, (done) => {
ifdescribe(process.platform === 'win32')('Fullscreen state', () => {
it('checks normal bounds when fullscreen\'ed', (done) => {
const bounds = w.getBounds()
w.once('enter-full-screen', () => {
expectBoundsEqual(w.getNormalBounds(), bounds)
@ -1015,7 +1015,7 @@ describe('BrowserWindow module', () => {
w.show()
w.setFullScreen(true)
})
it(`checks normal bounds when unfullscreen'ed`, (done) => {
it('checks normal bounds when unfullscreen\'ed', (done) => {
const bounds = w.getBounds()
w.once('enter-full-screen', () => {
w.setFullScreen(false)
@ -1262,7 +1262,7 @@ describe('BrowserWindow module', () => {
server = http.createServer((req, res) => {
if (req.url === '/link') {
res.setHeader('Content-type', 'text/html')
res.end(`<head><link rel="preconnect" href="//example.com" /></head><body>foo</body>`)
res.end('<head><link rel="preconnect" href="//example.com" /></head><body>foo</body>')
return
}
res.end()
@ -2092,10 +2092,10 @@ describe('BrowserWindow module', () => {
await closeWindow(popupWindow, { assertNotWindows: false })
expect(popupAccessMessage).to.be.a('string',
`child's .document is accessible from its parent window`)
'child\'s .document is accessible from its parent window')
expect(popupAccessMessage).to.match(/^Blocked a frame with origin/)
expect(openerAccessMessage).to.be.a('string',
`opener .document is accessible from a popup window`)
'opener .document is accessible from a popup window')
expect(openerAccessMessage).to.match(/^Blocked a frame with origin/)
})
@ -2178,7 +2178,7 @@ describe('BrowserWindow module', () => {
waitForEvents(w, [
'page-title-updated'
], done)
w.loadURL(`data:text/html,<script>document.title = 'changed'</script>`)
w.loadURL('data:text/html,<script>document.title = \'changed\'</script>')
})
it('works for stop events', (done) => {
@ -2187,7 +2187,7 @@ describe('BrowserWindow module', () => {
'did-fail-load',
'did-stop-loading'
], done)
w.loadURL(`data:text/html,<script>stop()</script>`)
w.loadURL('data:text/html,<script>stop()</script>')
})
it('works for web contents events', (done) => {

Просмотреть файл

@ -267,7 +267,7 @@ describe('contextBridge', () => {
contextBridge.exposeInMainWorld('example', {
1: 123,
2: 456,
'3': 789
3: 789
})
})
const result = await callWithBindings(async (root: any) => {
@ -390,7 +390,7 @@ describe('contextBridge', () => {
try {
let a: any = []
for (let i = 0; i < 999; i++) {
a = [ a ]
a = [a]
}
root.example.doThing(a)
return false
@ -403,7 +403,7 @@ describe('contextBridge', () => {
try {
let a: any = []
for (let i = 0; i < 1000; i++) {
a = [ a ]
a = [a]
}
root.example.doThing(a)
return false

Просмотреть файл

@ -277,10 +277,10 @@ ifdescribe(!process.mas && !process.env.DISABLE_CRASH_REPORTER_TESTS && process.
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } })
w.loadURL('about:blank')
await expect(
w.webContents.executeJavaScript(`require('electron').crashReporter.setUploadToServer(true)`)
w.webContents.executeJavaScript('require(\'electron\').crashReporter.setUploadToServer(true)')
).to.eventually.be.rejected()
await expect(
w.webContents.executeJavaScript(`require('electron').crashReporter.getUploadToServer()`)
w.webContents.executeJavaScript('require(\'electron\').crashReporter.getUploadToServer()')
).to.eventually.be.rejected()
})
it('sets uploadToServer false when called with false', function () {

Просмотреть файл

@ -104,7 +104,7 @@ describe('debugger module', () => {
w.webContents.loadURL('about:blank')
w.webContents.debugger.attach()
const params = { 'expression': '4+2' }
const params = { expression: '4+2' }
const res = await w.webContents.debugger.sendCommand('Runtime.evaluate', params)
expect(res.wasThrown).to.be.undefined()
@ -121,7 +121,7 @@ describe('debugger module', () => {
w.webContents.openDevTools()
await opened
const params = { 'expression': '4+2' }
const params = { expression: '4+2' }
const res = await w.webContents.debugger.sendCommand('Runtime.evaluate', params)
expect(res.wasThrown).to.be.undefined()

Просмотреть файл

@ -181,8 +181,8 @@ describe('deprecate', () => {
deprecate.fnToProperty(mod, 'newProp', '_oldGetterFn', '_oldSetterFn')
mod['oldGetterFn']()
mod['oldSetterFn']()
mod.oldGetterFn()
mod.oldSetterFn()
expect(warnings).to.have.lengthOf(2)

Просмотреть файл

@ -83,7 +83,7 @@ describe('Menu module', function () {
it('does throw exception for object without role, label, or type attribute', () => {
expect(() => {
Menu.buildFromTemplate([{ 'visible': true }])
Menu.buildFromTemplate([{ visible: true }])
}).to.throw(/Invalid template for MenuItem: must have at least one of label, role or type/)
})
it('does throw exception for undefined', () => {
@ -99,7 +99,8 @@ describe('Menu module', function () {
{
label: 'two',
id: '2',
afterGroupContaining: ['1'] },
afterGroupContaining: ['1']
},
{ type: 'separator' },
{
id: '1',
@ -132,8 +133,8 @@ describe('Menu module', function () {
})
const sep = new MenuItem({ type: 'separator' })
const items = [ secondItem, sep, firstItem ]
const expected = [ firstItem, sep, secondItem ]
const items = [secondItem, sep, firstItem]
const expected = [firstItem, sep, secondItem]
expect(sortMenuItems(items)).to.deep.equal(expected)
})

Просмотреть файл

@ -85,7 +85,7 @@ let routeFailure = false
respondNTimes.toRoutes = (routes: Record<string, http.RequestListener>, n: number) => {
return respondNTimes((request, response) => {
if (routes.hasOwnProperty(request.url || '')) {
if (Object.prototype.hasOwnProperty.call(routes, request.url || '')) {
(async () => {
await Promise.resolve(routes[request.url || ''](request, response))
})().catch((err) => {
@ -702,7 +702,7 @@ describe('net module', () => {
expect(() => {
session.defaultSession.webRequest.onBeforeRequest(
{ urls: [ '*://www.googleapis.com/', '*://blahblah.dev' ] },
{ urls: ['*://www.googleapis.com/', '*://blahblah.dev'] },
(details, callback) => { callback({ cancel: false }) }
)
}).to.throw('Invalid url pattern *://blahblah.dev: Empty path.')

Просмотреть файл

@ -116,9 +116,9 @@ ifdescribe(!skip)('Notification module (dbus)', () => {
body: 'body',
actions: [],
hints: {
'append': 'true',
append: 'true',
'desktop-entry': appName,
'urgency': 1
urgency: 1
}
})
})

Просмотреть файл

@ -128,7 +128,7 @@ describe('powerMonitor', () => {
// form and type but not its value.
const idleState = powerMonitor.getSystemIdleState(1)
expect(idleState).to.be.a('string')
const validIdleStates = [ 'active', 'idle', 'locked', 'unknown' ]
const validIdleStates = ['active', 'idle', 'locked', 'unknown']
expect(validIdleStates).to.include(idleState)
})

Просмотреть файл

@ -228,7 +228,7 @@ describe('protocol module', () => {
expect(() => callback({
path: filePath,
headers: { 'X-Great-Header': (42 as any) }
})).to.throw(Error, `Value of 'X-Great-Header' header has to be a string`)
})).to.throw(Error, 'Value of \'X-Great-Header\' header has to be a string')
done()
}).then(() => {
ajax(protocolName + '://fake-host')
@ -371,8 +371,8 @@ describe('protocol module', () => {
await registerStreamProtocol(protocolName, (request, callback) => {
callback({
headers: {
'header1': ['value1', 'value2'],
'header2': 'value3'
header1: ['value1', 'value2'],
header2: 'value3'
},
data: getStream()
})

Просмотреть файл

@ -94,7 +94,7 @@ ifdescribe(features.isRemoteModuleEnabled())('remote module', () => {
w().webContents.once('remote-get-global', (event) => {
event.preventDefault()
})
await expect(remotely(() => require('electron').remote.getGlobal('test'))).to.eventually.be.rejected(`Blocked remote.getGlobal('test')`)
await expect(remotely(() => require('electron').remote.getGlobal('test'))).to.eventually.be.rejected('Blocked remote.getGlobal(\'test\')')
})
})
@ -110,7 +110,7 @@ ifdescribe(features.isRemoteModuleEnabled())('remote module', () => {
w().webContents.once('remote-get-builtin', (event) => {
event.preventDefault()
})
await expect(remotely(() => (require('electron').remote as any).getBuiltin('test'))).to.eventually.be.rejected(`Blocked remote.getGlobal('test')`)
await expect(remotely(() => (require('electron').remote as any).getBuiltin('test'))).to.eventually.be.rejected('Blocked remote.getGlobal(\'test\')')
})
})
@ -126,7 +126,7 @@ ifdescribe(features.isRemoteModuleEnabled())('remote module', () => {
w().webContents.once('remote-require', (event) => {
event.preventDefault()
})
await expect(remotely(() => require('electron').remote.require('test'))).to.eventually.be.rejected(`Blocked remote.require('test')`)
await expect(remotely(() => require('electron').remote.require('test'))).to.eventually.be.rejected('Blocked remote.require(\'test\')')
})
})
@ -142,7 +142,7 @@ ifdescribe(features.isRemoteModuleEnabled())('remote module', () => {
w().webContents.once('remote-get-current-window', (event) => {
event.preventDefault()
})
await expect(remotely(() => require('electron').remote.getCurrentWindow())).to.eventually.be.rejected(`Blocked remote.getCurrentWindow()`)
await expect(remotely(() => require('electron').remote.getCurrentWindow())).to.eventually.be.rejected('Blocked remote.getCurrentWindow()')
})
})
@ -158,7 +158,7 @@ ifdescribe(features.isRemoteModuleEnabled())('remote module', () => {
w().webContents.once('remote-get-current-web-contents', (event) => {
event.preventDefault()
})
await expect(remotely(() => require('electron').remote.getCurrentWebContents())).to.eventually.be.rejected(`Blocked remote.getCurrentWebContents()`)
await expect(remotely(() => require('electron').remote.getCurrentWebContents())).to.eventually.be.rejected('Blocked remote.getCurrentWebContents()')
})
})
})

Просмотреть файл

@ -149,7 +149,7 @@ describe('session module', () => {
it('should overwrite previous cookies', async () => {
const { cookies } = session.defaultSession
const name = 'DidOverwrite'
for (const value of [ 'No', 'Yes' ]) {
for (const value of ['No', 'Yes']) {
await cookies.set({ url, name, value, expirationDate: (+new Date()) / 1000 + 120 })
const list = await cookies.get({ url })
@ -303,7 +303,7 @@ describe('session module', () => {
let customSession: Session
const protocol = session.defaultSession.protocol
const handler = (ignoredError: any, callback: Function) => {
callback({ data: `<script>require('electron').ipcRenderer.send('hello')</script>`, mimeType: 'text/html' })
callback({ data: '<script>require(\'electron\').ipcRenderer.send(\'hello\')</script>', mimeType: 'text/html' })
}
beforeEach(async () => {
@ -869,7 +869,7 @@ describe('session module', () => {
const w = new BrowserWindow({
show: false,
webPreferences: {
partition: `very-temp-permision-handler`,
partition: 'very-temp-permision-handler',
nodeIntegration: true
}
})

Просмотреть файл

@ -114,7 +114,7 @@ describe('renderer nodeIntegrationInSubFrames', () => {
if (config.names.length > 0) {
config.title = `with ${config.names.join(', ')} on`
} else {
config.title = `without anything special turned on`
config.title = 'without anything special turned on'
}
delete config.names

Просмотреть файл

@ -47,7 +47,7 @@ describe('systemPreferences module', () => {
1,
null,
new Date(),
{ 'one': null }
{ one: null }
]
for (const badDefault of badDefaults) {
@ -90,7 +90,7 @@ describe('systemPreferences module', () => {
['integer', 11],
['url', 'https://github.com/electron'],
['array', [1, 2, 3]],
['dictionary', { 'a': 1, 'b': 2 }]
['dictionary', { a: 1, b: 2 }]
]
it('sets values', () => {

Просмотреть файл

@ -235,7 +235,7 @@ describe('webContents module', () => {
})
it('executes after page load', (done) => {
w.webContents.executeJavaScript(`(() => "test")()`).then(result => {
w.webContents.executeJavaScript('(() => "test")()').then(result => {
expect(result).to.equal('test')
done()
})
@ -727,15 +727,15 @@ describe('webContents module', () => {
const w = new BrowserWindow({ show: false })
expect(() => {
w.webContents.startDrag({ icon: path.join(fixturesPath, 'assets', 'logo.png') } as any)
}).to.throw(`Must specify either 'file' or 'files' option`)
}).to.throw('Must specify either \'file\' or \'files\' option')
expect(() => {
w.webContents.startDrag({ file: __filename } as any)
}).to.throw(`Must specify non-empty 'icon' option`)
}).to.throw('Must specify non-empty \'icon\' option')
expect(() => {
w.webContents.startDrag({ file: __filename, icon: __filename })
}).to.throw(`Must specify non-empty 'icon' option`)
}).to.throw('Must specify non-empty \'icon\' option')
})
})
@ -1561,7 +1561,7 @@ describe('webContents module', () => {
marginsType: 'terrible',
scaleFactor: 'not-a-number',
landscape: [],
pageRanges: { 'oops': 'im-not-the-right-key' },
pageRanges: { oops: 'im-not-the-right-key' },
headerFooter: '123',
printSelectionOnly: 1,
printBackground: 2,
@ -1783,7 +1783,7 @@ describe('webContents module', () => {
cb(user, pass)
})
await w.loadURL(serverUrl)
const body = await w.webContents.executeJavaScript(`document.documentElement.textContent`)
const body = await w.webContents.executeJavaScript('document.documentElement.textContent')
expect(body).to.equal(`Basic ${Buffer.from(`${user}:${pass}`).toString('base64')}`)
expect(eventRequest.url).to.equal(serverUrl + '/')
expect(eventAuthInfo.isProxy).to.be.false()
@ -1807,7 +1807,7 @@ describe('webContents module', () => {
cb(user, pass)
})
await w.loadURL(`${serverUrl}/no-auth`)
const body = await w.webContents.executeJavaScript(`document.documentElement.textContent`)
const body = await w.webContents.executeJavaScript('document.documentElement.textContent')
expect(body).to.equal(`Basic ${Buffer.from(`${user}:${pass}`).toString('base64')}`)
expect(eventRequest.url).to.equal(`${serverUrl}/no-auth`)
expect(eventAuthInfo.isProxy).to.be.true()
@ -1824,7 +1824,7 @@ describe('webContents module', () => {
cb()
})
await w.loadURL(serverUrl)
const body = await w.webContents.executeJavaScript(`document.documentElement.textContent`)
const body = await w.webContents.executeJavaScript('document.documentElement.textContent')
expect(body).to.equal('401')
})
})

Просмотреть файл

@ -49,7 +49,7 @@ describe('WebContentsView', () => {
return arr
}
it(`doesn't crash when GCed during allocation`, (done) => {
it('doesn\'t crash when GCed during allocation', (done) => {
const web = (webContents as any).create({})
// eslint-disable-next-line no-new
new WebContentsView(web)

Просмотреть файл

@ -29,12 +29,12 @@ describe('webFrame module', () => {
}
})
})
const inputText = `spleling test you're `
const inputText = 'spleling test you\'re '
for (const keyCode of inputText) {
w.webContents.sendInputEvent({ type: 'char', keyCode })
}
const [words, callbackDefined] = await spellCheckerFeedback
expect(words.sort()).to.deep.equal(['spleling', 'test', `you're`, 'you', 're'].sort())
expect(words.sort()).to.deep.equal(['spleling', 'test', 'you\'re', 'you', 're'].sort())
expect(callbackDefined).to.be.true()
})
})

Просмотреть файл

@ -217,7 +217,7 @@ describe('webRequest module', () => {
ses.webRequest.onHeadersReceived((details, callback) => {
expect(details.statusLine).to.equal('HTTP/1.1 200 OK')
expect(details.statusCode).to.equal(200)
expect(details.responseHeaders!['Custom']).to.deep.equal(['Header'])
expect(details.responseHeaders!.Custom).to.deep.equal(['Header'])
callback({})
})
const { data } = await ajax(defaultURL)
@ -227,7 +227,7 @@ describe('webRequest module', () => {
it('can change the response header', async () => {
ses.webRequest.onHeadersReceived((details, callback) => {
const responseHeaders = details.responseHeaders!
responseHeaders['Custom'] = ['Changed'] as any
responseHeaders.Custom = ['Changed'] as any
callback({ responseHeaders: responseHeaders })
})
const { headers } = await ajax(defaultURL)
@ -247,7 +247,7 @@ describe('webRequest module', () => {
it('can change headers of CORS responses', async () => {
ses.webRequest.onHeadersReceived((details, callback) => {
const responseHeaders = details.responseHeaders!
responseHeaders['Custom'] = ['Changed'] as any
responseHeaders.Custom = ['Changed'] as any
callback({ responseHeaders: responseHeaders })
})
const { headers } = await ajax('neworigin://host')
@ -306,7 +306,7 @@ describe('webRequest module', () => {
expect(details.fromCache).to.be.a('boolean')
expect(details.statusLine).to.equal('HTTP/1.1 200 OK')
expect(details.statusCode).to.equal(200)
expect(details.responseHeaders!['Custom']).to.deep.equal(['Header'])
expect(details.responseHeaders!.Custom).to.deep.equal(['Header'])
})
const { data, headers } = await ajax(defaultURL)
expect(headers).to.match(/^custom: Header$/m)
@ -420,24 +420,24 @@ describe('webRequest module', () => {
})
ses.webRequest.onResponseStarted((details) => {
if (details.url.startsWith('ws://')) {
expect(details.responseHeaders!['Connection'][0]).be.equal('Upgrade')
expect(details.responseHeaders!.Connection[0]).be.equal('Upgrade')
} else if (details.url.startsWith('http')) {
expect(details.responseHeaders!['foo1'][0]).be.equal('bar1')
expect(details.responseHeaders!.foo1[0]).be.equal('bar1')
}
})
ses.webRequest.onSendHeaders((details) => {
if (details.url.startsWith('ws://')) {
expect(details.requestHeaders['foo']).be.equal('bar')
expect(details.requestHeaders['Upgrade']).be.equal('websocket')
expect(details.requestHeaders.foo).be.equal('bar')
expect(details.requestHeaders.Upgrade).be.equal('websocket')
} else if (details.url.startsWith('http')) {
expect(details.requestHeaders['foo']).be.equal('bar')
expect(details.requestHeaders.foo).be.equal('bar')
}
})
ses.webRequest.onCompleted((details) => {
if (details.url.startsWith('ws://')) {
expect(details['error']).be.equal('net::ERR_WS_UPGRADE')
expect(details.error).be.equal('net::ERR_WS_UPGRADE')
} else if (details.url.startsWith('http')) {
expect(details['error']).be.equal('net::OK')
expect(details.error).be.equal('net::OK')
}
})
@ -462,10 +462,10 @@ describe('webRequest module', () => {
contents.loadFile(path.join(fixturesPath, 'api', 'webrequest.html'), { query: { port } })
await emittedOnce(ipcMain, 'websocket-success')
expect(receivedHeaders['/websocket']['Upgrade'][0]).to.equal('websocket')
expect(receivedHeaders['/']['foo1'][0]).to.equal('bar1')
expect(reqHeaders['/websocket']['foo']).to.equal('bar')
expect(reqHeaders['/']['foo']).to.equal('bar')
expect(receivedHeaders['/websocket'].Upgrade[0]).to.equal('websocket')
expect(receivedHeaders['/'].foo1[0]).to.equal('bar1')
expect(reqHeaders['/websocket'].foo).to.equal('bar')
expect(reqHeaders['/'].foo).to.equal('bar')
})
})
})

Просмотреть файл

@ -49,7 +49,7 @@ describe('reporting api', () => {
res.setHeader('Report-To', JSON.stringify({
group: 'default',
max_age: 120,
endpoints: [ { url: `https://localhost:${(server.address() as any).port}/report` } ]
endpoints: [{ url: `https://localhost:${(server.address() as any).port}/report` }]
}))
res.setHeader('Content-Type', 'text/html')
// using the deprecated `webkitRequestAnimationFrame` will trigger a
@ -271,7 +271,7 @@ describe('command line switches', () => {
it('should display the discovery page', (done) => {
const electronPath = process.execPath
let output = ''
const appProcess = ChildProcess.spawn(electronPath, [`--remote-debugging-port=`])
const appProcess = ChildProcess.spawn(electronPath, ['--remote-debugging-port='])
appProcess.stderr.on('data', (data) => {
output += data
@ -318,7 +318,7 @@ describe('chromium features', () => {
const appLocale = app.getLocale()
const w = new BrowserWindow({ show: false })
await w.loadURL('about:blank')
const languages = await w.webContents.executeJavaScript(`navigator.languages`)
const languages = await w.webContents.executeJavaScript('navigator.languages')
expect(languages).to.deep.equal([appLocale])
})
})
@ -448,7 +448,7 @@ describe('chromium features', () => {
[true, false].forEach((isSandboxEnabled) =>
describe(`sandbox=${isSandboxEnabled}`, () => {
it('posts data in the same window', () => {
it('posts data in the same window', async () => {
const w = new BrowserWindow({
show: false,
webPreferences: {
@ -456,24 +456,23 @@ describe('chromium features', () => {
}
})
return new Promise(async (resolve) => {
await w.loadFile(path.join(fixturesPath, 'pages', 'form-with-data.html'))
await w.loadFile(path.join(fixturesPath, 'pages', 'form-with-data.html'))
w.webContents.once('did-finish-load', async () => {
const res = await w.webContents.executeJavaScript('document.body.innerText')
expect(res).to.equal('body:greeting=hello')
resolve()
})
const loadPromise = emittedOnce(w.webContents, 'did-finish-load')
w.webContents.executeJavaScript(`
const form = document.querySelector('form')
form.action = '${serverUrl}';
form.submit();
`)
})
w.webContents.executeJavaScript(`
const form = document.querySelector('form')
form.action = '${serverUrl}';
form.submit();
`)
await loadPromise
const res = await w.webContents.executeJavaScript('document.body.innerText')
expect(res).to.equal('body:greeting=hello')
})
it('posts data to a new window with target=_blank', () => {
it('posts data to a new window with target=_blank', async () => {
const w = new BrowserWindow({
show: false,
webPreferences: {
@ -481,22 +480,21 @@ describe('chromium features', () => {
}
})
return new Promise(async (resolve) => {
await w.loadFile(path.join(fixturesPath, 'pages', 'form-with-data.html'))
await w.loadFile(path.join(fixturesPath, 'pages', 'form-with-data.html'))
app.once('browser-window-created', async (event, newWin) => {
const res = await newWin.webContents.executeJavaScript('document.body.innerText')
expect(res).to.equal('body:greeting=hello')
resolve()
})
const windowCreatedPromise = emittedOnce(app, 'browser-window-created')
w.webContents.executeJavaScript(`
const form = document.querySelector('form')
form.action = '${serverUrl}';
form.target = '_blank';
form.submit();
`)
})
w.webContents.executeJavaScript(`
const form = document.querySelector('form')
form.action = '${serverUrl}';
form.target = '_blank';
form.submit();
`)
const [, newWin] = await windowCreatedPromise
const res = await newWin.webContents.executeJavaScript('document.body.innerText')
expect(res).to.equal('body:greeting=hello')
})
})
)
@ -598,13 +596,13 @@ describe('chromium features', () => {
w.webContents.executeJavaScript(`{ b = window.open(${JSON.stringify(targetURL)}); null }`)
const [, window] = await emittedOnce(app, 'browser-window-created')
await emittedOnce(window.webContents, 'did-finish-load')
expect(await w.webContents.executeJavaScript(`b.location.href`)).to.equal(targetURL)
expect(await w.webContents.executeJavaScript('b.location.href')).to.equal(targetURL)
})
it('defines a window.location setter', async () => {
const w = new BrowserWindow({ show: false })
w.loadURL('about:blank')
w.webContents.executeJavaScript(`{ b = window.open("about:blank"); null }`)
w.webContents.executeJavaScript('{ b = window.open("about:blank"); null }')
const [, { webContents }] = await emittedOnce(app, 'browser-window-created')
await emittedOnce(webContents, 'did-finish-load')
// When it loads, redirect
@ -615,7 +613,7 @@ describe('chromium features', () => {
it('defines a window.location.href setter', async () => {
const w = new BrowserWindow({ show: false })
w.loadURL('about:blank')
w.webContents.executeJavaScript(`{ b = window.open("about:blank"); null }`)
w.webContents.executeJavaScript('{ b = window.open("about:blank"); null }')
const [, { webContents }] = await emittedOnce(app, 'browser-window-created')
await emittedOnce(webContents, 'did-finish-load')
// When it loads, redirect
@ -626,25 +624,25 @@ describe('chromium features', () => {
it('open a blank page when no URL is specified', async () => {
const w = new BrowserWindow({ show: false })
w.loadURL('about:blank')
w.webContents.executeJavaScript(`{ b = window.open(); null }`)
w.webContents.executeJavaScript('{ b = window.open(); null }')
const [, { webContents }] = await emittedOnce(app, 'browser-window-created')
await emittedOnce(webContents, 'did-finish-load')
expect(await w.webContents.executeJavaScript(`b.location.href`)).to.equal('about:blank')
expect(await w.webContents.executeJavaScript('b.location.href')).to.equal('about:blank')
})
it('open a blank page when an empty URL is specified', async () => {
const w = new BrowserWindow({ show: false })
w.loadURL('about:blank')
w.webContents.executeJavaScript(`{ b = window.open(''); null }`)
w.webContents.executeJavaScript('{ b = window.open(\'\'); null }')
const [, { webContents }] = await emittedOnce(app, 'browser-window-created')
await emittedOnce(webContents, 'did-finish-load')
expect(await w.webContents.executeJavaScript(`b.location.href`)).to.equal('about:blank')
expect(await w.webContents.executeJavaScript('b.location.href')).to.equal('about:blank')
})
it('sets the window title to the specified frameName', async () => {
const w = new BrowserWindow({ show: false })
w.loadURL('about:blank')
w.webContents.executeJavaScript(`{ b = window.open('', 'hello'); null }`)
w.webContents.executeJavaScript('{ b = window.open(\'\', \'hello\'); null }')
const [, window] = await emittedOnce(app, 'browser-window-created')
expect(window.getTitle()).to.equal('hello')
})
@ -652,7 +650,7 @@ describe('chromium features', () => {
it('does not throw an exception when the frameName is a built-in object property', async () => {
const w = new BrowserWindow({ show: false })
w.loadURL('about:blank')
w.webContents.executeJavaScript(`{ b = window.open('', '__proto__'); null }`)
w.webContents.executeJavaScript('{ b = window.open(\'\', \'__proto__\'); null }')
const [, window] = await emittedOnce(app, 'browser-window-created')
expect(window.getTitle()).to.equal('__proto__')
})
@ -682,7 +680,7 @@ describe('chromium features', () => {
it('can return labels of enumerated devices', async () => {
const w = new BrowserWindow({ show: false })
w.loadFile(path.join(fixturesPath, 'pages', 'blank.html'))
const labels = await w.webContents.executeJavaScript(`navigator.mediaDevices.enumerateDevices().then(ds => ds.map(d => d.label))`)
const labels = await w.webContents.executeJavaScript('navigator.mediaDevices.enumerateDevices().then(ds => ds.map(d => d.label))')
expect(labels.some((l: any) => l)).to.be.true()
})
@ -690,7 +688,7 @@ describe('chromium features', () => {
session.defaultSession.setPermissionCheckHandler(() => false)
const w = new BrowserWindow({ show: false })
w.loadFile(path.join(fixturesPath, 'pages', 'blank.html'))
const labels = await w.webContents.executeJavaScript(`navigator.mediaDevices.enumerateDevices().then(ds => ds.map(d => d.label))`)
const labels = await w.webContents.executeJavaScript('navigator.mediaDevices.enumerateDevices().then(ds => ds.map(d => d.label))')
expect(labels.some((l: any) => l)).to.be.false()
})
@ -886,7 +884,7 @@ describe('chromium features', () => {
it('cannot access localStorage', (done) => {
ipcMain.once('local-storage-response', (event, error) => {
expect(error).to.equal(`Failed to read the 'localStorage' property from 'Window': Access is denied for this document.`)
expect(error).to.equal('Failed to read the \'localStorage\' property from \'Window\': Access is denied for this document.')
done()
})
contents.loadURL(protocolName + '://host/localStorage')
@ -894,7 +892,7 @@ describe('chromium features', () => {
it('cannot access sessionStorage', (done) => {
ipcMain.once('session-storage-response', (event, error) => {
expect(error).to.equal(`Failed to read the 'sessionStorage' property from 'Window': Access is denied for this document.`)
expect(error).to.equal('Failed to read the \'sessionStorage\' property from \'Window\': Access is denied for this document.')
done()
})
contents.loadURL(`${protocolName}://host/sessionStorage`)
@ -902,7 +900,7 @@ describe('chromium features', () => {
it('cannot access WebSQL database', (done) => {
ipcMain.once('web-sql-response', (event, error) => {
expect(error).to.equal(`Failed to execute 'openDatabase' on 'Window': Access to the WebDatabase API is denied in this context.`)
expect(error).to.equal('Failed to execute \'openDatabase\' on \'Window\': Access to the WebDatabase API is denied in this context.')
done()
})
contents.loadURL(`${protocolName}://host/WebSQL`)
@ -910,7 +908,7 @@ describe('chromium features', () => {
it('cannot access indexedDB', (done) => {
ipcMain.once('indexed-db-response', (event, error) => {
expect(error).to.equal(`Failed to execute 'open' on 'IDBFactory': access to the Indexed Database API is denied in this context.`)
expect(error).to.equal('Failed to execute \'open\' on \'IDBFactory\': access to the Indexed Database API is denied in this context.')
done()
})
contents.loadURL(`${protocolName}://host/indexedDB`)
@ -918,7 +916,7 @@ describe('chromium features', () => {
it('cannot access cookie', (done) => {
ipcMain.once('cookie-response', (event, error) => {
expect(error).to.equal(`Failed to set the 'cookie' property on 'Document': Access is denied for this document.`)
expect(error).to.equal('Failed to set the \'cookie\' property on \'Document\': Access is denied for this document.')
done()
})
contents.loadURL(`${protocolName}://host/cookie`)
@ -1044,7 +1042,7 @@ describe('font fallback', () => {
}
it('should use Helvetica for sans-serif on Mac, and Arial on Windows and Linux', async () => {
const html = `<body style="font-family: sans-serif">test</body>`
const html = '<body style="font-family: sans-serif">test</body>'
const fonts = await getRenderedFonts(html)
expect(fonts).to.be.an('array')
expect(fonts).to.have.length(1)

Просмотреть файл

@ -241,7 +241,7 @@ ifdescribe(process.electronBinding('features').isExtensionsEnabled())('chrome ex
const { id } = await customSession.loadExtension(path.join(fixtures, 'extensions', 'lazy-background-page'))
const w = new BrowserWindow({ show: false, webPreferences: { session: customSession } })
await w.loadURL(`chrome-extension://${id}/page-get-background.html`)
const receivedMessage = await w.webContents.executeJavaScript(`window.completionPromise`)
const receivedMessage = await w.webContents.executeJavaScript('window.completionPromise')
expect(receivedMessage).to.deep.equal({ some: 'message' })
})
@ -250,7 +250,7 @@ ifdescribe(process.electronBinding('features').isExtensionsEnabled())('chrome ex
const { id } = await customSession.loadExtension(path.join(fixtures, 'extensions', 'lazy-background-page'))
const w = new BrowserWindow({ show: false, webPreferences: { session: customSession } })
await w.loadURL(`chrome-extension://${id}/page-get-background.html`)
const receivedMessage = await w.webContents.executeJavaScript(`window.completionPromise`)
const receivedMessage = await w.webContents.executeJavaScript('window.completionPromise')
expect(receivedMessage).to.deep.equal({ some: 'message' })
})
@ -259,7 +259,7 @@ ifdescribe(process.electronBinding('features').isExtensionsEnabled())('chrome ex
const { id } = await customSession.loadExtension(path.join(fixtures, 'extensions', 'lazy-background-page'))
const w = new BrowserWindow({ show: false, webPreferences: { session: customSession } })
await w.loadURL(`chrome-extension://${id}/page-runtime-get-background.html`)
const receivedMessage = await w.webContents.executeJavaScript(`window.completionPromise`)
const receivedMessage = await w.webContents.executeJavaScript('window.completionPromise')
expect(receivedMessage).to.deep.equal({ some: 'message' })
})
})
@ -407,9 +407,9 @@ ifdescribe(process.electronBinding('features').isExtensionsEnabled())('chrome ex
const contentScript = path.resolve(fixtures, 'extensions/content-script')
// Computed style values
const COLOR_RED = `rgb(255, 0, 0)`
const COLOR_BLUE = `rgb(0, 0, 255)`
const COLOR_TRANSPARENT = `rgba(0, 0, 0, 0)`
const COLOR_RED = 'rgb(255, 0, 0)'
const COLOR_BLUE = 'rgb(0, 0, 255)'
const COLOR_TRANSPARENT = 'rgba(0, 0, 0, 0)'
before(() => {
BrowserWindow.addExtension(contentScript)
@ -485,7 +485,7 @@ ifdescribe(process.electronBinding('features').isExtensionsEnabled())('chrome ex
const { id } = await session.defaultSession.loadExtension(path.join(fixtures, 'extensions', 'ui-page'))
const w = new BrowserWindow({ show: false })
await w.loadURL(`chrome-extension://${id}/bare-page.html`)
const textContent = await w.webContents.executeJavaScript(`document.body.textContent`)
const textContent = await w.webContents.executeJavaScript('document.body.textContent')
expect(textContent).to.equal('ui page loaded ok\n')
})
@ -493,7 +493,7 @@ ifdescribe(process.electronBinding('features').isExtensionsEnabled())('chrome ex
const { id } = await session.defaultSession.loadExtension(path.join(fixtures, 'extensions', 'ui-page'))
const w = new BrowserWindow({ show: false })
await w.loadURL(`chrome-extension://${id}/page-script-load.html`)
const textContent = await w.webContents.executeJavaScript(`document.body.textContent`)
const textContent = await w.webContents.executeJavaScript('document.body.textContent')
expect(textContent).to.equal('script loaded ok\n')
})
})

Просмотреть файл

@ -20,7 +20,7 @@ describe('modules support', () => {
it('can be required in renderer', async () => {
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } })
w.loadURL('about:blank')
await expect(w.webContents.executeJavaScript(`{ require('echo'); null }`)).to.be.fulfilled()
await expect(w.webContents.executeJavaScript('{ require(\'echo\'); null }')).to.be.fulfilled()
})
ifit(features.isRunAsNodeEnabled())('can be required in node binary', function (done) {

Просмотреть файл

@ -48,7 +48,7 @@ describe('security warnings', () => {
return
}
const cspHeaders = { 'Content-Security-Policy': `script-src 'self' 'unsafe-inline'` }
const cspHeaders = { 'Content-Security-Policy': 'script-src \'self\' \'unsafe-inline\'' }
response.writeHead(200, useCsp ? cspHeaders : undefined)
response.write(file, 'binary')
response.end()

Просмотреть файл

@ -21,7 +21,7 @@ describe('version-bumper', () => {
major: 2,
minor: 0,
patch: 0,
pre: [ 'nightly', 12345678 ]
pre: ['nightly', 12345678]
}
const version = utils.makeVersion(components, '.', utils.preType.PARTIAL)
@ -33,7 +33,7 @@ describe('version-bumper', () => {
major: 2,
minor: 0,
patch: 0,
pre: [ 'nightly', 12345678 ]
pre: ['nightly', 12345678]
}
const version = utils.makeVersion(components, '.', utils.preType.FULL)

Просмотреть файл

@ -538,7 +538,7 @@ describe('<webview> tag', function () {
it('emits when accessing external protocol', async () => {
loadWebView(w.webContents, {
src: `magnet:test`,
src: 'magnet:test',
partition
})
const [, webViewContents] = await emittedOnce(app, 'web-contents-created')

Просмотреть файл

@ -454,7 +454,7 @@ describe('chromium feature', () => {
setImmediate(() => {
let called = false
Promise.resolve().then(() => {
done(called ? void 0 : new Error('wrong sequence'))
done(called ? undefined : new Error('wrong sequence'))
})
document.createElement('x-element')
called = true
@ -467,7 +467,7 @@ describe('chromium feature', () => {
ipcRenderer.invoke('ping').then(() => {
let called = false
Promise.resolve().then(() => {
done(called ? void 0 : new Error('wrong sequence'))
done(called ? undefined : new Error('wrong sequence'))
})
document.createElement('y-element')
called = true

13
spec/fixtures/api/cookie-app/main.js поставляемый
Просмотреть файл

@ -17,16 +17,11 @@ app.whenReady().then(async function () {
url
})
const maybeRemove = async (pred) => new Promise(async (resolve, reject) => {
try {
if (pred()) {
await persistentSession.cookies.remove(url, name)
}
resolve()
} catch (error) {
reject(error)
const maybeRemove = async (pred) => {
if (pred()) {
await persistentSession.cookies.remove(url, name)
}
})
}
try {
await maybeRemove(() => process.env.PHASE === 'one')

36
spec/fixtures/module/inspector-binding.js поставляемый
Просмотреть файл

@ -16,17 +16,17 @@ let scopeCallback = null
function checkScope (session, scopeId) {
session.post('Runtime.getProperties', {
'objectId': scopeId,
'ownProperties': false,
'accessorPropertiesOnly': false,
'generatePreview': true
objectId: scopeId,
ownProperties: false,
accessorPropertiesOnly: false,
generatePreview: true
}, scopeCallback)
}
function debuggerPausedCallback (session, notification) {
const params = notification['params']
const callFrame = params['callFrames'][0]
const scopeId = callFrame['scopeChain'][0]['object']['objectId']
const params = notification.params
const callFrame = params.callFrames[0]
const scopeId = callFrame.scopeChain[0].object.objectId
checkScope(session, scopeId)
}
@ -41,11 +41,11 @@ function testSampleDebugSession () {
if (error) failures.push(error)
const i = cur++
let v, actual, expected
for (v of result['result']) {
actual = v['value']['value']
expected = expects[v['name']][i]
for (v of result.result) {
actual = v.value.value
expected = expects[v.name][i]
if (actual !== expected) {
failures.push(`Iteration ${i} variable: ${v['name']} ` +
failures.push(`Iteration ${i} variable: ${v.name} ` +
`expected: ${expected} actual: ${actual}`)
}
}
@ -57,19 +57,19 @@ function testSampleDebugSession () {
let cbAsSecondArgCalled = false
session.post('Debugger.enable', () => { cbAsSecondArgCalled = true })
session.post('Debugger.setBreakpointByUrl', {
'lineNumber': 9,
'url': pathToFileURL(path.resolve(__dirname, __filename)).toString(),
'columnNumber': 0,
'condition': ''
lineNumber: 9,
url: pathToFileURL(path.resolve(__dirname, __filename)).toString(),
columnNumber: 0,
condition: ''
})
debuggedFunction()
scopeCallback = null
session.disconnect()
process.send({
'cmd': 'assert',
'debuggerEnabled': cbAsSecondArgCalled,
'success': (cur === 5) && (failures.length === 0)
cmd: 'assert',
debuggerEnabled: cbAsSecondArgCalled,
success: (cur === 5) && (failures.length === 0)
})
}

Просмотреть файл

@ -50,7 +50,7 @@ describe('node feature', () => {
it('works in forked process when options.env is specifed', (done) => {
const child = ChildProcess.fork(path.join(fixtures, 'module', 'fork_ping.js'), [], {
path: process.env['PATH']
path: process.env.PATH
})
child.on('message', (msg) => {
expect(msg).to.equal('message')

Просмотреть файл

@ -7,7 +7,7 @@ const { app, BrowserWindow, crashReporter, dialog, ipcMain, protocol, webContent
try {
require('fs').rmdirSync(app.getPath('userData'), { recursive: true })
} catch (e) {
console.warn(`Warning: couldn't clear user data directory:`, e)
console.warn('Warning: couldn\'t clear user data directory:', e)
}
const fs = require('fs')

Просмотреть файл

@ -1021,7 +1021,7 @@ describe('<webview> tag', function () {
marginsType: 'terrible',
scaleFactor: 'not-a-number',
landscape: [],
pageRanges: { 'oops': 'im-not-the-right-key' },
pageRanges: { oops: 'im-not-the-right-key' },
headerFooter: '123',
printSelectionOnly: 1,
printBackground: 2,