Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Issue 5786 #47

Closed
wants to merge 5 commits into from

2 participants

This page is out of date. Refresh to see the latest.
Showing with 141 additions and 53 deletions.
  1. +141 −53 extension/content/firebug/chrome/reps.js
View
194 extension/content/firebug/chrome/reps.js
@@ -514,33 +514,46 @@ FirebugReps.Reference = domplate(Firebug.Rep,
// ********************************************************************************************* //
-FirebugReps.Arr = domplate(Firebug.Rep,
+function mightBeArray(obj, win)
{
- tag:
- OBJECTBOX({_repObject: "$object",
- $hasTwisty: "$object|hasSpecialProperties",
- onclick: "$onToggleProperties"},
- SPAN({"class": "arrayLeftBracket", role: "presentation"}, "["),
- FOR("item", "$object|longArrayIterator",
- TAG("$item.tag", {object: "$item.object"}),
- SPAN({"class": "arrayComma", role: "presentation"}, "$item.delim")
- ),
- SPAN({"class": "arrayRightBracket", role: "presentation"}, "]"),
- SPAN({"class": "arrayProperties", role: "group"})
- ),
+ try
+ {
+ if (!obj)
+ return false;
+ // do this first to avoid security 1000 errors
+ else if (obj instanceof Ci.nsIDOMHistory)
+ return false;
+
+ var view = Wrapper.getContentView(win || window);
+ // do this first to avoid security 1000 errors
+ if ("StorageList" in view && obj instanceof view.StorageList)
+ return false;
+ // do this first to avoid exceptions
+ else if (obj.toString() === "[xpconnect wrapped native prototype]")
+ return false;
+ }
+ catch (exc)
+ {
+ try
+ {
+ if (FBTrace.DBG_ERRORS)
+ {
+ // Something weird: without the try/catch, OOM, with no exception??
+ FBTrace.sysout("mightBeArray FAILS: " + exc, exc);
+ FBTrace.sysout("mightBeArray Fails on obj " + obj);
+ }
+ }
+ catch (exexc)
+ {
+ FBTrace.sysout("mightBeArray double ERROR " + exexc, exexc);
+ }
+ }
- shortTag:
- OBJECTBOX({_repObject: "$object",
- $hasTwisty: "$object|hasSpecialProperties",
- onclick: "$onToggleProperties"},
- SPAN({"class": "arrayLeftBracket", role: "presentation"}, "["),
- FOR("item", "$object|shortArrayIterator",
- TAG("$item.tag", {object: "$item.object"}),
- SPAN({"class": "arrayComma", role: "presentation"}, "$item.delim")
- ),
- SPAN({"class": "arrayRightBracket"}, "]"),
- SPAN({"class": "arrayProperties", role: "group"})
- ),
+ return true;
+}
+
+FirebugReps.ArrBase = domplate(Firebug.Rep,
+{
longArrayIterator: function(array)
{
@@ -699,16 +712,14 @@ FirebugReps.Arr = domplate(Firebug.Rep,
// Highlight multiple elements on the page.
Firebug.Inspector.highlightObject(arr, context);
},
+ titleTag:
+ SPAN({"class": "objectTitle"}, "$object|getTitleTag"),
// http://code.google.com/p/fbug/issues/detail?id=874
// BEGIN Yahoo BSD Source (modified here) YAHOO.lang.isArray, YUI 2.2.2 June 2007
isArray: function(obj, win)
{
- win = win || window;
-
- var view = Wrapper.getContentView(win);
-
- try
+ if (mightBeArray(obj, win))
{
if (!obj)
return false;
@@ -720,40 +731,116 @@ FirebugReps.Arr = domplate(Firebug.Rep,
return false;
else if (isFinite(obj.length) && typeof obj.splice === "function")
return true;
- else if (isFinite(obj.length) && typeof obj.callee === "function") // arguments
+ else if (Arr.isArray(obj))
return true;
- else if (obj instanceof view.HTMLCollection)
- return true;
- else if (obj instanceof view.NodeList)
- return true;
- }
- catch (exc)
- {
- try
- {
- if (FBTrace.DBG_ERRORS)
- {
- // Something weird: without the try/catch, OOM, with no exception??
- FBTrace.sysout("isArray FAILS: " + exc, exc);
- FBTrace.sysout("isArray Fails on obj " + obj);
- }
- }
- catch (exexc)
- {
- FBTrace.sysout("isArray double ERROR " + exexc, exexc);
- }
}
-
return false;
},
// END Yahoo BSD SOURCE See license below.
- getTitle: function(object, context)
+ getTitleTag: function(object, context)
{
return "[" + object.length + "]";
+ }
+});
+
+FirebugReps.Arr = domplate(FirebugReps.ArrBase,
+{
+ tag:
+ OBJECTBOX({_repObject: "$object",
+ $hasTwisty: "$object|hasSpecialProperties",
+ onclick: "$onToggleProperties"},
+ SPAN({"class": "arrayLeftBracket", role: "presentation"}, "["),
+ FOR("item", "$object|longArrayIterator",
+ TAG("$item.tag", {object: "$item.object"}),
+ SPAN({"class": "arrayComma", role: "presentation"}, "$item.delim")
+ ),
+ SPAN({"class": "arrayRightBracket", role: "presentation"}, "]"),
+ SPAN({"class": "arrayProperties", role: "group"})
+ ),
+
+ shortTag:
+ OBJECTBOX({_repObject: "$object",
+ $hasTwisty: "$object|hasSpecialProperties",
+ onclick: "$onToggleProperties"},
+ SPAN({"class": "arrayLeftBracket", role: "presentation"}, "["),
+ FOR("item", "$object|shortArrayIterator",
+ TAG("$item.tag", {object: "$item.object"}),
+ SPAN({"class": "arrayComma", role: "presentation"}, "$item.delim")
+ ),
+ SPAN({"class": "arrayRightBracket"}, "]"),
+ SPAN({"class": "arrayProperties", role: "group"})
+ ),
+
+ // http://code.google.com/p/fbug/issues/detail?id=874
+ isArray: function(obj, win)
+ {
+ if (mightBeArray(obj, win))
+ {
+ if (isFinite(obj.length) && typeof obj.callee === "function") // arguments
+ return true;
+ else if (Arr.isArray(obj))
+ return true;
+ }
+ return false;
}
});
+FirebugReps.ArrayishObject = domplate(FirebugReps.ArrBase,
+{
+ tag:
+ OBJECTBOX({_repObject: "$object",
+ $hasTwisty: "$object|hasSpecialProperties",
+ onclick: "$onToggleProperties"},
+ SPAN({"class": "objectTitle"}, "$object|getTitle "),
+ SPAN({"class": "arrayLeftBracket", role: "presentation"}, "["),
+ FOR("item", "$object|longArrayIterator",
+ TAG("$item.tag", {object: "$item.object"}),
+ SPAN({"class": "arrayComma", role: "presentation"}, "$item.delim")
+ ),
+ SPAN({"class": "arrayRightBracket", role: "presentation"}, "]"),
+ SPAN({"class": "arrayProperties", role: "group"})
+ ),
+
+ shortTag:
+ OBJECTBOX({_repObject: "$object",
+ $hasTwisty: "$object|hasSpecialProperties",
+ onclick: "$onToggleProperties"},
+ SPAN({"class": "objectTitle"}, "$object|getTitle "),
+ SPAN({"class": "arrayLeftBracket", role: "presentation"}, "["),
+ FOR("item", "$object|shortArrayIterator",
+ TAG("$item.tag", {object: "$item.object"}),
+ SPAN({"class": "arrayComma", role: "presentation"}, "$item.delim")
+ ),
+ SPAN({"class": "arrayRightBracket"}, "]"),
+ SPAN({"class": "arrayProperties", role: "group"})
+ ),
+
+ getTitle: function(object, context)
+ {
+ const re =/\[object ([^\]]*)/;
+ var label = Str.safeToString(object);
+ var m = re.exec(label);
+ return m[1] || label;
+ },
+
+ isArray: function(obj, win)
+ {
+ if (mightBeArray(obj, win))
+ {
+ if (isFinite(obj.length) && typeof obj.splice === "function" && obj.length)
+ return true;
+ var view = Wrapper.getContentView(win || window);
+ if (obj instanceof view.HTMLCollection)
+ return true;
+ else if (obj instanceof view.NodeList)
+ return true;
+ }
+ return false;
+ },
+});
+
+
// ********************************************************************************************* //
FirebugReps.Property = domplate(Firebug.Rep,
@@ -3147,6 +3234,7 @@ Firebug.registerRep(
FirebugReps.Except,
FirebugReps.XML,
FirebugReps.Arr,
+ FirebugReps.ArrayishObject,
FirebugReps.XPathResult,
FirebugReps.Storage,
FirebugReps.Attr,
Something went wrong with that request. Please try again.