*/
function bound(var_args)
{
- return func.apply(thisObject, concat(args, slice(arguments)));
+ return InjectedScriptHost.callFunction(func, thisObject, concat(args, slice(arguments)));
}
bound.toString = function()
{
return false;
if (typeof obj.splice === "function")
return isFinite(obj.length);
- var str = Object.prototype.toString.call(obj);
- if (str === "[object Array]" ||
- str === "[object Arguments]" ||
- str === "[object HTMLCollection]" ||
- str === "[object NodeList]" ||
- str === "[object DOMTokenList]")
+ var str = InjectedScriptHost.callFunction(Object.prototype.toString, obj);
+ if (str === "[object Arguments]")
return isFinite(obj.length);
} catch (e) {
}
*/
_parseObjectId: function(objectId)
{
- return nullifyObjectProto(InjectedScriptHost.evaluate("(" + objectId + ")"));
+ return nullifyObjectProto(InjectedScriptHost.eval("(" + objectId + ")"));
},
/**
*/
releaseObjectGroup: function(objectGroupName)
{
+ if (objectGroupName === "console")
+ delete this._lastResult;
var group = this._objectGroups[objectGroupName];
if (!group)
return;
*/
dispatch: function(methodName, args)
{
- var argsArray = InjectedScriptHost.evaluate("(" + args + ")");
- var result = this[methodName].apply(this, argsArray);
+ var argsArray = InjectedScriptHost.eval("(" + args + ")");
+ var result = InjectedScriptHost.callFunction(this[methodName], this, argsArray);
if (typeof result === "undefined") {
inspectedWindow.console.error("Web Inspector error: InjectedScript.%s returns undefined", methodName);
result = null;
try {
propertyProcessed[property] = true;
- var descriptor = nullifyObjectProto(InjectedScriptHost.suppressWarningsAndCall(Object, Object.getOwnPropertyDescriptor, o, property));
+ var descriptor = nullifyObjectProto(InjectedScriptHost.suppressWarningsAndCallFunction(Object.getOwnPropertyDescriptor, Object, [o, property]));
if (descriptor) {
if (accessorPropertiesOnly && !("get" in descriptor || "set" in descriptor))
continue;
*/
evaluate: function(expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview)
{
- return this._evaluateAndWrap(InjectedScriptHost.evaluate, InjectedScriptHost, expression, objectGroup, false, injectCommandLineAPI, returnByValue, generatePreview);
+ return this._evaluateAndWrap(null, null, expression, objectGroup, false, injectCommandLineAPI, returnByValue, generatePreview);
},
/**
if (args) {
var resolvedArgs = [];
- args = InjectedScriptHost.evaluate(args);
+ args = InjectedScriptHost.eval(args);
for (var i = 0; i < args.length; ++i) {
try {
resolvedArgs[i] = this._resolveCallArgument(args[i]);
try {
var objectGroup = this._idToObjectGroupName[parsedObjectId.id];
- var func = InjectedScriptHost.evaluate("(" + expression + ")");
+ var func = InjectedScriptHost.eval("(" + expression + ")");
if (typeof func !== "function")
return "Given expression does not evaluate to a function";
return { wasThrown: false,
- result: this._wrapObject(func.apply(object, resolvedArgs), objectGroup, returnByValue),
+ result: this._wrapObject(InjectedScriptHost.callFunction(func, object, resolvedArgs), objectGroup, returnByValue),
__proto__: null };
} catch (e) {
- return this._createThrownValue(e, objectGroup);
+ return this._createThrownValue(e, objectGroup, false);
}
},
},
/**
- * @param {!Function} evalFunction
- * @param {!Object} object
+ * @param {?function(string):*} evalFunction
+ * @param {?Object} object
* @param {string} expression
* @param {string} objectGroup
* @param {boolean} isEvalOnCallFrame
*/
_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.exceptionDetails) {
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);
}
+ return this._createThrownValue(wrappedResult.result, objectGroup, generatePreview, wrappedResult.exceptionDetails);
},
/**
* @param {*} value
* @param {string} objectGroup
+ * @param {boolean} generatePreview
+ * @param {!DebuggerAgent.ExceptionDetails=} exceptionDetails
* @return {!Object}
*/
- _createThrownValue: function(value, objectGroup)
+ _createThrownValue: function(value, objectGroup, generatePreview, exceptionDetails)
{
- var remoteObject = this._wrapObject(value, objectGroup);
- try {
- remoteObject.description = toStringDescription(value);
- } catch (e) {}
- return { wasThrown: true, result: remoteObject, __proto__: null };
+ var remoteObject = this._wrapObject(value, objectGroup, false, generatePreview && !(value instanceof Error));
+ if (!remoteObject.description){
+ try {
+ remoteObject.description = toStringDescription(value);
+ } catch (e) {}
+ }
+ return { wasThrown: true, result: remoteObject, exceptionDetails: exceptionDetails, __proto__: null };
},
/**
- * @param {!Function} evalFunction
- * @param {!Object} object
+ * @param {?function(string):*} evalFunction
+ * @param {?Object} object
* @param {string} objectGroup
* @param {string} expression
* @param {boolean} isEvalOnCallFrame
if (prefix)
expression = prefix + "\n" + expression + "\n" + suffix;
- var result = evalFunction.call(object, expression);
- if (objectGroup === "console")
- this._lastResult = result;
- return result;
+ var wrappedResult = evalFunction ? InjectedScriptHost.callFunction(evalFunction, object, [expression]) : InjectedScriptHost.evaluateWithExceptionDetails(expression);
+ if (objectGroup === "console" && !wrappedResult.exceptionDetails)
+ this._lastResult = wrappedResult.result;
+ return wrappedResult;
} finally {
if (injectCommandLineAPI)
delete inspectedWindow.__commandLineAPI;
*/
evaluateOnCallFrame: function(topCallFrame, asyncCallStacks, callFrameId, expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview)
{
- var parsedCallFrameId = nullifyObjectProto(InjectedScriptHost.evaluate("(" + callFrameId + ")"));
+ var parsedCallFrameId = nullifyObjectProto(InjectedScriptHost.eval("(" + callFrameId + ")"));
var callFrame = this._callFrameForParsedId(topCallFrame, parsedCallFrameId, asyncCallStacks);
if (!callFrame)
return "Could not find call frame with given id";
if (parsedCallFrameId["asyncOrdinal"])
- return this._evaluateAndWrap(InjectedScriptHost.evaluate, InjectedScriptHost, expression, objectGroup, false, injectCommandLineAPI, returnByValue, generatePreview, callFrame.scopeChain);
- return this._evaluateAndWrap(callFrame.evaluate, callFrame, expression, objectGroup, true, injectCommandLineAPI, returnByValue, generatePreview);
+ return this._evaluateAndWrap(null, null, expression, objectGroup, false, injectCommandLineAPI, returnByValue, generatePreview, callFrame.scopeChain);
+ return this._evaluateAndWrap(callFrame.evaluateWithExceptionDetails, callFrame, expression, objectGroup, true, injectCommandLineAPI, returnByValue, generatePreview);
},
/**
}
var newValueJson;
try {
- newValueJson = InjectedScriptHost.evaluate("(" + newValueJsonString + ")");
+ newValueJson = InjectedScriptHost.eval("(" + newValueJsonString + ")");
} catch (e) {
return "Failed to parse new value JSON " + newValueJsonString + " : " + e;
}
*/
_callFrameForId: function(topCallFrame, callFrameId)
{
- var parsedCallFrameId = nullifyObjectProto(InjectedScriptHost.evaluate("(" + callFrameId + ")"));
+ var parsedCallFrameId = nullifyObjectProto(InjectedScriptHost.eval("(" + callFrameId + ")"));
return this._callFrameForParsedId(topCallFrame, parsedCallFrameId, []);
},
injectModule: function(name, source)
{
delete this._modules[name];
- var moduleFunction = InjectedScriptHost.evaluate("(" + source + ")");
+ var moduleFunction = InjectedScriptHost.eval("(" + source + ")");
if (typeof moduleFunction !== "function") {
inspectedWindow.console.error("Web Inspector error: A function was expected for module %s evaluation", name);
return null;
}
- var module = moduleFunction.call(inspectedWindow, InjectedScriptHost, inspectedWindow, injectedScriptId, this);
+ var module = InjectedScriptHost.callFunction(moduleFunction, inspectedWindow, [InjectedScriptHost, inspectedWindow, injectedScriptId, this]);
this._modules[name] = module;
return module;
},
if (this.isPrimitiveValue(obj))
return null;
- if (this._isHTMLAllCollection(obj))
- return "array";
-
var preciseType = InjectedScriptHost.type(obj);
if (preciseType)
return preciseType;
if (isSymbol(obj)) {
try {
- return Symbol.prototype.toString.call(obj) || "Symbol";
+ return InjectedScriptHost.callFunction(Symbol.prototype.toString, obj) || "Symbol";
} catch (e) {
return "Symbol";
}
}
- if (className === "Object") {
- // In Chromium DOM wrapper prototypes will have Object as their constructor name,
- // get the real DOM wrapper name from the constructor property.
- var constructorName = obj.constructor && obj.constructor.name;
- if (constructorName)
- return constructorName;
- }
+ if (obj instanceof Error && !!obj.message)
+ return className + ": " + obj.message;
+
return className;
}
}
/**
* @param {!RuntimeAgent.ObjectPreview} preview
- * @param {!Array.<Object>} descriptors
+ * @param {!Array.<!Object>} descriptors
* @param {!Object} propertiesThreshold
* @param {?Array.<string>=} secondLevelKeys
* @param {boolean=} isTable
*/
dir: function(var_args)
{
- return inspectedWindow.console.dir.apply(inspectedWindow.console, arguments)
+ return InjectedScriptHost.callFunction(inspectedWindow.console.dir, inspectedWindow.console, slice(arguments));
},
/**
*/
dirxml: function(var_args)
{
- return inspectedWindow.console.dirxml.apply(inspectedWindow.console, arguments)
+ return InjectedScriptHost.callFunction(inspectedWindow.console.dirxml, inspectedWindow.console, slice(arguments));
},
/**
*/
profile: function(opt_title)
{
- return inspectedWindow.console.profile.apply(inspectedWindow.console, arguments)
+ return InjectedScriptHost.callFunction(inspectedWindow.console.profile, inspectedWindow.console, slice(arguments));
},
/**
*/
profileEnd: function(opt_title)
{
- return inspectedWindow.console.profileEnd.apply(inspectedWindow.console, arguments)
+ return InjectedScriptHost.callFunction(inspectedWindow.console.profileEnd, inspectedWindow.console, slice(arguments));
},
/**
table: function(data, opt_columns)
{
- inspectedWindow.console.table.apply(inspectedWindow.console, arguments);
+ InjectedScriptHost.callFunction(inspectedWindow.console.table, inspectedWindow.console, slice(arguments));
},
/**