Modified: trunk/LayoutTests/ChangeLog (194148 => 194149)
--- trunk/LayoutTests/ChangeLog 2015-12-16 17:38:17 UTC (rev 194148)
+++ trunk/LayoutTests/ChangeLog 2015-12-16 17:40:15 UTC (rev 194149)
@@ -1,3 +1,13 @@
+2015-12-16 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Typing object literal in the console causes a parse error
+ https://bugs.webkit.org/show_bug.cgi?id=141737
+
+ Reviewed by Timothy Hatcher.
+
+ * inspector/controller/runtime-controller-expected.txt: Added.
+ * inspector/controller/runtime-controller.html: Added.
+
2015-12-08 Sergio Villar Senin <[email protected]>
Fix computation of min|max-content contribution of non-replaced blocks
Added: trunk/LayoutTests/inspector/controller/runtime-controller-expected.txt (0 => 194149)
--- trunk/LayoutTests/inspector/controller/runtime-controller-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/controller/runtime-controller-expected.txt 2015-12-16 17:40:15 UTC (rev 194149)
@@ -0,0 +1,22 @@
+Tests for the Runtime.parse command.
+
+
+== Running test suite: RuntimeManager
+-- Running test case: RuntimeManager.prototype.evaluateInInspectedWindow.ObjectLiteralConvenience
+Source: {a:1}
+PASS: Evaluation should produce an object.
+Source: {a:1, b:2}
+PASS: Evaluation should produce an object.
+Source: {a:1, b:2}
+PASS: Evaluation should produce an object.
+Source: { let a = 1; a += 1; a }
+PASS: Evaluation should produce an exception.
+Source: ;{a:1}
+PASS: Evaluation should produce the labeled statement's value.
+Source: {a:1};
+PASS: Evaluation should produce the labeled statement's value.
+Source: ;{a:1, b:2}
+PASS: Evaluation should produce an exception.
+Source: ;{ let a = 1; a += 1; a }
+PASS: Evaluation should produce the labeled statement's value.
+
Added: trunk/LayoutTests/inspector/controller/runtime-controller.html (0 => 194149)
--- trunk/LayoutTests/inspector/controller/runtime-controller.html (rev 0)
+++ trunk/LayoutTests/inspector/controller/runtime-controller.html 2015-12-16 17:40:15 UTC (rev 194149)
@@ -0,0 +1,66 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+<script>
+function test()
+{
+ let suite = InspectorTest.createAsyncSuite("RuntimeManager");
+
+ suite.addTestCase({
+ name: "RuntimeManager.prototype.evaluateInInspectedWindow.ObjectLiteralConvenience",
+ description: "Test evaluating an object literal string conveniently converts wraps it in parenthesis to avoid misinterpretation as a program with a block and labeled statement.",
+ test: (resolve, reject) => {
+ function testSource(_expression_, callback) {
+ const objectGroup = "test";
+ const includeCommandLineAPI = false;
+ const ignorePauseOnExceptionsAndMute = false;
+ const shouldReturnByValue = false;
+ const shouldGeneratePreview = false;
+ const shouldSaveResult = false;
+ WebInspector.runtimeManager.evaluateInInspectedWindow(_expression_, objectGroup, includeCommandLineAPI, ignorePauseOnExceptionsAndMute, shouldReturnByValue, shouldGeneratePreview, shouldSaveResult, (result, wasThrown) => {
+ InspectorTest.log("Source: " + _expression_);
+ callback(result, wasThrown);
+ });
+ }
+
+ function expectObject(result, wasThrown) {
+ InspectorTest.expectThat(result.type === "object", "Evaluation should produce an object.");
+ }
+
+ function expectException(result, wasThrown) {
+ InspectorTest.expectThat(wasThrown, "Evaluation should produce an exception.");
+ }
+
+ function expectValue(value) {
+ return function(result, wasThrown) {
+ InspectorTest.expectThat(result.value === value, "Evaluation should produce the labeled statement's value.");
+ }
+ }
+
+ // The convenience will detect these and make them objects.
+ testSource("{a:1}", expectObject);
+ testSource("{a:1, b:2}", expectObject);
+ testSource(" {a:1, b:2} ", expectObject);
+
+ // The convenience will incorrectly apply to these that would otherwise have been valid programs.
+ testSource("{ let a = 1; a += 1; a }", expectException);
+
+ // Test we can run non-convenience cases by not starting / ending with characters other than curly braces.
+ testSource(";{a:1}", expectValue(1));
+ testSource("{a:1};", expectValue(1));
+ testSource(";{a:1, b:2}", expectException);
+ testSource(";{ let a = 1; a += 1; a }", expectValue(2));
+
+ InspectorBackend.runAfterPendingDispatches(resolve);
+ }
+ });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests for the Runtime.parse command.</p>
+</body>
+</html>
Modified: trunk/Source/WebInspectorUI/ChangeLog (194148 => 194149)
--- trunk/Source/WebInspectorUI/ChangeLog 2015-12-16 17:38:17 UTC (rev 194148)
+++ trunk/Source/WebInspectorUI/ChangeLog 2015-12-16 17:40:15 UTC (rev 194149)
@@ -1,5 +1,26 @@
2015-12-16 Joseph Pecoraro <[email protected]>
+ Web Inspector: Typing object literal in the console causes a parse error
+ https://bugs.webkit.org/show_bug.cgi?id=141737
+
+ Reviewed by Timothy Hatcher.
+
+ Provide a convenience in console evaluations for JSON object like input.
+ If the console input starts with '{' and ends with '}' wrap the input
+ in parenthesis to force evaluation as an _expression_.
+
+ For example, input "{a:1}" would be convenience wrapped to "({a:1})"
+ and produce the expected object. This helps avoid the unusual treatment
+ of "{a:1}" as program containing a labeled statement, which is often
+ not what the user expects. And in more realistic cases, like "{a:1, b:2}",
+ produce a SyntaxError.
+
+ * UserInterface/Controllers/RuntimeManager.js:
+ (WebInspector.RuntimeManager.prototype.evaluateInInspectedWindow):
+ Detect and convenience wrap the given _expression_.
+
+2015-12-16 Joseph Pecoraro <[email protected]>
+
Uncaught Exception View has undefined exception URL
https://bugs.webkit.org/show_bug.cgi?id=152327
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js (194148 => 194149)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js 2015-12-16 17:38:17 UTC (rev 194148)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js 2015-12-16 17:40:15 UTC (rev 194149)
@@ -40,6 +40,9 @@
if (!_expression_) {
// There is no _expression_, so the completion should happen against global properties.
_expression_ = "this";
+ } else if (/^\s*\{/.test(_expression_) && /\}\s*$/.test(_expression_)) {
+ // Transform {a:1} to ({a:1}) so it is treated like an object literal instead of a block with a label.
+ _expression_ = "(" + _expression_ + ")";
}
_expression_ = appendWebInspectorSourceURL(_expression_);