Bug 1050340 - Do a CheckedUnwrap in xpc::IsReflector. r=gabor

This matches the behavior of UnwrapReflectorToISupports, and makes all of the
structured clone callbacks scattered throughout Gecko compatible with wrappers
that have not already had CheckedUnwrap invoked on them.
This commit is contained in:
Bobby Holley 2014-08-18 14:18:39 -07:00
parent 8995a85ada
commit d9deab8699

View File

@ -26,6 +26,9 @@ namespace xpc {
bool
IsReflector(JSObject *obj)
{
obj = CheckedUnwrap(obj, /* stopAtOuter = */ false);
if (!obj)
return false;
return IS_WN_REFLECTOR(obj) || dom::IsDOMObject(obj);
}
@ -117,15 +120,11 @@ bool IsBlobOrFileList(JSObject *obj)
static bool
StackScopedCloneWrite(JSContext *cx, JSStructuredCloneWriter *writer,
Handle<JSObject *> objArg, void *closure)
Handle<JSObject *> obj, void *closure)
{
MOZ_ASSERT(closure, "Null pointer!");
StackScopedCloneData *cloneData = static_cast<StackScopedCloneData *>(closure);
// The SpiderMonkey structured clone machinery does a CheckedUnwrap, but
// doesn't strip off outer windows. Do that to avoid confusing the reflector
// detection.
RootedObject obj(cx, JS_ObjectToInnerObject(cx, objArg));
if ((cloneData->mOptions->wrapReflectors && IsReflector(obj)) ||
IsBlobOrFileList(obj))
{