Closed Bug 901517 Opened 11 years ago Closed 11 years ago

Observable Object: use EventEmitter.decorate and fix array issue

Categories

(DevTools Graveyard :: WebIDE, defect)

x86
All
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 26

People

(Reporter: paul, Assigned: paul)

References

Details

Attachments

(2 files, 1 obsolete file)

      No description provided.
Blocks: 901521
Attached patch Patch v1 (obsolete) — Splinter Review
To easily inherit from ObservableObject, it's better to use EventEmitter.decorate. Also, we were returning the wrong path sometimes.
Attachment #787451 - Flags: review?(poirot.alex)
Comment on attachment 787451 [details] [diff] [review]
Patch v1

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

Also I'm seing what looks like strict JS errors, can you set strict mode and fix eventual exeptions.
(Like `path` not being declared anywhere here http://mxr.mozilla.org/mozilla-central/source/browser/devtools/shared/observable-object.js#107)

::: browser/devtools/shared/observable-object.js
@@ -43,4 @@
>  
>  function isObject(value) {
>    return Object(value) === value;
>  }

I think that's a bad way to check for objects.
I'm expecting to see failure if we get cross compartments objects.
Could you use this pattern instead?
http://mxr.mozilla.org/mozilla-central/source/testing/specialpowers/content/specialpowersAPI.js?force=1#48
(This code has been written by bholley... I trust him when it comes to wrappers ;))

@@ -70,5 @@
>    unwrap: function(target, key, value) {
>      if (!isObject(value) || !this._wrappers.has(value)) {
>        return [value, this._paths.get(target).concat(key)];
>      }
> -    return [this._wrappers.get(value), this._paths.get(value)];

I'm new to ObservableObject implementation, I do not easily what it fixes,
what about having a test covering this fix?
Attachment #787451 - Flags: review?(poirot.alex)
Attached patch Patch v1.1Splinter Review
(In reply to Alexandre Poirot (:ochameau) from comment #2)
> Also I'm seing what looks like strict JS errors, can you set strict mode and
> fix eventual exeptions.
> (Like `path` not being declared anywhere here
> http://mxr.mozilla.org/mozilla-central/source/browser/devtools/shared/
> observable-object.js#107)

Addressed ("use strict").

> ::: browser/devtools/shared/observable-object.js
> @@ -43,4 @@
> >  
> >  function isObject(value) {
> >    return Object(value) === value;
> >  }
> 
> I think that's a bad way to check for objects.
> I'm expecting to see failure if we get cross compartments objects.
> Could you use this pattern instead?
> http://mxr.mozilla.org/mozilla-central/source/testing/specialpowers/content/
> specialpowersAPI.js?force=1#48
> (This code has been written by bholley... I trust him when it comes to
> wrappers ;))

wut? How can it be bad?

> @@ -70,5 @@
> >    unwrap: function(target, key, value) {
> >      if (!isObject(value) || !this._wrappers.has(value)) {
> >        return [value, this._paths.get(target).concat(key)];
> >      }
> > -    return [this._wrappers.get(value), this._paths.get(value)];
> 
> I'm new to ObservableObject implementation, I do not easily what it fixes,
> what about having a test covering this fix?

We were getting an exception when re-using existing wrapped objects into new properties. I have added some more tests to cover this.
Attachment #787451 - Attachment is obsolete: true
Attachment #788918 - Flags: review?(poirot.alex)
Comment on attachment 788918 [details] [diff] [review]
Patch v1.1

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

> > ::: browser/devtools/shared/observable-object.js
> > @@ -43,4 @@
> > >  
> > >  function isObject(value) {
> > >    return Object(value) === value;
> > >  }
> > 
> > I think that's a bad way to check for objects.
> > I'm expecting to see failure if we get cross compartments objects.
> > Could you use this pattern instead?
> > http://mxr.mozilla.org/mozilla-central/source/testing/specialpowers/content/
> > specialpowersAPI.js?force=1#48
> > (This code has been written by bholley... I trust him when it comes to
> > wrappers ;))
> 
> wut? How can it be bad?

If you have a wrapper at some point, your isObject function will behave incorrectly.
You can see that by executing this in the (old) error console:
  JObject(content) == content 
  false

Please tweak this method, that would be unfortunate to loose time on wrapper issues...
Attachment #788918 - Flags: review?(poirot.alex) → review+
Attached patch patch v2Splinter Review
Whiteboard: [land-in-fx-team]
Whiteboard: [land-in-fx-team]
https://hg.mozilla.org/mozilla-central/rev/fde7ed54c2cb
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 26
Product: Firefox → DevTools
Product: DevTools → DevTools Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: