Title: [125033] trunk
Revision
125033
Author
pfeld...@chromium.org
Date
2012-08-08 06:21:41 -0700 (Wed, 08 Aug 2012)

Log Message

Web Inspector: store last evaluation result in $_
https://bugs.webkit.org/show_bug.cgi?id=93377

Reviewed by Vsevolod Vlasov.

Source/WebCore:

All "console" evaluations end up in that variable on command line API.

Test: inspector/console/console-last-result.html

* inspector/InjectedScriptSource.js:
(.):

LayoutTests:

* inspector/console/console-last-result-expected.txt: Added.
* inspector/console/console-last-result.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (125032 => 125033)


--- trunk/LayoutTests/ChangeLog	2012-08-08 13:19:22 UTC (rev 125032)
+++ trunk/LayoutTests/ChangeLog	2012-08-08 13:21:41 UTC (rev 125033)
@@ -1,3 +1,13 @@
+2012-08-08  Pavel Feldman  <pfeld...@chromium.org>
+
+        Web Inspector: store last evaluation result in $_
+        https://bugs.webkit.org/show_bug.cgi?id=93377
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/console/console-last-result-expected.txt: Added.
+        * inspector/console/console-last-result.html: Added.
+
 2012-08-08  KwangYong Choi  <ky0.c...@samsung.com>
 
         [EFL] Support DataList for <input type="range">

Added: trunk/LayoutTests/inspector/console/console-last-result-expected.txt (0 => 125033)


--- trunk/LayoutTests/inspector/console/console-last-result-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/console/console-last-result-expected.txt	2012-08-08 13:21:41 UTC (rev 125033)
@@ -0,0 +1,7 @@
+Tests that console exposes last evaluation result as $_.
+
+1+1
+2
+$_
+2
+

Added: trunk/LayoutTests/inspector/console/console-last-result.html (0 => 125033)


--- trunk/LayoutTests/inspector/console/console-last-result.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/console/console-last-result.html	2012-08-08 13:21:41 UTC (rev 125033)
@@ -0,0 +1,32 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function test()
+{
+    InspectorTest.evaluateInConsole("1+1", step1);
+
+    function step1()
+    {
+        InspectorTest.evaluateInConsole("$_", callback);
+    }
+
+    function callback()
+    {
+        InspectorTest.dumpConsoleMessages();
+        InspectorTest.completeTest();
+    }
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+    Tests that console exposes last evaluation result as $_.
+</p>
+
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (125032 => 125033)


--- trunk/Source/WebCore/ChangeLog	2012-08-08 13:19:22 UTC (rev 125032)
+++ trunk/Source/WebCore/ChangeLog	2012-08-08 13:21:41 UTC (rev 125033)
@@ -1,3 +1,17 @@
+2012-08-08  Pavel Feldman  <pfeld...@chromium.org>
+
+        Web Inspector: store last evaluation result in $_
+        https://bugs.webkit.org/show_bug.cgi?id=93377
+
+        Reviewed by Vsevolod Vlasov.
+
+        All "console" evaluations end up in that variable on command line API.
+
+        Test: inspector/console/console-last-result.html
+
+        * inspector/InjectedScriptSource.js:
+        (.):
+
 2012-08-08  Simon Hausmann  <simon.hausm...@nokia.com>
 
         [Qt] Port internal findMethodIndex method matcher to use JSC C API

Modified: trunk/Source/WebCore/inspector/InjectedScriptSource.js (125032 => 125033)


--- trunk/Source/WebCore/inspector/InjectedScriptSource.js	2012-08-08 13:19:22 UTC (rev 125032)
+++ trunk/Source/WebCore/inspector/InjectedScriptSource.js	2012-08-08 13:21:41 UTC (rev 125033)
@@ -404,7 +404,7 @@
     {
         try {
             return { wasThrown: false,
-                     result: this._wrapObject(this._evaluateOn(evalFunction, object, _expression_, isEvalOnCallFrame, injectCommandLineAPI), objectGroup, returnByValue) };
+                     result: this._wrapObject(this._evaluateOn(evalFunction, object, objectGroup, _expression_, isEvalOnCallFrame, injectCommandLineAPI), objectGroup, returnByValue) };
         } catch (e) {
             return this._createThrownValue(e, objectGroup);
         }
@@ -428,12 +428,13 @@
     /**
      * @param {Function} evalFunction
      * @param {Object} object
+     * @param {string} objectGroup
      * @param {string} _expression_
      * @param {boolean} isEvalOnCallFrame
      * @param {boolean} injectCommandLineAPI
      * @return {*}
      */
-    _evaluateOn: function(evalFunction, object, _expression_, isEvalOnCallFrame, injectCommandLineAPI)
+    _evaluateOn: function(evalFunction, object, objectGroup, _expression_, isEvalOnCallFrame, injectCommandLineAPI)
     {
         // Only install command line api object for the time of evaluation.
         // Surround the _expression_ in with statements to inject our command line API so that
@@ -444,7 +445,10 @@
                 inspectedWindow.console._commandLineAPI = new CommandLineAPI(this._commandLineAPIImpl, isEvalOnCallFrame ? object : null);
                 _expression_ = "with ((window && window.console && window.console._commandLineAPI) || {}) {\n" + _expression_ + "\n}";
             }
-            return evalFunction.call(object, _expression_);
+            var result = evalFunction.call(object, _expression_);
+            if (objectGroup === "console")
+                this._lastResult = result;
+            return result;
         } finally {
             if (injectCommandLineAPI && inspectedWindow.console)
                 delete inspectedWindow.console._commandLineAPI;
@@ -797,6 +801,8 @@
 
         this.__defineGetter__("$" + i, commandLineAPIImpl._inspectedObject.bind(commandLineAPIImpl, i));
     }
+
+    this.$_ = injectedScript._lastResult;
 }
 
 /**
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to