diff --git a/js/src/xpconnect/src/XPCNativeWrapper.cpp b/js/src/xpconnect/src/XPCNativeWrapper.cpp index 8f1cbe238dd..f42cd80aa4c 100644 --- a/js/src/xpconnect/src/XPCNativeWrapper.cpp +++ b/js/src/xpconnect/src/XPCNativeWrapper.cpp @@ -1180,7 +1180,17 @@ UnwrapNW(JSContext *cx, uintN argc, jsval *vp) return JS_TRUE; } - return GetwrappedJSObject(cx, JSVAL_TO_OBJECT(v), vp); + XPCWrappedNative *wn; + if (!XPCNativeWrapper::GetWrappedNative(cx, JSVAL_TO_OBJECT(v), &wn)) { + return JS_FALSE; + } + + if (!wn) { + JS_SET_RVAL(cx, vp, JSVAL_NULL); + return JS_TRUE; + } + + return GetwrappedJSObject(cx, wn->GetFlatJSObject(), vp); } static JSFunctionSpec static_functions[] = { diff --git a/js/src/xpconnect/tests/chrome/test_bug533596.xul b/js/src/xpconnect/tests/chrome/test_bug533596.xul index 0cfe55221d7..0c3e1c8786c 100644 --- a/js/src/xpconnect/tests/chrome/test_bug533596.xul +++ b/js/src/xpconnect/tests/chrome/test_bug533596.xul @@ -3,9 +3,9 @@ - @@ -34,6 +34,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=500931 var win = $('ifr').contentWindow; var utils = window.getInterface(Components.interfaces.nsIDOMWindowUtils); is(utils.getClassName(win), "XPCNativeWrapper", "win is an XPCNW"); + ok("x" in XPCNativeWrapper.unwrap(win), "actually unwrapped"); is(utils.getClassName(XPCNativeWrapper.unwrap(win)), "XPCSafeJSObjectWrapper", "unwrap on an NW returns the same object"); is(utils.getClassName(XPCNativeWrapper.unwrap(new XPCNativeWrapper(win))), "XPCSafeJSObjectWrapper", diff --git a/js/src/xpconnect/tests/mochitest/bug500931_helper.html b/js/src/xpconnect/tests/mochitest/bug500931_helper.html index df5a02f4daa..da268d99d89 100644 --- a/js/src/xpconnect/tests/mochitest/bug500931_helper.html +++ b/js/src/xpconnect/tests/mochitest/bug500931_helper.html @@ -1,6 +1,7 @@ Inner frame for bug 500931 mochitest +