tiptoeing along, keeping the suite passing

This commit is contained in:
Zeke Sikelianos 2016-03-25 12:41:24 -07:00 committed by Kevin Sawicki
parent ee181294b3
commit ca7b492b97
3 changed files with 90 additions and 85 deletions

View file

@ -1,62 +1,62 @@
'use strict'; 'use strict'
const v8Util = process.atomBinding('v8_util'); const v8Util = process.atomBinding('v8_util')
class CallbacksRegistry { class CallbacksRegistry {
constructor() { constructor () {
this.nextId = 0; this.nextId = 0
this.callbacks = {}; this.callbacks = {}
} }
add(callback) { add (callback) {
// The callback is already added. // The callback is already added.
var filenameAndLine, id, location, match, ref, regexp, stackString; var filenameAndLine, id, location, match, ref, regexp, stackString
id = v8Util.getHiddenValue(callback, 'callbackId'); id = v8Util.getHiddenValue(callback, 'callbackId')
if (id != null) { if (id != null) {
return id; return id
} }
id = ++this.nextId; id = ++this.nextId
// Capture the location of the function and put it in the ID string, // Capture the location of the function and put it in the ID string,
// so that release errors can be tracked down easily. // so that release errors can be tracked down easily.
regexp = /at (.*)/gi; regexp = /at (.*)/gi
stackString = (new Error).stack; stackString = (new Error).stack
while ((match = regexp.exec(stackString)) !== null) { while ((match = regexp.exec(stackString)) !== null) {
location = match[1]; location = match[1]
if (location.indexOf('(native)') !== -1) { if (location.indexOf('(native)') !== -1) {
continue; continue
} }
if (location.indexOf('atom.asar') !== -1) { if (location.indexOf('atom.asar') !== -1) {
continue; continue
} }
ref = /([^\/^\)]*)\)?$/gi.exec(location); ref = /([^\/^\)]*)\)?$/gi.exec(location)
filenameAndLine = ref[1]; filenameAndLine = ref[1]
break; break
} }
this.callbacks[id] = callback; this.callbacks[id] = callback
v8Util.setHiddenValue(callback, 'callbackId', id); v8Util.setHiddenValue(callback, 'callbackId', id)
v8Util.setHiddenValue(callback, 'location', filenameAndLine); v8Util.setHiddenValue(callback, 'location', filenameAndLine)
return id; return id
} }
get(id) { get (id) {
var ref; var ref
return (ref = this.callbacks[id]) != null ? ref : function() {}; return (ref = this.callbacks[id]) != null ? ref : function () {}
} }
call(id, ...args) { call (id, ...args) {
var ref; var ref
return (ref = this.get(id)).call.apply(ref, [global].concat(args)); return (ref = this.get(id)).call.apply(ref, [global].concat(args))
} }
apply(id, ...args) { apply (id, ...args) {
var ref; var ref
return (ref = this.get(id)).apply.apply(ref, [global].concat(args)); return (ref = this.get(id)).apply.apply(ref, [global].concat(args))
} }
remove(id) { remove (id) {
return delete this.callbacks[id]; return delete this.callbacks[id]
} }
} }
module.exports = CallbacksRegistry; module.exports = CallbacksRegistry

View file

@ -1,6 +1,6 @@
if (process.platform === 'linux' && process.type === 'renderer') { if (process.platform === 'linux' && process.type === 'renderer') {
// On Linux we could not access clipboard in renderer process. // On Linux we could not access clipboard in renderer process.
module.exports = require('electron').remote.clipboard; module.exports = require('electron').remote.clipboard
} else { } else {
module.exports = process.atomBinding('clipboard'); module.exports = process.atomBinding('clipboard')
} }

View file

