bug 580128 - Make the Window constructor be defined on new windows. r=peterv

This commit is contained in:
Blake Kaplan 2010-09-17 14:54:40 -07:00
parent f981834205
commit 8a04a08f4f
2 changed files with 19 additions and 0 deletions

View File

@ -2571,6 +2571,19 @@ nsJSContext::CreateOuterObject(nsIScriptGlobalObject *aGlobalObject,
JS_SetOptions(mContext, JS_GetOptions(mContext) | JSOPTION_XML);
}
nsIXPConnect *xpc = nsContentUtils::XPConnect();
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
nsresult rv = xpc->WrapNative(mContext, aCurrentInner->GetGlobalJSObject(),
aCurrentInner, NS_GET_IID(nsISupports),
getter_AddRefs(holder));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIXPConnectWrappedNative> wrapper(do_QueryInterface(holder));
NS_ABORT_IF_FALSE(wrapper, "bad wrapper");
wrapper->RefreshPrototype();
JSObject *outer =
NS_NewOuterWindowProxy(mContext, aCurrentInner->GetGlobalJSObject());
if (!outer) {

View File

@ -1124,6 +1124,12 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext,
if(!scope)
return UnexpectedFailure(NS_ERROR_FAILURE);
// Note: This call cooperates with a call to wrapper->RefreshPrototype()
// in nsJSEnvironment::CreateOuterObject in order to ensure that the
// prototype defines its constructor on the right global object.
if(wrapper->GetProto()->GetScriptableInfo())
scope->RemoveWrappedNativeProtos();
NS_ASSERTION(scope->GetGlobalJSObject() == tempGlobal, "stealing scope!");
scope->SetGlobal(ccx, globalJSObj);