Skip to content
Permalink
Browse files
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
  • Loading branch information
xeenon committed Aug 19, 2008
1 parent 098734d commit 5722bb0cc7625e0c0c08fb6f45770d2462c5c1cc
Showing 2 changed files with 22 additions and 0 deletions.
@@ -1,3 +1,18 @@
2008-08-19 Timothy Hatcher <timothy@apple.com>

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.

2008-08-19 Kevin McCullough <kmccullough@apple.com>

Reviewed by Geoff.
@@ -329,6 +329,10 @@ WebInspector.Console.prototype = {

_evalInInspectedWindow: function(expression)
{
// Surround the expression in parenthesis so the result of the eval is the result
// of the whole expression not the last potential sub-expression.
expression = "(" + expression + ")";

if (WebInspector.panels.scripts.paused)
return WebInspector.panels.scripts.evaluateInSelectedCallFrame(expression);

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

// Surround the expression in with statemnets to inject our command line API so that
// the window object properties still take more precedent than our API functions.
expression = "with (window._inspectorCommandLineAPI) { with (window) { " + expression + " } }";

return inspectedWindow.eval(expression);
},

0 comments on commit 5722bb0

Please sign in to comment.