Fix for bug 298064 (nsContentUtils::GetDocumentFromCaller() is broken.). r=jst, sr=brendan.
git-svn-id: svn://10.0.0.236/trunk@179553 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -241,9 +241,9 @@ public:
|
||||
|
||||
/**
|
||||
* Get the document through the JS context that's currently on the stack.
|
||||
* If there's no JS context currently on the stack aDocument will be null.
|
||||
* If there's no JS context currently on the stack it will return null.
|
||||
*
|
||||
* @param aDocument The document or null if no JS context
|
||||
* @return The document or null if no JS context
|
||||
*/
|
||||
static nsIDOMDocument *GetDocumentFromCaller();
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
@@ -113,6 +113,7 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
|
||||
#include "nsILineBreaker.h"
|
||||
#include "nsIWordBreaker.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "jsdbgapi.h"
|
||||
|
||||
// for ReportToConsole
|
||||
#include "nsIStringBundle.h"
|
||||
@@ -931,19 +932,22 @@ nsContentUtils::GetDocumentFromCaller()
|
||||
JSContext *cx = nsnull;
|
||||
sThreadJSContextStack->Peek(&cx);
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> doc;
|
||||
nsIDOMDocument *doc = nsnull;
|
||||
|
||||
if (cx) {
|
||||
nsIScriptGlobalObject *sgo = nsJSUtils::GetDynamicScriptGlobal(cx);
|
||||
JSObject *callee = nsnull;
|
||||
JSStackFrame *fp = nsnull;
|
||||
while (!callee && (fp = ::JS_FrameIterator(cx, &fp))) {
|
||||
callee = ::JS_GetFrameCalleeObject(cx, fp);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> win(do_QueryInterface(sgo));
|
||||
nsCOMPtr<nsPIDOMWindow> win =
|
||||
do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(cx, callee));
|
||||
if (win) {
|
||||
win->GetDocument(getter_AddRefs(doc));
|
||||
doc = win->GetExtantDocument();
|
||||
}
|
||||
}
|
||||
|
||||
// This will return a pointer to something we're about to release,
|
||||
// but that's ok here.
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
@@ -1850,15 +1850,14 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
|
||||
// Grab a reference to the calling documents security info (if any)
|
||||
// and principal as it may be lost in the call to Reset().
|
||||
nsCOMPtr<nsISupports> securityInfo;
|
||||
nsCOMPtr<nsIPrincipal> callerPrincipal;
|
||||
|
||||
if (callerDoc) {
|
||||
securityInfo = callerDoc->GetSecurityInfo();
|
||||
|
||||
nsContentUtils::GetSecurityManager()->
|
||||
GetSubjectPrincipal(getter_AddRefs(callerPrincipal));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrincipal> callerPrincipal;
|
||||
nsContentUtils::GetSecurityManager()->
|
||||
GetSubjectPrincipal(getter_AddRefs(callerPrincipal));
|
||||
|
||||
// The URI for the document after this call. Get it from the calling
|
||||
// principal (if available), or set it to "about:blank" if no
|
||||
// principal is reachable.
|
||||
|
||||
Reference in New Issue
Block a user