If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

Returning an nsIVariant from WebIDL doesn't work

RESOLVED FIXED in mozilla23

Status

()

Core
DOM
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: bz, Assigned: bz)

Tracking

unspecified
mozilla23
x86
Mac OS X
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite ?

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

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.
Assignee: nobody → bzbarsky
Attachment #730682 - Flags: feedback?(ted)
Whiteboard: [need review]
Attachment #730682 - Flags: feedback?(ted) → review?(peterv)
This makes the patch in bug 851542 work for me.

Updated

5 years ago
Blocks: 847594

Comment 3

5 years ago
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.
Attachment #730682 - Flags: review?(peterv) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/db4edcd5986e
Flags: in-testsuite?
Whiteboard: [need review]
Target Milestone: --- → mozilla23

Comment 5

5 years ago
Hmm, looks like I'm getting crash because iid is null.

Comment 6

5 years ago
debug only assertion crash.

Comment 7

5 years ago
MOZ_ASSERT(!iid || iid->Equals(NS_GET_IID(nsIVariant)));
for now.
Does putting back the notflattened=True help?
https://hg.mozilla.org/mozilla-central/rev/db4edcd5986e
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.