@ -1,94 +1,99 @@
'use strict'; 'use strict'
const os = require('os'); const os = require('os')
const path = require('path'); const path = require('path')
const spawn = require('child_process').spawn; const spawn = require('child_process').spawn
const electron = require('electron'); const electron = require('electron')
const binding = process.atomBinding('crash_reporter'); const binding = process.atomBinding('crash_reporter')
var CrashReporter = (function() { var CrashReporter = (function () {
function CrashReporter() {} function CrashReporter () {}
CrashReporter.prototype.start = function(options) { CrashReporter.prototype.start = function (options) {
var app, args, autoSubmit, companyName, deprecate, env, extra, ignoreSystemCrashHandler, start, submitURL; var app, args, autoSubmit, companyName, deprecate, env, extra, ignoreSystemCrashHandler, start, submitURL
if (options == null) { if (options == null) {
options = {}; options = {}
} }
this.productName = options.productName, companyName = options.companyName, submitURL = options.submitURL, autoSubmit = options.autoSubmit, ignoreSystemCrashHandler = options.ignoreSystemCrashHandler, extra = options.extra; this.productName = options.productName
companyName = options.companyName
submitURL = options.submitURL
autoSubmit = options.autoSubmit
ignoreSystemCrashHandler = options.ignoreSystemCrashHandler
extra = options.extra
// Deprecated. // Deprecated.
deprecate = electron.deprecate; deprecate = electron.deprecate
if (options.submitUrl) { if (options.submitUrl) {
if (submitURL == null) { if (submitURL == null) {
submitURL = options.submitUrl; submitURL = options.submitUrl
} }
deprecate.warn('submitUrl', 'submitURL'); deprecate.warn('submitUrl', 'submitURL')
} }
app = (process.type === 'browser' ? electron : electron.remote).app; app = (process.type === 'browser' ? electron : electron.remote).app
if (this.productName == null) { if (this.productName == null) {
this.productName = app.getName(); this.productName = app.getName()
} }
if (autoSubmit == null) { if (autoSubmit == null) {
autoSubmit = true; autoSubmit = true
} }
if (ignoreSystemCrashHandler == null) { if (ignoreSystemCrashHandler == null) {
ignoreSystemCrashHandler = false; ignoreSystemCrashHandler = false
} }
if (extra == null) { if (extra == null) {
extra = {}; extra = {}
} }
if (extra._productName == null) { if (extra._productName == null) {
extra._productName = this.productName; extra._productName = this.productName
} }
if (extra._companyName == null) { if (extra._companyName == null) {
extra._companyName = companyName; extra._companyName = companyName
} }
if (extra._version == null) { if (extra._version == null) {
extra._version = app.getVersion(); extra._version = app.getVersion()
} }
if (companyName == null) { if (companyName == null) {
deprecate.log('companyName is now a required option to crashReporter.start'); deprecate.log('companyName is now a required option to crashReporter.start')
return; return
} }
if (submitURL == null) { if (submitURL == null) {
deprecate.log('submitURL is now a required option to crashReporter.start'); deprecate.log('submitURL is now a required option to crashReporter.start')
return; return
} }
start = () => { start = () => {
binding.start(this.productName, companyName, submitURL, autoSubmit, ignoreSystemCrashHandler, extra); binding.start(this.productName, companyName, submitURL, autoSubmit, ignoreSystemCrashHandler, extra)
}; }
if (process.platform === 'win32') { if (process.platform === 'win32') {
args = ["--reporter-url=" + submitURL, "--application-name=" + this.productName, "--v=1"]; args = ["--reporter-url=" + submitURL, "--application-name=" + this.productName, "--v=1"]
env = { env = {
ATOM_SHELL_INTERNAL_CRASH_SERVICE: 1 ATOM_SHELL_INTERNAL_CRASH_SERVICE: 1
}; }
spawn(process.execPath, args, { spawn(process.execPath, args, {
env: env, env: env,
detached: true detached: true
}); })
} }
return start(); return start()
}; }
CrashReporter.prototype.getLastCrashReport = function() { CrashReporter.prototype.getLastCrashReport = function () {
var reports; var reports
reports = this.getUploadedReports(); reports = this.getUploadedReports()
if (reports.length > 0) { if (reports.length > 0) {
return reports[0]; return reports[0]
} else { } else {
return null; return null
} }
}; }
CrashReporter.prototype.getUploadedReports = function() { CrashReporter.prototype.getUploadedReports = function () {
var log, tmpdir; var log, tmpdir
tmpdir = process.platform === 'win32' ? os.tmpdir() : '/tmp'; tmpdir = process.platform === 'win32' ? os.tmpdir() : '/tmp'
log = process.platform === 'darwin' ? path.join(tmpdir, this.productName + " Crashes") : path.join(tmpdir, this.productName + " Crashes", 'uploads.log'); log = process.platform === 'darwin' ? path.join(tmpdir, this.productName + " Crashes") : path.join(tmpdir, this.productName + " Crashes", 'uploads.log')
return binding._getUploadedReports(log); return binding._getUploadedReports(log)
}; }
return CrashReporter; return CrashReporter
})(); })()
module.exports = new CrashReporter; module.exports = new CrashReporter