Bug 804983 - WebTelephony API: DOM does not accurately handle an outgoing call. r=bent
authorHsin-Yi Tsai <htsai@mozilla.com>
Thu, 25 Oct 2012 18:31:37 +0800
changeset 112007 7781dba5ed5e
parent 112006 b84d576e597a
child 112008 5bf3abe91210
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersbent
bugs804983
milestone19.0a1
Bug 804983 - WebTelephony API: DOM does not accurately handle an outgoing call. r=bent
dom/telephony/Telephony.cpp
--- a/dom/telephony/Telephony.cpp
+++ b/dom/telephony/Telephony.cpp
@@ -397,33 +397,37 @@ Telephony::CallStateChanged(uint32_t aCa
     }
 
     // Change state.
     modifiedCall->ChangeState(aCallState);
 
     return NS_OK;
   }
 
-  // Didn't know anything about this call before now, must be incoming.
-  NS_ASSERTION(aCallState == nsIRadioInterfaceLayer::CALL_STATE_INCOMING,
+  // Didn't know anything about this call before now, could be 'incoming' or
+  // 'dialing' that was placed by others.
+  NS_ASSERTION(aCallState == nsIRadioInterfaceLayer::CALL_STATE_INCOMING ||
+               aCallState == nsIRadioInterfaceLayer::CALL_STATE_DIALING,
                "Serious logic problem here!");
 
   nsRefPtr<TelephonyCall> call =
     TelephonyCall::Create(this, aNumber, aCallState, aCallIndex);
   NS_ASSERTION(call, "This should never fail!");
 
   NS_ASSERTION(mCalls.Contains(call), "Should have auto-added new call!");
 
-  // Dispatch incoming event.
-  nsRefPtr<CallEvent> event = CallEvent::Create(call);
-  NS_ASSERTION(event, "This should never fail!");
+  if (aCallState == nsIRadioInterfaceLayer::CALL_STATE_INCOMING) {
+    // Dispatch incoming event.
+    nsRefPtr<CallEvent> event = CallEvent::Create(call);
+    NS_ASSERTION(event, "This should never fail!");
 
-  nsresult rv =
-    event->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("incoming"));
-  NS_ENSURE_SUCCESS(rv, rv);
+    nsresult rv =
+      event->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("incoming"));
+    NS_ENSURE_SUCCESS(rv, rv);
+  }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 Telephony::EnumerateCallState(uint32_t aCallIndex, uint16_t aCallState,
                               const nsAString& aNumber, bool aIsActive,
                               bool* aContinue)