Changeset 194149 in webkit


Ignore:
Timestamp:
Dec 16, 2015 9:40:15 AM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: Typing object literal in the console causes a parse error
https://bugs.webkit.org/show_bug.cgi?id=141737

Patch by Joseph Pecoraro <Joseph Pecoraro> on 2015-12-16
Reviewed by Timothy Hatcher.

Source/WebInspectorUI:

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.

LayoutTests:

  • inspector/controller/runtime-controller-expected.txt: Added.
  • inspector/controller/runtime-controller.html: Added.
Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r194143 r194149  
     12015-12-16  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Typing object literal in the console causes a parse error
     4        https://bugs.webkit.org/show_bug.cgi?id=141737
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * inspector/controller/runtime-controller-expected.txt: Added.
     9        * inspector/controller/runtime-controller.html: Added.
     10
    1112015-12-08  Sergio Villar Senin  <svillar@igalia.com>
    212
  • trunk/Source/WebInspectorUI/ChangeLog

    r194148 r194149  
     12015-12-16  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Typing object literal in the console causes a parse error
     4        https://bugs.webkit.org/show_bug.cgi?id=141737
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        Provide a convenience in console evaluations for JSON object like input.
     9        If the console input starts with '{' and ends with '}' wrap the input
     10        in parenthesis to force evaluation as an expression.
     11
     12        For example, input "{a:1}" would be convenience wrapped to "({a:1})"
     13        and produce the expected object. This helps avoid the unusual treatment
     14        of "{a:1}" as program containing a labeled statement, which is often
     15        not what the user expects. And in more realistic cases, like "{a:1, b:2}",
     16        produce a SyntaxError.
     17
     18        * UserInterface/Controllers/RuntimeManager.js:
     19        (WebInspector.RuntimeManager.prototype.evaluateInInspectedWindow):
     20        Detect and convenience wrap the given expression.
     21
    1222015-12-16  Joseph Pecoraro  <pecoraro@apple.com>
    223
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js

    r192383 r194149  
    4141            // There is no expression, so the completion should happen against global properties.
    4242            expression = "this";
     43        } else if (/^\s*\{/.test(expression) && /\}\s*$/.test(expression)) {
     44            // Transform {a:1} to ({a:1}) so it is treated like an object literal instead of a block with a label.
     45            expression = "(" + expression + ")";
    4346        }
    4447
Note: See TracChangeset for help on using the changeset viewer.