This is needed for bug 851542 for now until we have IDL arrays. But it might come up for something else too. The basic problem is that we treat nsIVariant as an external interface, call dom::WrapObject<nsIVariant>, which calls dom::XPCOMObjectToJsval, which calls dom::NativeInterface2JSObjectAndThrowIfFailed, which calls XPCConvert::NativeInterface2JSObject. And that fails, in a web page, because variants have no classinfo. The point, of course, is we don't want to create a wrapper for a variant at all. Note that XPCConvert::NativeData2JS special-cases nsIVariant in the nsXPTType::T_INTERFACE case by calling XPCVariant::VariantDataToJS. We need to do something similar.
Created attachment 730682 [details] [diff] [review] Make returning an nsIVariant from a WebIDL interface work.
This makes the patch in bug 851542 work for me.
Comment on attachment 730682 [details] [diff] [review] Make returning an nsIVariant from a WebIDL interface work. Exception handling is a bit ugly, but should at least be safe. I don't think we handle exceptions too consistently with VariantDataToJS.
Hmm, looks like I'm getting crash because iid is null.
debug only assertion crash.
MOZ_ASSERT(!iid || iid->Equals(NS_GET_IID(nsIVariant))); for now.
Does putting back the notflattened=True help?