diff --git a/js/xpconnect/src/ExportHelpers.cpp b/js/xpconnect/src/ExportHelpers.cpp index 520949da0e7d..5075796193d2 100644 --- a/js/xpconnect/src/ExportHelpers.cpp +++ b/js/xpconnect/src/ExportHelpers.cpp @@ -98,10 +98,15 @@ bool IsBlobOrFileList(JSObject *obj) static bool StackScopedCloneWrite(JSContext *cx, JSStructuredCloneWriter *writer, - Handle obj, void *closure) + Handle objArg, void *closure) { MOZ_ASSERT(closure, "Null pointer!"); StackScopedCloneData *cloneData = static_cast(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)) {