mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Fix for bug 502730 (ASSERTION: Wrong scope, this is really bad!: 'JS_GetGlobalForObject(cx, obj) == newScope').
--HG-- extra : rebase_source : dbd409d54e6ecad801953d4cf76a57f95c419f94
This commit is contained in:
parent
d05aee9903
commit
8e41a252d2
@ -3550,23 +3550,25 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject)
|
||||
mScopeObject = do_GetWeakReference(aScriptGlobalObject);
|
||||
|
||||
#ifdef DEBUG
|
||||
// We really shouldn't have a wrapper here but if we do we need to make sure
|
||||
// it has the correct parent.
|
||||
JSObject *obj = GetWrapper();
|
||||
if (obj) {
|
||||
JSObject *newScope = aScriptGlobalObject->GetGlobalJSObject();
|
||||
nsIScriptContext *scx = aScriptGlobalObject->GetContext();
|
||||
JSContext *cx = scx ? (JSContext *)scx->GetNativeContext() : nsnull;
|
||||
if (!cx) {
|
||||
nsContentUtils::ThreadJSContextStack()->Peek(&cx);
|
||||
if (!mWillReparent) {
|
||||
// We really shouldn't have a wrapper here but if we do we need to make sure
|
||||
// it has the correct parent.
|
||||
JSObject *obj = GetWrapper();
|
||||
if (obj) {
|
||||
JSObject *newScope = aScriptGlobalObject->GetGlobalJSObject();
|
||||
nsIScriptContext *scx = aScriptGlobalObject->GetContext();
|
||||
JSContext *cx = scx ? (JSContext *)scx->GetNativeContext() : nsnull;
|
||||
if (!cx) {
|
||||
nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(&cx);
|
||||
NS_ASSERTION(cx, "Uhoh, no context, this is bad!");
|
||||
nsContentUtils::ThreadJSContextStack()->Peek(&cx);
|
||||
if (!cx) {
|
||||
nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(&cx);
|
||||
NS_ASSERTION(cx, "Uhoh, no context, this is bad!");
|
||||
}
|
||||
}
|
||||
if (cx) {
|
||||
NS_ASSERTION(JS_GetGlobalForObject(cx, obj) == newScope,
|
||||
"Wrong scope, this is really bad!");
|
||||
}
|
||||
}
|
||||
if (cx) {
|
||||
NS_ASSERTION(JS_GetGlobalForObject(cx, obj) == newScope,
|
||||
"Wrong scope, this is really bad!");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1273,6 +1273,11 @@ private:
|
||||
#ifdef MOZ_SMIL
|
||||
nsAutoPtr<nsSMILAnimationController> mAnimationController;
|
||||
#endif // MOZ_SMIL
|
||||
|
||||
#ifdef DEBUG
|
||||
protected:
|
||||
PRBool mWillReparent;
|
||||
#endif
|
||||
};
|
||||
|
||||
#define NS_DOCUMENT_INTERFACE_TABLE_BEGIN(_class) \
|
||||
|
@ -1924,9 +1924,18 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
|
||||
// Remember the old scope in case the call to SetNewDocument changes it.
|
||||
nsCOMPtr<nsIScriptGlobalObject> oldScope(do_QueryReferent(mScopeObject));
|
||||
|
||||
#ifdef DEBUG
|
||||
PRBool willReparent = mWillReparent;
|
||||
mWillReparent = PR_TRUE;
|
||||
#endif
|
||||
|
||||
rv = window->SetNewDocument(this, nsnull, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
#ifdef DEBUG
|
||||
mWillReparent = willReparent;
|
||||
#endif
|
||||
|
||||
// Now make sure we're not flagged as the initial document anymore, now
|
||||
// that we've had stuff done to us. From now on, if anyone tries to
|
||||
// document.open() us, they get a new inner window.
|
||||
|
Loading…
Reference in New Issue
Block a user