Diff
Modified: trunk/LayoutTests/ChangeLog (148494 => 148495)
--- trunk/LayoutTests/ChangeLog 2013-04-16 05:56:18 UTC (rev 148494)
+++ trunk/LayoutTests/ChangeLog 2013-04-16 06:12:22 UTC (rev 148495)
@@ -1,3 +1,18 @@
+2013-04-15 Timothy Hatcher <[email protected]>
+
+ Web Inspector: Make var and function declarations work again in the Console.
+
+ https://webkit.org/b/114534
+ rdar://problem/13614477
+
+ Reviewed by Oliver Hunt.
+
+ * inspector/console/command-line-api-expected.txt:
+ * inspector/console/console-eval-syntax-error-expected.txt:
+ * inspector/extensions/extensions-eval-expected.txt:
+ * platform/mac/http/tests/inspector/console-resource-errors-expected.txt:
+ Updated test results.
+
2013-04-15 James Craig <[email protected]>
WebKit should not expose AXSubrole:AXDescriptionList on Mountain Lion as it causes a regression in VoiceOver behavior
Modified: trunk/LayoutTests/inspector/console/command-line-api-expected.txt (148494 => 148495)
--- trunk/LayoutTests/inspector/console/command-line-api-expected.txt 2013-04-16 05:56:18 UTC (rev 148494)
+++ trunk/LayoutTests/inspector/console/command-line-api-expected.txt 2013-04-16 06:12:22 UTC (rev 148495)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 1200: The console function $() has changed from $=getElementById(id) to $=querySelector(selector). You might try $("#%s")
+CONSOLE MESSAGE: line 1223: The console function $() has changed from $=getElementById(id) to $=querySelector(selector). You might try $("#%s")
Tests that command line api works.
Modified: trunk/LayoutTests/inspector/console/console-eval-syntax-error-expected.txt (148494 => 148495)
--- trunk/LayoutTests/inspector/console/console-eval-syntax-error-expected.txt 2013-04-16 05:56:18 UTC (rev 148494)
+++ trunk/LayoutTests/inspector/console/console-eval-syntax-error-expected.txt 2013-04-16 06:12:22 UTC (rev 148495)
@@ -1,5 +1,5 @@
Tests that evaluating an _expression_ with a syntax error in the console won't crash the browser. Bug 61194.
foo().
-SyntaxError: Unexpected EOF
+SyntaxError: Expected an identifier but found '}' instead
Modified: trunk/LayoutTests/inspector/extensions/extensions-eval-expected.txt (148494 => 148495)
--- trunk/LayoutTests/inspector/extensions/extensions-eval-expected.txt 2013-04-16 05:56:18 UTC (rev 148494)
+++ trunk/LayoutTests/inspector/extensions/extensions-eval-expected.txt 2013-04-16 06:12:22 UTC (rev 148495)
@@ -5,7 +5,7 @@
RUNNING TEST: extension_testEvalConsoleAPI
Evaluate: "function" (exception: undefined)
RUNNING TEST: extension_testEvalDefinesGlobalSymbols
-Evaluate: {"func":"undefined","variable":42} (exception: undefined)
+Evaluate: {"func":"function","variable":42} (exception: undefined)
RUNNING TEST: extension_testEvalOk
Evaluate: {"str":"foo","num":42} (exception: undefined)
RUNNING TEST: extension_testEvalStatement
Modified: trunk/LayoutTests/platform/mac/http/tests/inspector/console-resource-errors-expected.txt (148494 => 148495)
--- trunk/LayoutTests/platform/mac/http/tests/inspector/console-resource-errors-expected.txt 2013-04-16 05:56:18 UTC (rev 148494)
+++ trunk/LayoutTests/platform/mac/http/tests/inspector/console-resource-errors-expected.txt 2013-04-16 06:12:22 UTC (rev 148495)
@@ -4,5 +4,5 @@
GET http://127.0.0.1:8000/inspector/missing.css 404 (Not Found) console-resource-errors-iframe.html:3 console-message console-error-level
GET http://127.0.0.1:8000/inspector/non-existent-iframe.html 404 (Not Found) non-existent-iframe.html:1 console-message console-error-level
GET http://127.0.0.1:8000/inspector/non-existent-script.js 404 (Not Found) console-resource-errors-iframe.html:4 console-message console-error-level
-GET http://127.0.0.1:8000/inspector/non-existent-xhr 404 (Not Found) [native code]:1send [native code]:1loadXHR console-resource-errors.html:18performActions console-resource-errors.html:10eval codeeval [native code]:1(anonymous function)(anonymous function)_evaluateOn_evaluateAndWrapevaluate console-message console-error-level
+GET http://127.0.0.1:8000/inspector/non-existent-xhr 404 (Not Found) [native code]:1send [native code]:1loadXHR console-resource-errors.html:18performActions console-resource-errors.html:10eval codeeval [native code]:1_evaluateOn_evaluateAndWrapevaluate console-message console-error-level
Modified: trunk/Source/WebCore/ChangeLog (148494 => 148495)
--- trunk/Source/WebCore/ChangeLog 2013-04-16 05:56:18 UTC (rev 148494)
+++ trunk/Source/WebCore/ChangeLog 2013-04-16 06:12:22 UTC (rev 148495)
@@ -1,3 +1,16 @@
+2013-04-15 Timothy Hatcher <[email protected]>
+
+ Web Inspector: Make var and function declarations work again in the Console.
+
+ https://webkit.org/b/114534
+ rdar://problem/13614477
+
+ Reviewed by Oliver Hunt.
+
+ * inspector/InjectedScriptSource.js:
+ (InjectedScript.prototype._evaluateOn): Use 'with' when not evaluating
+ on a call frame.
+
2013-04-15 Seokju Kwon <[email protected]>
Web Inspector: Add missing Localized strings
Modified: trunk/Source/WebCore/inspector/InjectedScriptSource.js (148494 => 148495)
--- trunk/Source/WebCore/inspector/InjectedScriptSource.js 2013-04-16 05:56:18 UTC (rev 148494)
+++ trunk/Source/WebCore/inspector/InjectedScriptSource.js 2013-04-16 06:12:22 UTC (rev 148495)
@@ -550,41 +550,64 @@
*/
_evaluateOn: function(evalFunction, object, objectGroup, _expression_, isEvalOnCallFrame, injectCommandLineAPI)
{
- // We can only use this approach if the evaluate function is the true 'eval'. That allows us to use it with
- // the 'eval' identifier when calling it. Using 'eval' grants access to the local scope of the closure we
- // create that provides the command line APIs.
+ var commandLineAPI = injectCommandLineAPI ? new CommandLineAPI(this._commandLineAPIImpl, isEvalOnCallFrame ? object : null) : null;
- var parameters = [InjectedScriptHost.evaluate, _expression_];
- var expressionFunctionBody = "var __originalEval = window.eval; window.eval = __eval; try { return eval(__currentExpression); } finally { window.eval = __originalEval; }";
+ if (isEvalOnCallFrame) {
+ // We can only use this approach if the evaluate function is the true 'eval'. That allows us to use it with
+ // the 'eval' identifier when calling it. Using 'eval' grants access to the local scope of the closure we
+ // create that provides the command line APIs.
- if (injectCommandLineAPI) {
- // To avoid using a 'with' statement (which fails in strict mode and requires injecting the API object)
- // we instead create a closure where we evaluate the _expression_. The command line APIs are passed as
- // parameters to the closure so they are in scope but not injected. This allows the code evaluated in
- // the console to stay in strict mode (if is was already set), or to get strict mode by prefixing
- // expressions with 'use strict';.
+ var parameters = [InjectedScriptHost.evaluate, _expression_];
+ var expressionFunctionBody = "var __originalEval = window.eval; window.eval = __eval; try { return eval(__currentExpression); } finally { window.eval = __originalEval; }";
- var commandLineAPI = new CommandLineAPI(this._commandLineAPIImpl, isEvalOnCallFrame ? object : null);
- var parameterNames = Object.getOwnPropertyNames(commandLineAPI);
- for (var i = 0; i < parameterNames.length; ++i)
- parameters.push(commandLineAPI[parameterNames[i]]);
+ if (commandLineAPI) {
+ // To avoid using a 'with' statement (which fails in strict mode and requires injecting the API object)
+ // we instead create a closure where we evaluate the _expression_. The command line APIs are passed as
+ // parameters to the closure so they are in scope but not injected. This allows the code evaluated in
+ // the console to stay in strict mode (if is was already set), or to get strict mode by prefixing
+ // expressions with 'use strict';.
- var expressionFunctionString = "(function(__eval, __currentExpression, " + parameterNames.join(", ") + ") { " + expressionFunctionBody + " })";
- } else {
- // Use a closure in this case too to keep the same behavior of 'var' being captured by the closure instead
- // of leaking out into the calling scope.
- var expressionFunctionString = "(function(__eval, __currentExpression) { " + expressionFunctionBody + " })";
+ var parameterNames = Object.getOwnPropertyNames(commandLineAPI);
+ for (var i = 0; i < parameterNames.length; ++i)
+ parameters.push(commandLineAPI[parameterNames[i]]);
+
+ var expressionFunctionString = "(function(__eval, __currentExpression, " + parameterNames.join(", ") + ") { " + expressionFunctionBody + " })";
+ } else {
+ // Use a closure in this case too to keep the same behavior of 'var' being captured by the closure instead
+ // of leaking out into the calling scope.
+ var expressionFunctionString = "(function(__eval, __currentExpression) { " + expressionFunctionBody + " })";
+ }
+
+ // Bind 'this' to the function _expression_ using another closure instead of Function.prototype.bind. This ensures things will work if the page replaces bind.
+ var boundExpressionFunctionString = "(function(__function, __thisObject) { return function() { return __function.apply(__thisObject, arguments) }; })(" + expressionFunctionString + ", this)";
+ var expressionFunction = evalFunction.call(object, boundExpressionFunctionString);
+ var result = expressionFunction.apply(null, parameters);
+
+ if (objectGroup === "console")
+ this._lastResult = result;
+
+ return result;
}
- // Bind 'this' to the function _expression_ using another closure instead of Function.prototype.bind. This ensures things will work if the page replaces bind.
- var boundExpressionFunctionString = "(function(__function, __thisObject) { return function() { return __function.apply(__thisObject, arguments) }; })(" + expressionFunctionString + ", this)";
- var expressionFunction = evalFunction.call(object, boundExpressionFunctionString);
- var result = expressionFunction.apply(null, parameters);
+ // When not evaluating on a call frame we use a 'with' statement to allow var and function statements to leak
+ // into the global scope. This allow them to stick around between evaluations.
- if (objectGroup === "console")
- this._lastResult = result;
+ try {
+ if (commandLineAPI && inspectedWindow.console) {
+ inspectedWindow.console.__commandLineAPI = commandLineAPI;
+ _expression_ = "with ((window && window.console && window.console.__commandLineAPI) || {}) { " + _expression_ + " }";
+ }
- return result;
+ var result = evalFunction.call(object, _expression_);
+
+ if (objectGroup === "console")
+ this._lastResult = result;
+
+ return result;
+ } finally {
+ if (commandLineAPI && inspectedWindow.console)
+ delete inspectedWindow.console.__commandLineAPI;
+ }
},
/**