Last Comment Bug 642196 - GCLI should allow JS to be entered using {}
: GCLI should allow JS to be entered using {}
[minotaur][best:3d, likely:5d, worst:...
Product: Firefox
Classification: Client Software
Component: Developer Tools (show other bugs)
: unspecified
: All All
-- normal (vote)
: ---
Assigned To: Joe Walker [:jwalker] (needinfo me or ping on irc)
: J. Ryan Stinnett [:jryans] (use ni?)
Depends on: 653979
Blocks: GCLI-JS
  Show dependency treegraph
Reported: 2011-03-16 11:10 PDT by Joe Walker [:jwalker] (needinfo me or ping on irc)
Modified: 2011-08-22 00:54 PDT (History)
2 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Description User image Joe Walker [:jwalker] (needinfo me or ping on irc) 2011-03-16 11:10:58 PDT
Previous developer tool command lines have been primarily JS based. While this is somewhat limiting, it does allow easy interaction with the DOM and JS data. GCLI should allow this access using something like the following:

> echo {window.title}
"Enter Bug"

> {console.log('hi')}

It is expected that the command line will have a toggle switch to allow JS input to be the default.

The system will allow JS to be the default, allowing use of JS without either "{}" or the toggle switch:

> eval 2+2

The system may need integration with a JS parser like narcissus or uglify to allow us to recognize matching {}
Comment 1 User image Nick Fitzgerald [:fitzgen] [⏰PST; UTC-8] 2011-06-15 17:09:56 PDT
Kind of a non-sequitor:

The ipython enhanced python shell uses `!` to distinguish shell commands from python code.

For example, this is interpreted as python:

    > foo = 5

and this would be a shell command:

    > !ls -al

Would it make sense to alias "eval" to "!"? I think "eval" is quite long, and though it is useful for learning the GCLI, as soon as you know it you want something more concise:

    > <normal commands>
    > !<arbitrary javascript>

Comment 2 User image Joe Walker [:jwalker] (needinfo me or ping on irc) 2011-06-16 03:04:49 PDT
I suggested {} for 2 reasons:
- it allows something after the JS
- {} already has the notion of containment in JS.
Comment 3 User image Rob Campbell [:rc] (:robcee) 2011-06-20 15:53:16 PDT
{} is used for defining an object literal. Using it as a wrapper for code to evaluate could be confusing.

I'm not sure I like the ! notation either for a more modern shell either. That makes sense in a non-graphical environment like iPython (or Bash or whatever). It makes less sense in a "graphical" command line. Could we toggle Eval mode with a button + keyboard shortcut combo?
Comment 4 User image Joe Walker [:jwalker] (needinfo me or ping on irc) 2011-06-20 16:02:49 PDT
The confusion between {} for defining a block and for defining an object literal isn't *that* great though is it?

And wouldn't most web developers that are going to want to type JS into the command line already get the dual uses?
Comment 5 User image Rob Campbell [:rc] (:robcee) 2011-06-20 16:45:15 PDT
yeah, no doubt. It's just kind of a strange case of overloading.

Evaluating JS seems like it might be a special enough case that it could warrant some additional UI. Just a thought.
Comment 6 User image Rob Campbell [:rc] (:robcee) 2011-06-23 16:08:12 PDT
another alternative syntax that will make a bit more sense if this becomes spec:

{||} block syntax.

(or even {|} with no block arguments.

e.g., {| // some javascript }
Comment 7 User image Joe Walker [:jwalker] (needinfo me or ping on irc) 2011-06-24 00:27:40 PDT
Nice idea, thanks Rob.

Note You need to log in before you can comment on or make changes to this bug.