Calling removeTrack on different RTCPeerConnection should throw InvalidAccessError
[WebKit-https.git] / Source / WebCore / Modules / mediastream / RTCPeerConnection.cpp
index 1386cac..62840e6 100644 (file)
@@ -131,7 +131,10 @@ ExceptionOr<void> RTCPeerConnection::removeTrack(RTCRtpSender& sender)
     INFO_LOG(LOGIDENTIFIER);
 
     if (isClosed())
-        return Exception { InvalidStateError };
+        return Exception { InvalidStateError, "RTCPeerConnection is closed"_s };
+
+    if (!sender.isCreatedBy(*m_backend))
+        return Exception { InvalidAccessError, "RTCPeerConnection did not create the given sender"_s };
 
     bool shouldAbort = true;
     RTCRtpTransceiver* senderTransceiver = nullptr;