Fix for bug 540443 (Change one argument of nsContentUtils::CheckSameOrigin from nsIDOMNode to nsINode). r=bz.

This commit is contained in:
Peter Van der Beken 2010-01-12 14:08:44 +01:00
parent 6289e634b5
commit 648f658133
5 changed files with 8 additions and 14 deletions

View File

@ -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.

View File

@ -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<nsINode> trustedNode = do_QueryInterface(aTrustedNode);
nsCOMPtr<nsINode> 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) {

View File

@ -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<nsIDOMNode> 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);

View File

@ -287,9 +287,7 @@ nsXULCommandDispatcher::AddCommandUpdater(nsIDOMElement* aElement,
if (! aElement)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIDOMNode> doc(do_QueryInterface(mDocument));
nsresult rv = nsContentUtils::CheckSameOrigin(doc, aElement);
nsresult rv = nsContentUtils::CheckSameOrigin(mDocument, aElement);
if (NS_FAILED(rv)) {
return rv;

View File

@ -782,15 +782,13 @@ nsXULDocument::AddBroadcastListenerFor(nsIDOMElement* aBroadcaster,
NS_ENSURE_ARG(aBroadcaster && aListener);
nsresult rv =
nsContentUtils::CheckSameOrigin(static_cast<nsDocument *>(this),
aBroadcaster);
nsContentUtils::CheckSameOrigin(this, aBroadcaster);
if (NS_FAILED(rv)) {
return rv;
}
rv = nsContentUtils::CheckSameOrigin(static_cast<nsDocument *>(this),
aListener);
rv = nsContentUtils::CheckSameOrigin(this, aListener);
if (NS_FAILED(rv)) {
return rv;