Commit b5319893 authored by aandrey@chromium.org's avatar aandrey@chromium.org

DevTools: Remove console last result $_ on console clear.

BUG=398336
R=loislo, yurys

Review URL: https://codereview.chromium.org/430503002

git-svn-id: svn://svn.chromium.org/blink/trunk@179179 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 3a497e63
Tests that evaluating an expression with a syntax error in the console won't crash the browser. Bug 61194. Tests that evaluating an expression with a syntax error in the console won't crash the browser. Bug 61194.
foo(). foo().
Uncaught SyntaxError: Unexpected token } VM:734 Uncaught SyntaxError: Unexpected token } VM:736
Tests that console exposes last evaluation result as $_. Tests that console exposes last evaluation result as $_.
Running: testLastResult
1+1 1+1
2 2
$_ $_
2 2
Running: testLastResultAfterConsoleClear
$_
undefined
...@@ -6,17 +6,44 @@ ...@@ -6,17 +6,44 @@
function test() function test()
{ {
InspectorTest.evaluateInConsole("1+1", step1); InspectorTest.runTestSuite([
function testLastResult(next)
{
InspectorTest.evaluateInConsole("1+1", step1);
function step1() function step1()
{ {
InspectorTest.evaluateInConsole("$_", callback); evaluateLastResultAndDump(next);
} }
},
function testLastResultAfterConsoleClear(next)
{
InspectorTest.evaluateInConsole("1+1", step1);
function callback() function step1()
{
WebInspector.consoleModel.requestClearMessages();
InspectorTest.runAfterPendingDispatches(step2);
}
function step2()
{
evaluateLastResultAndDump(next);
}
}
]);
function evaluateLastResultAndDump(callback)
{ {
InspectorTest.dumpConsoleMessages(); InspectorTest.evaluateInConsole("$_", didEvaluate);
InspectorTest.completeTest();
function didEvaluate()
{
InspectorTest.dumpConsoleMessages();
if (callback)
callback();
}
} }
} }
......
...@@ -359,6 +359,8 @@ InjectedScript.prototype = { ...@@ -359,6 +359,8 @@ InjectedScript.prototype = {
*/ */
releaseObjectGroup: function(objectGroupName) releaseObjectGroup: function(objectGroupName)
{ {
if (objectGroupName === "console")
delete this._lastResult;
var group = this._objectGroups[objectGroupName]; var group = this._objectGroups[objectGroupName];
if (!group) if (!group)
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment