Closed Bug 579339 Opened 14 years ago Closed 14 years ago

Improve JS/DOM Object Introspector

Categories

(DevTools :: General, defect)

Other
Other
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 573102

People

(Reporter: julian.viereck, Assigned: julian.viereck)

References

Details

Attachments

(1 file, 4 obsolete files)

This is a following bug for 573102. PropertyPanel didn't worked before for the 
window or document object. Arrays can now be inspected. Few other adjustments.
Attached patch Patch (obsolete) — Splinter Review
Attachment #457856 - Flags: review?(dietrich)
Attached patch Patch rebased (obsolete) — Splinter Review
Same as former patch attachment 457856 [details] [diff] [review], but rebased.
Attachment #457856 - Attachment is obsolete: true
Attachment #458296 - Flags: review?(dietrich)
Attachment #457856 - Flags: review?(dietrich)
Attached patch Patch rebase 2 (obsolete) — Splinter Review
Rebase with trunk.

Also, add a new JSTerm evalInSandbox() function as a result of bug 574033. Improved the unit test a little bit.
Attachment #458296 - Attachment is obsolete: true
Attachment #458358 - Flags: review?(dietrich)
Attachment #458296 - Flags: review?(dietrich)
Attachment #458358 - Flags: feedback?(ddahl)
blocking2.0: --- → ?
I'm requesting 2.0 blocking status for this bug as the added patch improves an important feature that is required by the WebConsole (aka Heads Up Display) and DOM Inspector.
Attached patch Patch 1.1 (obsolete) — Splinter Review
Same as 458358 but without two Services.console.logStringMessage(...args); statements.
Attachment #458358 - Attachment is obsolete: true
Attachment #459338 - Flags: feedback?(ddahl)
Attachment #458358 - Flags: review?(dietrich)
Attachment #458358 - Flags: feedback?(ddahl)
Comment on attachment 459338 [details] [diff] [review]
Patch 1.1


>+function unwrapObject(aObject)
> {
>-  if (!aObject) {
>-    return false;
>+  if (typeof(aObject) === "undefined" || aObject == null) {
>+    return aObject;
is this supposed to actually unwrap an object? You can also do: return XPCNativeWrapper.unwrap(aObject)

>-  // DISCUSS: Why not showing the body of the function as well?
perhaps because it is deep in chrome code so you will be shown "[Native Code]" or something like that.


>+/**
>+ * Get an array of property name value pairs for the tree.
>  *
>  * @param object aObject
>  *        The object to get properties for.
>  * @returns array of object
>- *          Objects have the name: and value: properties.
>+ *          Objects have the name, value, display, type, children properties.
>  */
> function namesAndValuesOf(aObject)
> {
>   let pairs = [];
>+  let value, presentable;
> 
>-  for (var name in aObject) {
>+  for (var propName in aObject) {
>+    try {
>+      value = aObject[propName];
>+      presentable = presentableValueFor(value);
>+    }
>+    catch (ex) {
>+      continue;
>+    }
>+
>     let pair = {};
>-    pair.name = name;
>-    pair.display = name + ': ' + presentableValueFor(aObject[name], name);
>-    pair.value = aObject[name];
>+    pair.name = propName;
>+    pair.display = propName + ": " + presentable.display;
>+    pair.type = presentable.type;
>+    pair.value = value;
>+
>+    // Convert the pair.name to a number for later sorting.
>+    pair.nameNumber = parseFloat(pair.name)
>+    if (isNaN(pair.nameNumber)) {
>+      pair.nameNumber = false;
>+    }
> 
>     pairs.push(pair);
>   }
> 
>   pairs.sort(function(a, b)
>   {
>-    if (a.name < b.name) {
>+    // Sort numbers.
>+    if (a.nameNumber !== false && b.nameNumber === false) {
>+      return 1;
>+    }
>+    else if (a.nameNumber === false && b.nameNumber !== false) {
>       return -1;
>     }
>-    if (a.name > b.name) {
>+    else if (a.nameNumber !== false && b.nameNumber !== false) {
>+      return a.nameNumber - b.nameNumber;
>+    }
>+    // Sort string.
>+    else if (a.name < b.name) {
>+      return -1;
>+    }
>+    else if (a.name > b.name) {
>       return 1;
>     }
>-    return 0;
>+    else {
>+      return 0;
>+    }
>   });
> 

Have you tested this sorting on some objects with many properties of varying types?

>   return pairs;
> }
>
Attached patch Patch 1.2Splinter Review
Updated patch:
- tuned sorting algorithm to put numbers infront of characters
- added testcase for property sorting
- removed unwrap() function. I tested this on the window/document object + some other JS objects and I could see no regression when removing them.
Attachment #459338 - Attachment is obsolete: true
Attachment #460207 - Flags: feedback?(ddahl)
Attachment #459338 - Flags: feedback?(ddahl)
I'd like to block once on either this bug or bug 573102. This was filed as a follow up to bug 573102, but it hasn't landed yet - is merging them into one bug a bad idea for some reason?
(In reply to comment #8)
> I'd like to block once on either this bug or bug 573102. This was filed as a
> follow up to bug 573102, but it hasn't landed yet - is merging them into one
> bug a bad idea for some reason?

No, it is not a bad idea. two patches on one bug. yay!
Comment on attachment 460207 [details] [diff] [review]
Patch 1.2

looks good, nice test.
Attachment #460207 - Flags: feedback?(ddahl) → feedback+
The patch of this bug has been merged in bug 573102. Mark this as duplicate to not confuse people as work/review is done on that bug now.
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → DUPLICATE
blocking2.0: ? → ---
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: