Closed Bug 760370 Opened 12 years ago Closed 11 years ago

Visually distinguish non-extensible objects

Categories

(DevTools :: Debugger, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 24

People

(Reporter: past, Assigned: fitzgen)

References

Details

Attachments

(1 file, 2 obsolete files)

From a recent discussion in es-discuss:

https://mail.mozilla.org/pipermail/es-discuss/2012-May/022991.html

We could alter the display of frozen, sealed and non-extensible objects in a similar fashion to what we do for writable, enumerable and configurable properties. I imagine a single character at the right side of the object value, with a "float: right" alignment, that reads either F(rozen), S(ealed) or N(on-extensible). Other ideas are more than welcome.
Assignee: nobody → vporof
Priority: -- → P3
Status: NEW → ASSIGNED
Making a note here:
We need protocol support. There's information only about the writable, enumerable, configurable properties in the messages.
Assignee: vporof → nfitzgerald
Somehow I think it would be more useful to have this in-your-face, not hidden in a tooltip. You don't get such objects everywhere, and it's important to.. distinguish them.
Victor, fair enough.

Uploading my existing WIP now.
Attached patch wip (obsolete) — Splinter Review
Breaking some mochitests, but hopefully I can sidestep this issue when switching from tooltips to something more in your face, as Victor suggests.
Attached patch v1 (obsolete) — Splinter Review
https://tbpl.mozilla.org/?tree=Try&rev=ca4f3deb58d3
Attachment #750523 - Attachment is obsolete: true
Attachment #750728 - Flags: review?(vporof)
Comment on attachment 750728 [details] [diff] [review]
v1

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

Exemplary, but take a look at the comments below.

::: browser/devtools/debugger/test/browser_dbg_propertyview-12.js
@@ +24,5 @@
> +}
> +
> +function testFSN() {
> +  gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
> +    // XXX: Let the variables view do its thing and setup before we begin testing.

I don't entirely understand this. Do what thing? Although I'm not happy about it, I'm not against a thread dispatch since all other test do this, so ok! But this comment makes me think you might want to listen to Debugger:FetchedVariables instead, otherwise intermittents may occur. (see other tests).

@@ +65,5 @@
> +    },
> +    extensible: hasNoneTester,
> +    string: hasNoneTester,
> +    arguments: hasNoneTester,
> +    this: hasNoneTester

This brings back FP memories. Thank you.

::: browser/devtools/shared/widgets/VariablesView.jsm
@@ +2389,4 @@
>        tooltip.setAttribute("orient", "horizontal");
> +
> +      let labels = ["configurable", "enumerable", "writable", "native-getter",
> +                    "frozen", "sealed", "non-extensible"];

We.. should really localize these at some point. Care to file a followup bug?

@@ +2389,5 @@
>        tooltip.setAttribute("orient", "horizontal");
> +
> +      let labels = ["configurable", "enumerable", "writable", "native-getter",
> +                    "frozen", "sealed", "non-extensible"];
> +      labels.forEach(label => {

When did for..of become too mainstream?

@@ +2423,5 @@
>  
>      if (this.ownerView.eval) {
>        this._target.setAttribute("editable", "");
>      }
> +    if (!descriptor.null) {

descriptor.null is a hack that makes me really sad. I'll file a bug to change it to something better.

@@ +2433,5 @@
> +      }
> +      if (!descriptor.writable && !this.ownerView.getter && !this.ownerView.setter) {
> +        this._target.setAttribute("non-writable", "");
> +      }
> +      if (descriptor.value && typeof descriptor.value === "object") {

Nit: I'd use == since really, typeof always returns strings, but I'm not holding a gun.

::: browser/themes/linux/devtools/widgets.css
@@ +531,5 @@
>    text-shadow: 0 0 8px #fcc;
>  }
>  
> +.variable-or-property[non-extensible]:not([non-writable]) > .title:after {
> +  content: "N";

I'm not sure how I feel about this. These should probably be localized, but since tooltips aren't localized either, the followup bug I mentioned earlier would be ok.
Attachment #750728 - Flags: review?(vporof) → review+
(In reply to Victor Porof [:vp] from comment #7)
> ::: browser/devtools/shared/widgets/VariablesView.jsm
> @@ +2389,4 @@
> >        tooltip.setAttribute("orient", "horizontal");
> > +
> > +      let labels = ["configurable", "enumerable", "writable", "native-getter",
> > +                    "frozen", "sealed", "non-extensible"];
> 
> We.. should really localize these at some point. Care to file a followup bug?

Why do we need to localize values specified in the JavaScript language? I don't believe anyone thinks in their native language when reading code.

But maybe we should change non-extensible to extensible. It's the only negative term and the strikeout effect would amount to a double negative.
> Why do we need to localize values specified in the JavaScript language? I
> don't believe anyone thinks in their native language when reading code.
> 

Good point. If you think it's ok, then I won't be worried. Although "native-getter" seems to be a special case, switching to "WebIDL" sounds good and universal.

> But maybe we should change non-extensible to extensible. It's the only
> negative term and the strikeout effect would amount to a double negative.

Agreed.
> But maybe we should change non-extensible to extensible. It's the only negative
> term and the strikeout effect would amount to a double negative.

I think this could possibly be more confusing because

a) we don't show the tooltip when an object is extensible (which I can change, but the vast majority of objects are, and I think always showing it would be clutter)

b) it isn't double negative because it isn't strike-through'd

c) The "N" wouldn't stand for non-extensble anymore. I guess we could do an "E" with a strike-through.

Thoughts?
Now that I've actually played with the patch I see what you mean. It looks fine to me.
So can I [land-in-fx-team] this bad boy?
Yes please!
Whiteboard: [land-in-fx-team]
Or not! No updated patch yet. The only thing I mostly care about is using Debugger:FetchedVariables instead of framesadded, like I said in comment #7. I wouldn't mind the rest of the nits addressed, but they're.. just nits :)
Whiteboard: [land-in-fx-team]
Attached patch V2Splinter Review
* Using Debugger:FetchedVariables in test

* Using for of loop instead of forEach

* Using == instead of === in string comparison

* Rebased on new devtools directory structure

https://tbpl.mozilla.org/?tree=Try&rev=64b1769b7371
Attachment #750728 - Attachment is obsolete: true
Attachment #755745 - Flags: review?(vporof)
Comment on attachment 755745 [details] [diff] [review]
V2

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

Ship it!
Attachment #755745 - Flags: review?(vporof) → review+
Whiteboard: [land-in-fx-team]
https://hg.mozilla.org/integration/fx-team/rev/842928279e36
Whiteboard: [land-in-fx-team] → [fixed-in-fx-team]
https://hg.mozilla.org/mozilla-central/rev/842928279e36
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 24
Depends on: 881209
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: