nsCOMPtr<nsIScriptGlobalObject> globalObject; mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject)); nsCOMPtr<nsIDOMWindowInternal> window = do_QueryInterface(globalObject);
nsCOMPtr<nsIDOMWindowInternal> window = do_QueryInterface(mDocument->GetScriptGlobalObject());
nsHTMLFormElement::NotifySubmitObservers(nsIURI* aActionURL,                                         PRBool* aCancelSubmit){  // If this is the first form, bring alive the first form submit  // category observers  if (!gFirstFormSubmitted) {    gFirstFormSubmitted = PR_TRUE;    NS_CreateServicesFromCategory(NS_FIRST_FORMSUBMIT_CATEGORY,                                  nsnull,                                  NS_FIRST_FORMSUBMIT_CATEGORY);  }  // Notify observers that the form is being submitted.  nsresult rv = NS_OK;  nsCOMPtr<nsIObserverService> service =    do_GetService("@mozilla.org/observer-service;1", &rv);  NS_ENSURE_SUCCESS(rv, rv);  nsCOMPtr<nsISimpleEnumerator> theEnum;  rv = service->EnumerateObservers(NS_FORMSUBMIT_SUBJECT,                                   getter_AddRefs(theEnum));  NS_ENSURE_SUCCESS(rv, rv);  if (theEnum) {    nsCOMPtr<nsISupports> inst;    *aCancelSubmit = PR_FALSE;    nsCOMPtr<nsIScriptGlobalObject> globalObject;    mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));    nsCOMPtr<nsIDOMWindowInternal> window = do_QueryInterface(globalObject);    PRBool loop = PR_TRUE;    while (NS_SUCCEEDED(theEnum->HasMoreElements(&loop)) && loop) {      theEnum->GetNext(getter_AddRefs(inst));      nsCOMPtr<nsIFormSubmitObserver> formSubmitObserver(                      do_QueryInterface(inst));      if (formSubmitObserver) {        rv = formSubmitObserver->Notify(this,                                        window,                                        aActionURL,                                        aCancelSubmit);        NS_ENSURE_SUCCESS(rv, rv);      }      if (*aCancelSubmit) {        return NS_OK;      }    }  }  return rv;}