Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(769)

Unified Diff: third_party/WebKit/Source/devtools/front_end/console_model/ConsoleModel.js

Issue 2800573002: DevTools: editing property values should wrap object literals similar to console (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/console_model/ConsoleModel.js
diff --git a/third_party/WebKit/Source/devtools/front_end/console_model/ConsoleModel.js b/third_party/WebKit/Source/devtools/front_end/console_model/ConsoleModel.js
index 4e64cf59f0557a40edef90c5f443b39baa76e4af..3d31a8eb44f39b86171cc143b7c34692b546339f 100644
--- a/third_party/WebKit/Source/devtools/front_end/console_model/ConsoleModel.js
+++ b/third_party/WebKit/Source/devtools/front_end/console_model/ConsoleModel.js
@@ -148,32 +148,7 @@ ConsoleModel.ConsoleModel = class extends Common.Object {
});
}
- /**
- * @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 + ')';
-
+ text = SDK.RuntimeModel.wrapObjectLiteralExpressionIfNeeded(text);
executionContext.evaluate(text, 'console', useCommandLineAPI, false, false, true, true, printResult.bind(this));
Host.userMetrics.actionTaken(Host.UserMetrics.Action.ConsoleEvaluated);
}

Powered by Google App Engine
This is Rietveld 408576698