Closed
Bug 82220
Opened 23 years ago
Closed 23 years ago
enumeration of Components.interfaces includes non-scriptable interfaces
Categories
(Core :: XPConnect, defect)
Core
XPConnect
Tracking
()
VERIFIED
FIXED
People
(Reporter: jband_mozilla, Assigned: jband_mozilla)
Details
(Keywords: regression)
Attachments
(2 files)
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
patch
|
Details | Diff | Splinter Review |
This is an xpcdom landing regression.
The enumeration of Components.interfaces is only supposed to include interfaces
marked as scriptable. But it does not.
Any attempt to actually access one of those non scriptable members will yield
undefined - since Components.interfaces does not actually expose the
non-scriptable interface objects in its resolver. So, those objects should not
be included in the list of property ids found when enumerating.
A simple test of the problem (which can be run in xpcshell) is:
var count = 0;
var nullCount = 0;
for(n in Components.interfaces) {
var cur = Components.interfaces[n];
count++;
if(!cur)
nullCount++;
dump("Components.interfaces["+n+"] = "+cur+"\n");
}
dump("count = "+count+" nullCount = "+nullCount+"\n");
This should not print lines like:
Components.interfaces[nsIXPConnect] = undefined
And the 'nullCount' *should* be 0.
I'll attach a patch to fix this bug.
Assignee | ||
Comment 1•23 years ago
|
||
Assignee | ||
Comment 2•23 years ago
|
||
Assignee | ||
Comment 3•23 years ago
|
||
The fix is to change the 'next' handler into a while loop that continues on
finding a non-scriptable item, returns on finding a 'good' item, and breaks on
finding the end of the enumeration.
I added a diff -wu version of the patch to make this easier to review by eye.
Status: NEW → ASSIGNED
Keywords: regression
Comment 4•23 years ago
|
||
Looks good to me, sr=jst
Comment 5•23 years ago
|
||
A bit hard to read, possibly because of tabbing issues. I'm guessing that the
closing curly brace that preceeds the break statement corresponds to the if
clause that checks that we haven't reached the end of the enumerator. If so,
r=vidur.
Assignee | ||
Comment 6•23 years ago
|
||
Yes Vidur. It is all just the below. Thanks.
case JSENUMERATE_NEXT:
{
nsCOMPtr<nsISupports> isup;
e = (nsIEnumerator*) JSVAL_TO_PRIVATE(*statep);
while(1)
{
if(NS_COMFALSE == e->IsDone() &&
NS_SUCCEEDED(e->CurrentItem(getter_AddRefs(isup))) && isup)
{
e->Next();
nsCOMPtr<nsIInterfaceInfo> iface(do_QueryInterface(isup));
if(iface)
{
JSString* idstr;
const char* name;
PRBool scriptable;
if(NS_SUCCEEDED(iface->IsScriptable(&scriptable)) &&
!scriptable)
{
continue;
}
if(NS_SUCCEEDED(iface->GetNameShared(&name)) && name &&
nsnull != (idstr = JS_NewStringCopyZ(cx, name)) &&
JS_ValueToId(cx, STRING_TO_JSVAL(idstr), idp))
{
return NS_OK;
}
}
}
// else...
break;
}
// FALL THROUGH
}
Comment 7•23 years ago
|
||
r=dbradley looks fine, ran fine.
Assignee | ||
Comment 8•23 years ago
|
||
fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•