avoiding crashes

This commit is contained in:
sebv
2014-04-05 00:53:07 +08:00
parent eaf442675e
commit ac69aa6da8

View File

@@ -97,7 +97,7 @@ RemoteDebugger.prototype.disconnect = function () {
};
RemoteDebugger.prototype.setConnectionKey = function (cb) {
assert.ok(this.connId);
try { assert.ok(this.connId); } catch (err) { return cb(err); }
var setConnKey = messages.setConnectionKey(this.connId);
this.logger.info("Sending connection key");
this.send(setConnKey, function (simNameKey, simBuildKey) {
@@ -113,7 +113,7 @@ RemoteDebugger.prototype.setConnectionKey = function (cb) {
};
RemoteDebugger.prototype.selectApp = function (appIdKey, cb) {
assert.ok(this.connId);
try { assert.ok(this.connId); } catch (err) { return cb(err); }
this.appIdKey = appIdKey;
var connectToApp = messages.connectToApp(this.connId, this.appIdKey);
this.logger.info("Selecting app");
@@ -140,9 +140,12 @@ RemoteDebugger.prototype.selectPage = function (pageIdKey, cb, skipReadyCheck) {
if (typeof skipReadyCheck === "undefined") {
skipReadyCheck = false;
}
assert.ok(this.connId);
assert.ok(this.appIdKey);
assert.ok(this.senderId);
try {
assert.ok(this.connId);
assert.ok(this.appIdKey);
assert.ok(this.senderId);
} catch (err) { return cb(err); }
this.pageIdKey = pageIdKey;
var setSenderKey = messages.setSenderKey(this.connId, this.appIdKey,
this.senderId, this.pageIdKey);
@@ -269,10 +272,12 @@ RemoteDebugger.prototype.execute = function (command, cb, override) {
}.bind(this));
} else {
if (this.debuggerType === this.debuggerTypeEnum.webinspector) {
assert.ok(this.connId);
assert.ok(this.appIdKey);
assert.ok(this.senderId);
assert.ok(this.pageIdKey);
try {
assert.ok(this.connId);
assert.ok(this.appIdKey);
assert.ok(this.senderId);
assert.ok(this.pageIdKey);
} catch (err) { return cb(err); }
}
this.logger.info("Sending javascript command");
var sendJSCommand = messages.sendJSCommand(command, this.appIdKey,
@@ -282,10 +287,13 @@ RemoteDebugger.prototype.execute = function (command, cb, override) {
};
RemoteDebugger.prototype.callFunction = function (objId, fn, args, cb) {
assert.ok(this.connId);
assert.ok(this.appIdKey);
assert.ok(this.senderId);
assert.ok(this.pageIdKey);
try {
assert.ok(this.connId);
assert.ok(this.appIdKey);
assert.ok(this.senderId);
assert.ok(this.pageIdKey);
} catch (err) { return cb(err); }
this.logger.info("Calling javascript function");
var callJSFunction = messages.callJSfunction(objId, fn, args, this.appIdKey,
this.connId, this.senderId, this.pageIdKey, this.debuggerType);
@@ -294,10 +302,12 @@ RemoteDebugger.prototype.callFunction = function (objId, fn, args, cb) {
RemoteDebugger.prototype.navToUrl = function (url, cb) {
if (this.debuggerType === this.debuggerTypeEnum.webinspector) {
assert.ok(this.connId);
assert.ok(this.appIdKey);
assert.ok(this.senderId);
assert.ok(this.pageIdKey);
try {
assert.ok(this.connId);
assert.ok(this.appIdKey);
assert.ok(this.senderId);
assert.ok(this.pageIdKey);
} catch (err) { return cb(err); }
}
this.logger.info("Navigating to new URL: " + url);
var navToUrl = messages.setUrl(url, this.appIdKey, this.connId,