Fixing part of bug 265790 (the part that's a regression from bug 265921). Make it possible to flag DOM events as trusted when created using DOM APIs from native code, and marking the DOMWindowClose event (and a few other fired from nsGlobalWindow) as trusted to make closing a tab from script close the tab only, and not the whole window. r+sr=bzbarsky@mit.edu, a=chofmann@mozilla.org

git-svn-id: svn://10.0.0.236/trunk@164533 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jst%mozilla.jstenback.com
2004-10-28 00:36:30 +00:00
parent b20b8ae8dc
commit 7bfc89b66d
2 changed files with 32 additions and 8 deletions

View File

@@ -4305,7 +4305,9 @@ nsEventStateManager::ForceViewUpdate(nsIView* aView)
}
NS_IMETHODIMP
nsEventStateManager::DispatchNewEvent(nsISupports* aTarget, nsIDOMEvent* aEvent, PRBool *aPreventDefault)
nsEventStateManager::DispatchNewEvent(nsISupports* aTarget,
nsIDOMEvent* aEvent,
PRBool *aPreventDefault)
{
nsresult ret = NS_OK;
@@ -4314,14 +4316,22 @@ nsEventStateManager::DispatchNewEvent(nsISupports* aTarget, nsIDOMEvent* aEvent,
nsCOMPtr<nsIDOMEventTarget> eventTarget(do_QueryInterface(aTarget));
privEvt->SetTarget(eventTarget);
//Check security state to determine if dispatcher is trusted
nsIScriptSecurityManager *securityManager =
nsContentUtils::GetSecurityManager();
//Check security state to determine if dispatcher is trusted
nsIScriptSecurityManager *securityManager =
nsContentUtils::GetSecurityManager();
PRBool enabled;
nsresult res =
securityManager->IsCapabilityEnabled("UniversalBrowserWrite", &enabled);
privEvt->SetTrusted(NS_SUCCEEDED(res) && enabled);
PRBool trusted;
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(privEvt));
nsevent->GetIsTrusted(&trusted);
if (!trusted) {
PRBool enabled;
nsresult res =
securityManager->IsCapabilityEnabled("UniversalBrowserWrite",
&enabled);
privEvt->SetTrusted(NS_SUCCEEDED(res) && enabled);
}
nsEvent * innerEvent;
privEvt->GetInternalNSEvent(&innerEvent);