Closed Bug 82220 Opened 23 years ago Closed 23 years ago

enumeration of Components.interfaces includes non-scriptable interfaces

Categories

(Core :: XPConnect, defect)

defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: jband_mozilla, Assigned: jband_mozilla)

Details

(Keywords: regression)

Attachments

(2 files)

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.
Attached patch proposed fix (deleted) — Splinter Review
Attached patch diff -uw for easier review (deleted) — Splinter Review
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
Looks good to me, sr=jst
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.
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 }
r=dbradley looks fine, ran fine.
fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Marking Verified -
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: