Fix for bug 604362 (Don't rewrap XPCWrappedNatives that don't have classinfo). r=mrbkap.

This commit is contained in:
Peter Van der Beken 2010-10-16 01:43:53 -07:00
Родитель c48781685e
Коммит d840d4875b
2 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,12 @@
function run_test() {
var Cc = Components.classes;
var Ci = Components.interfaces;
var sp = Cc["@mozilla.org/systemprincipal;1"].
createInstance(Ci.nsIPrincipal);
var s = Components.utils.Sandbox(sp);
s.a = [];
s.Cu = Components.utils;
s.C = Components;
s.do_check_neq = do_check_neq;
Components.utils.evalInSandbox("do_check_neq(Cu.import, undefined);", s);
}

Просмотреть файл

@ -108,6 +108,11 @@ WrapperFactory::PrepareForWrapping(JSContext *cx, JSObject *scope, JSObject *obj
XPCWrappedNative *wn = static_cast<XPCWrappedNative *>(xpc_GetJSPrivate(obj)); XPCWrappedNative *wn = static_cast<XPCWrappedNative *>(xpc_GetJSPrivate(obj));
// If the object doesn't have classinfo we want to return the same
// XPCWrappedNative so that we keep the same set of interfaces.
if (!wn->GetClassInfo())
return DoubleWrap(cx, obj, flags);
// We know that DOM objects only allow one object, we can return early. // We know that DOM objects only allow one object, we can return early.
if (wn->HasProto() && wn->GetProto()->ClassIsDOMObject()) if (wn->HasProto() && wn->GetProto()->ClassIsDOMObject())
return DoubleWrap(cx, obj, flags); return DoubleWrap(cx, obj, flags);