Index: Source/core/inspector/InjectedScriptSource.js |
diff --git a/Source/core/inspector/InjectedScriptSource.js b/Source/core/inspector/InjectedScriptSource.js |
index 3cabdc116cb13ebc3333229b66f9ec8ae4151367..707b74c7dd0b4d607387b78b87047f1d74d3067e 100644 |
--- a/Source/core/inspector/InjectedScriptSource.js |
+++ b/Source/core/inspector/InjectedScriptSource.js |
@@ -351,7 +351,7 @@ InjectedScript.prototype = { |
*/ |
_parseObjectId: function(objectId) |
{ |
- return nullifyObjectProto(InjectedScriptHost.evaluate("(" + objectId + ")")); |
+ return nullifyObjectProto(this._evaluateOrThrow("(" + objectId + ")")); |
}, |
/** |
@@ -374,7 +374,7 @@ InjectedScript.prototype = { |
*/ |
dispatch: function(methodName, args) |
{ |
- var argsArray = InjectedScriptHost.evaluate("(" + args + ")"); |
+ var argsArray = this._evaluateOrThrow("(" + args + ")"); |
var result = this[methodName].apply(this, argsArray); |
if (typeof result === "undefined") { |
inspectedWindow.console.error("Web Inspector error: InjectedScript.%s returns undefined", methodName); |
@@ -597,7 +597,7 @@ InjectedScript.prototype = { |
if (args) { |
var resolvedArgs = []; |
- args = InjectedScriptHost.evaluate(args); |
+ args = this._evaluateOrThrow(args); |
for (var i = 0; i < args.length; ++i) { |
try { |
resolvedArgs[i] = this._resolveCallArgument(args[i]); |
@@ -609,7 +609,7 @@ InjectedScript.prototype = { |
try { |
var objectGroup = this._idToObjectGroupName[parsedObjectId.id]; |
- var func = InjectedScriptHost.evaluate("(" + expression + ")"); |
+ var func = this._evaluateOrThrow("(" + expression + ")"); |
if (typeof func !== "function") |
return "Given expression does not evaluate to a function"; |
@@ -664,27 +664,40 @@ InjectedScript.prototype = { |
*/ |
_evaluateAndWrap: function(evalFunction, object, expression, objectGroup, isEvalOnCallFrame, injectCommandLineAPI, returnByValue, generatePreview, scopeChain) |
{ |
- try { |
+ var wrappedResult = this._evaluateOn(evalFunction, object, objectGroup, expression, isEvalOnCallFrame, injectCommandLineAPI, scopeChain); |
+ if (!wrappedResult || !wrappedResult.exceptionDetails) { |
aandrey
2014/07/04 19:01:22
wrong condition. you should not throw iff wrappedR
kozyatinskiy1
2014/07/05 10:52:46
Done.
|
return { wasThrown: false, |
- result: this._wrapObject(this._evaluateOn(evalFunction, object, objectGroup, expression, isEvalOnCallFrame, injectCommandLineAPI, scopeChain), objectGroup, returnByValue, generatePreview), |
+ result: this._wrapObject(wrappedResult.result, objectGroup, returnByValue, generatePreview), |
__proto__: null }; |
- } catch (e) { |
- return this._createThrownValue(e, objectGroup); |
- } |
+ } else |
aandrey
2014/07/04 19:01:22
we also use brackets for one-liner else- block, if
kozyatinskiy1
2014/07/05 10:52:46
Done.
|
+ return this._createThrownValue(wrappedResult.result, objectGroup, wrappedResult.exceptionDetails); |
+ }, |
+ |
+ /** |
+ * @param {string} expression |
+ * @return {?} |
+ */ |
+ _evaluateOrThrow: function(expression) |
+ { |
+ var wrappedResult = InjectedScriptHost.evaluate(expression); |
+ if (wrappedResult.exceptionDetails) |
+ throw wrappedResult.result; |
+ return wrappedResult.result; |
}, |
/** |
* @param {*} value |
* @param {string} objectGroup |
+ * @param {!DebuggerAgent.ExceptionDetails=} exceptionDetails |
* @return {!Object} |
*/ |
- _createThrownValue: function(value, objectGroup) |
+ _createThrownValue: function(value, objectGroup, exceptionDetails) |
{ |
var remoteObject = this._wrapObject(value, objectGroup); |
try { |
remoteObject.description = toStringDescription(value); |
} catch (e) {} |
- return { wasThrown: true, result: remoteObject, __proto__: null }; |
+ return { wasThrown: true, result: remoteObject, exceptionDetails: exceptionDetails, __proto__: null }; |
}, |
/** |
@@ -772,7 +785,7 @@ InjectedScript.prototype = { |
*/ |
evaluateOnCallFrame: function(topCallFrame, asyncCallStacks, callFrameId, expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview) |
{ |
- var parsedCallFrameId = nullifyObjectProto(InjectedScriptHost.evaluate("(" + callFrameId + ")")); |
+ var parsedCallFrameId = nullifyObjectProto(this._evaluateOrThrow("(" + callFrameId + ")")); |
var callFrame = this._callFrameForParsedId(topCallFrame, parsedCallFrameId, asyncCallStacks); |
if (!callFrame) |
return "Could not find call frame with given id"; |
@@ -840,7 +853,7 @@ InjectedScript.prototype = { |
} |
var newValueJson; |
try { |
- newValueJson = InjectedScriptHost.evaluate("(" + newValueJsonString + ")"); |
+ newValueJson = this._evaluateOrThrow("(" + newValueJsonString + ")"); |
} catch (e) { |
return "Failed to parse new value JSON " + newValueJsonString + " : " + e; |
} |
@@ -865,7 +878,7 @@ InjectedScript.prototype = { |
*/ |
_callFrameForId: function(topCallFrame, callFrameId) |
{ |
- var parsedCallFrameId = nullifyObjectProto(InjectedScriptHost.evaluate("(" + callFrameId + ")")); |
+ var parsedCallFrameId = nullifyObjectProto(this._evaluateOrThrow("(" + callFrameId + ")")); |
return this._callFrameForParsedId(topCallFrame, parsedCallFrameId, []); |
}, |
@@ -935,7 +948,7 @@ InjectedScript.prototype = { |
injectModule: function(name, source) |
{ |
delete this._modules[name]; |
- var moduleFunction = InjectedScriptHost.evaluate("(" + source + ")"); |
+ var moduleFunction = this._evaluateOrThrow("(" + source + ")"); |
if (typeof moduleFunction !== "function") { |
inspectedWindow.console.error("Web Inspector error: A function was expected for module %s evaluation", name); |
return null; |