From 648f65813348e3b2ec1b00a47545ea77368c4da7 Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Tue, 12 Jan 2010 14:08:44 +0100 Subject: [PATCH] Fix for bug 540443 (Change one argument of nsContentUtils::CheckSameOrigin from nsIDOMNode to nsINode). r=bz. --- content/base/public/nsContentUtils.h | 2 +- content/base/src/nsContentUtils.cpp | 7 +++---- content/base/src/nsTreeWalker.cpp | 3 +-- content/xul/document/src/nsXULCommandDispatcher.cpp | 4 +--- content/xul/document/src/nsXULDocument.cpp | 6 ++---- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index a25f6f12b46..4d0a4ec10ce 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -393,7 +393,7 @@ public: * Never call this function with the first node provided by script, it * must always be known to be a 'real' node! */ - static nsresult CheckSameOrigin(nsIDOMNode* aTrustedNode, + static nsresult CheckSameOrigin(nsINode* aTrustedNode, nsIDOMNode* aUnTrustedNode); // Check if the (JS) caller can access aNode. diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index a1036606da0..1e50749526d 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -980,7 +980,7 @@ nsContentUtils::IsCallerTrustedForCapability(const char* aCapability) */ // static nsresult -nsContentUtils::CheckSameOrigin(nsIDOMNode *aTrustedNode, +nsContentUtils::CheckSameOrigin(nsINode *aTrustedNode, nsIDOMNode *aUnTrustedNode) { NS_PRECONDITION(aTrustedNode, "There must be a trusted node"); @@ -996,13 +996,12 @@ nsContentUtils::CheckSameOrigin(nsIDOMNode *aTrustedNode, /* * Get hold of each node's principal */ - nsCOMPtr trustedNode = do_QueryInterface(aTrustedNode); nsCOMPtr unTrustedNode = do_QueryInterface(aUnTrustedNode); // Make sure these are both real nodes - NS_ENSURE_TRUE(trustedNode && unTrustedNode, NS_ERROR_UNEXPECTED); + NS_ENSURE_TRUE(aTrustedNode && unTrustedNode, NS_ERROR_UNEXPECTED); - nsIPrincipal* trustedPrincipal = trustedNode->NodePrincipal(); + nsIPrincipal* trustedPrincipal = aTrustedNode->NodePrincipal(); nsIPrincipal* unTrustedPrincipal = unTrustedNode->NodePrincipal(); if (trustedPrincipal == unTrustedPrincipal) { diff --git a/content/base/src/nsTreeWalker.cpp b/content/base/src/nsTreeWalker.cpp index b757d48f5d3..6f77f259cec 100644 --- a/content/base/src/nsTreeWalker.cpp +++ b/content/base/src/nsTreeWalker.cpp @@ -147,8 +147,7 @@ NS_IMETHODIMP nsTreeWalker::SetCurrentNode(nsIDOMNode * aCurrentNode) NS_ENSURE_TRUE(aCurrentNode, NS_ERROR_DOM_NOT_SUPPORTED_ERR); // This QI is dumb, but this shouldn't be a critical operation - nsCOMPtr domRoot = do_QueryInterface(mRoot); - nsresult rv = nsContentUtils::CheckSameOrigin(domRoot, aCurrentNode); + nsresult rv = nsContentUtils::CheckSameOrigin(mRoot, aCurrentNode); NS_ENSURE_SUCCESS(rv, rv); mCurrentNode = do_QueryInterface(aCurrentNode); diff --git a/content/xul/document/src/nsXULCommandDispatcher.cpp b/content/xul/document/src/nsXULCommandDispatcher.cpp index 8a2fdae8270..26959dcc47c 100644 --- a/content/xul/document/src/nsXULCommandDispatcher.cpp +++ b/content/xul/document/src/nsXULCommandDispatcher.cpp @@ -287,9 +287,7 @@ nsXULCommandDispatcher::AddCommandUpdater(nsIDOMElement* aElement, if (! aElement) return NS_ERROR_NULL_POINTER; - nsCOMPtr doc(do_QueryInterface(mDocument)); - - nsresult rv = nsContentUtils::CheckSameOrigin(doc, aElement); + nsresult rv = nsContentUtils::CheckSameOrigin(mDocument, aElement); if (NS_FAILED(rv)) { return rv; diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index d811f509688..1d1269743a5 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -782,15 +782,13 @@ nsXULDocument::AddBroadcastListenerFor(nsIDOMElement* aBroadcaster, NS_ENSURE_ARG(aBroadcaster && aListener); nsresult rv = - nsContentUtils::CheckSameOrigin(static_cast(this), - aBroadcaster); + nsContentUtils::CheckSameOrigin(this, aBroadcaster); if (NS_FAILED(rv)) { return rv; } - rv = nsContentUtils::CheckSameOrigin(static_cast(this), - aListener); + rv = nsContentUtils::CheckSameOrigin(this, aListener); if (NS_FAILED(rv)) { return rv;