Skip to content

Commit 5722bb0

Browse files
committed
Surround the expression to be evaluated in parenthesis so the
result of the eval is the result of the whole expression not the last potential sub-expression. So evaluating {x: 123} will show the Object not 123. https://bugs.webkit.org/show_bug.cgi?id=20428 Reviewed by Kevin McCullough. * page/inspector/Console.js: (Console.prototype._evalInInspectedWindow): Add parenthesis around the expression. And add couple comments. Canonical link: https://commits.webkit.org/28240@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@35834 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 098734d commit 5722bb0

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

WebCore/ChangeLog

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
2008-08-19 Timothy Hatcher <timothy@apple.com>
2+
3+
Surround the expression to be evaluated in parenthesis so the
4+
result of the eval is the result of the whole expression not
5+
the last potential sub-expression. So evaluating {x: 123}
6+
will show the Object not 123.
7+
8+
https://bugs.webkit.org/show_bug.cgi?id=20428
9+
10+
Reviewed by Kevin McCullough.
11+
12+
* page/inspector/Console.js:
13+
(Console.prototype._evalInInspectedWindow): Add parenthesis
14+
around the expression. And add couple comments.
15+
116
2008-08-19 Kevin McCullough <kmccullough@apple.com>
217

318
Reviewed by Geoff.

WebCore/page/inspector/Console.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,10 @@ WebInspector.Console.prototype = {
329329

330330
_evalInInspectedWindow: function(expression)
331331
{
332+
// Surround the expression in parenthesis so the result of the eval is the result
333+
// of the whole expression not the last potential sub-expression.
334+
expression = "(" + expression + ")";
335+
332336
if (WebInspector.panels.scripts.paused)
333337
return WebInspector.panels.scripts.evaluateInSelectedCallFrame(expression);
334338

@@ -357,7 +361,10 @@ WebInspector.Console.prototype = {
357361
inspectedWindow._inspectorCommandLineAPI.clear = InspectorController.wrapCallback(this.clearMessages.bind(this));
358362
}
359363

364+
// Surround the expression in with statemnets to inject our command line API so that
365+
// the window object properties still take more precedent than our API functions.
360366
expression = "with (window._inspectorCommandLineAPI) { with (window) { " + expression + " } }";
367+
361368
return inspectedWindow.eval(expression);
362369
},
363370

0 commit comments

Comments
 (0)