Closed Bug 812814 Opened 12 years ago Closed 12 years ago

Add a way to edit or remove watch expressions while the debugger is paused

Categories

(DevTools :: Debugger, defect, P2)

defect

Tracking

(firefox19 fixed)

RESOLVED FIXED
Firefox 20
Tracking Status
firefox19 --- fixed

People

(Reporter: vporof, Assigned: vporof)

Details

(Whiteboard: [fixed-in-fx-team])

Attachments

(3 files, 2 obsolete files)

When paused, there's no way to remove watch expressions, because they're part of the variables view. We could either use a customizable context menu for variables/properties, or the ability to show the [x] button on certain elements.
Summary: Add a way to remove watch expressions while the debugger is paused → Add a way to edit or remove watch expressions while the debugger is paused
Hi, I just ran into this with a webdev.  In our case, we were using watched expressions to evaluate arbitrary expressions which meant we were accumulating a bunch of watched expressions that we couldn't clear out.  (Is there a better way to interactively evaluate JS?)
Currently, this is the only supported way of evaluating JS when execution is paused. We plan to make the web console and scratchpad usable in such cases, too, but we are not there, yet. We should have this bug fixed in the next few weeks.
Assignee: nobody → vporof
Status: NEW → ASSIGNED
Priority: -- → P2
(In reply to Luke Wagner [:luke] from comment #1)
> Hi, I just ran into this with a webdev.  In our case, we were using watched
> expressions to evaluate arbitrary expressions which meant we were
> accumulating a bunch of watched expressions that we couldn't clear out.  (Is
> there a better way to interactively evaluate JS?)

I wonder, would a "Persist watch expressions" pref (defaults to true, exposed as an option in the gear menu) be helpful? I imagine there are plenty of people that use watch expressions (not the webconsole) solely for evaluating arbitrary js. Of course, when we'll have other means to evaluate code in the context of the current frame, then that pref may be redundant, but I'm thinking about *habits* here.
That's a good question.  In Visual Studio's debugger, there is the "immediate" window (whose purpose would be filled by the web console, iiuc) which is separate from the watch window.  I have also seen devs who didn't know about the immediate window constantly adding watch expressionst.  Perhaps then a "fix" would be to make it easier to discover that you can interactively evaluate JS from the debugger UI.  I'm not a UI guy, but one idea that comes to mind is that, to the right of the "Add watch expression" text (in the same box) you have a link "Evaluate JS" that, when clicked, just opens up the web console.
Attached patch v1 (obsolete) — Splinter Review
Works, needs a test.
Attached patch v2 (obsolete) — Splinter Review
Fixed tests, added tooltips, polished etc.
Attachment #684840 - Attachment is obsolete: true
Attached patch v3Splinter Review
Added test, going through try.
Attachment #684849 - Attachment is obsolete: true
Attachment #684940 - Flags: review?(past)
Comment on attachment 684940 [details] [diff] [review]
v3

Review of attachment 684940 [details] [diff] [review]:
-----------------------------------------------------------------

Very nice! My only gripe is that editing the result of a watch expression is allowed, and even though the edit will be reverted after pressing ENTER, it can be confusing to a developer.

Also, it would be nice if we could get a version of this patch without the string changes for Aurora.

::: browser/devtools/debugger/debugger-panes.js
@@ +944,5 @@
>   */
>  function WatchExpressionsView() {
>    dumpn("WatchExpressionsView was instantiated");
>    MenuContainer.call(this);
> +  this.switchExpression = this.switchExpression.bind(this);

Nit: I'd go for changeExpression myself.

::: browser/devtools/debugger/test/browser_dbg_propertyview-edit-watch.js
@@ +14,5 @@
> +var gVars = null;
> +
> +requestLongerTimeout(2);
> +
> +function test() {

Can you add one line describing this test please?

::: browser/devtools/shared/VariablesView.jsm
@@ +640,5 @@
>    set twisty(aFlag) aFlag ? this.showArrow() : this.hideArrow(),
>  
>    /**
> +   * Specifies if editing variable or property names is allowed.
> +   * This flag applies non-recursively on the current scope.

s/on/to/g
Attachment #684940 - Flags: review?(past) → review+
(In reply to Panos Astithas [:past] from comment #9)
> Comment on attachment 684940 [details] [diff] [review]
> v3
> 
> Review of attachment 684940 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> Very nice! My only gripe is that editing the result of a watch expression is
> allowed, and even though the edit will be reverted after pressing ENTER, it
> can be confusing to a developer.
> 

Well, maybe. The changes aren't always reverted. For example, go to http://htmlpad.org/debugger/ and add the following watch expressions: "arguments[0]" and "aArg". Click me, and when on the first debugger statement, change the evaluation value of arguments[0] to be "42" or whatever. This change persists in the whole watch expressions scope, and in all the other scopes.

So my hypothesis is that there may be some remote use cases in which editing the watch expressions evaluation result may be useful (albeit confusing in others). If not, then my backup argument is that copying the result isn't possible without the textbox :) What do you think?

> Also, it would be nice if we could get a version of this patch without the
> string changes for Aurora.
> 

I was just about to suggest that.
(In reply to Victor Porof [:vp] from comment #10)
> (In reply to Panos Astithas [:past] from comment #9)
> > Very nice! My only gripe is that editing the result of a watch expression is
> > allowed, and even though the edit will be reverted after pressing ENTER, it
> > can be confusing to a developer.
> > 
> 
> Well, maybe. The changes aren't always reverted. For example, go to
> http://htmlpad.org/debugger/ and add the following watch expressions:
> "arguments[0]" and "aArg". Click me, and when on the first debugger
> statement, change the evaluation value of arguments[0] to be "42" or
> whatever. This change persists in the whole watch expressions scope, and in
> all the other scopes.
> 
> So my hypothesis is that there may be some remote use cases in which editing
> the watch expressions evaluation result may be useful (albeit confusing in
> others). If not, then my backup argument is that copying the result isn't
> possible without the textbox :) What do you think?

Good points, agreed.
Addressed comments.
Whiteboard: [land-in-fx-team]
Attachment #685160 - Attachment description: v3.1 → v3.1 [land-me]
Attachment #685164 - Attachment is patch: true
https://hg.mozilla.org/integration/fx-team/rev/afb00af6ee8f
Whiteboard: [land-in-fx-team] → [fixed-in-fx-team]
Attachment #685160 - Attachment description: v3.1 [land-me] → v3.1 [in-fx-team]
https://hg.mozilla.org/mozilla-central/rev/afb00af6ee8f
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 20
Comment on attachment 685164 [details] [diff] [review]
v3.1 [aurora:no-string-changes]

[Approval Request Comment]
Bug caused by (feature/regressing bug #): Watch expressions can't be modified or removed while the debugger is paused. It sucks :)
User impact if declined: Almost none, this patch affects a developer tool, however it's a brand new feature that is likely to get some attention.
Testing completed (on m-c, etc.): fx-team and m-c
Risk to taking this patch (and alternatives if risky): None
String or UUID changes made by this patch: None with this patch
Attachment #685164 - Flags: approval-mozilla-aurora?
Comment on attachment 685164 [details] [diff] [review]
v3.1 [aurora:no-string-changes]

[Triage Comment]
Low risk fix for a new dev feature. Approving for Aurora 19.
Attachment #685164 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: