| Index: third_party/WebKit/Source/devtools/front_end/sdk/ConsoleModel.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/ConsoleModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/ConsoleModel.js
|
| index aff5da307645c6f3864ce0b9e8603c14857f9d7e..703d3fa2c1fbe8ccee405ce0a4a274720fc51ffc 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/sdk/ConsoleModel.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/sdk/ConsoleModel.js
|
| @@ -212,8 +212,34 @@ WebInspector.ConsoleModel.evaluateCommandInConsole = function(executionContext,
|
| target.consoleModel.dispatchEventToListeners(WebInspector.ConsoleModel.Events.CommandEvaluated, {result: result, wasThrown: wasThrown, text: text, commandMessage: commandMessage, exceptionDetails: exceptionDetails});
|
| }
|
| }
|
| - if (/^\s*\{/.test(text) && /\}\s*$/.test(text))
|
| - text = '(' + text + ')';
|
| +
|
| + /**
|
| + * @param {string} code
|
| + * @suppress {uselessCode}
|
| + * @return {boolean}
|
| + */
|
| + function looksLikeAnObjectLiteral(code)
|
| + {
|
| + // Only parenthesize what appears to be an object literal.
|
| + if (!(/^\s*\{/.test(code) && /\}\s*$/.test(code)))
|
| + return false;
|
| +
|
| + try {
|
| + // Check if the code can be interpreted as an expression.
|
| + Function("return " + code + ";");
|
| +
|
| + // No syntax error! Does it work parenthesized?
|
| + Function("(" + code + ")");
|
| +
|
| + return true;
|
| + } catch (e) {
|
| + return false;
|
| + }
|
| + }
|
| +
|
| + if (looksLikeAnObjectLiteral(text))
|
| + text = "(" + text + ")";
|
| +
|
| executionContext.evaluate(text, "console", !!useCommandLineAPI, false, false, true, printResult);
|
|
|
| WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.ConsoleEvaluated);
|
|
|