Fixing bug 307632. Make the DOM code wrap objects in the current inner window when requested to wrap an object in an outer window. This ensures that window.selection === selection, and window.selection.__proto__ === Selection.prototype. r=mrbkap@gmail.com, sr=brendan@mozilla.org

This commit is contained in:
jst%mozilla.jstenback.com 2005-09-13 00:26:53 +00:00
Родитель 2f25b96d19
Коммит 292c4a6571
2 изменённых файлов: 22 добавлений и 2 удалений

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

@ -373,6 +373,7 @@ enum nsDOMClassInfoID {
nsIXPCScriptable::DONT_REFLECT_INTERFACE_NAMES | \
nsIXPCScriptable::WANT_NEWRESOLVE | \
nsIXPCScriptable::WANT_CHECKACCESS | \
nsIXPCScriptable::WANT_PRECREATE | \
nsIXPCScriptable::WANT_POSTCREATE)
#define DOM_DEFAULT_SCRIPTABLE_FLAGS \

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

@ -3077,9 +3077,28 @@ NS_IMETHODIMP
nsDOMClassInfo::PreCreate(nsISupports *nativeObj, JSContext *cx,
JSObject *globalObj, JSObject **parentObj)
{
NS_ERROR("nsDOMClassInfo::PreCreate Don't call me!");
*parentObj = globalObj;
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
nsresult rv =
sXPConnect->GetWrappedNativeOfJSObject(cx, globalObj,
getter_AddRefs(wrapper));
if (NS_FAILED(rv)) {
return NS_OK;
}
nsCOMPtr<nsPIDOMWindow> piwin = do_QueryWrappedNative(wrapper);
if (!piwin) {
return NS_OK;
}
if (piwin->IsOuterWindow()) {
*parentObj = ((nsGlobalWindow *)piwin.get())->
GetCurrentInnerWindowInternal()->GetGlobalJSObject();
}
return NS_OK;
}
NS_IMETHODIMP