Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(859)

Unified Diff: third_party/WebKit/Source/modules/peerconnection/RTCDataChannelTest.cpp

Issue 2888043003: Prevent access to null handler in RTCDataChannel. (Closed)
Patch Set: Add unit tests Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/peerconnection/RTCDataChannel.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/peerconnection/RTCDataChannelTest.cpp
diff --git a/third_party/WebKit/Source/modules/peerconnection/RTCDataChannelTest.cpp b/third_party/WebKit/Source/modules/peerconnection/RTCDataChannelTest.cpp
index bdeadde914ad61cd7a9f23a38a2562035dd2190e..fdbd3971b1bd7338540e6e3e1f0a50ec353b6609 100644
--- a/third_party/WebKit/Source/modules/peerconnection/RTCDataChannelTest.cpp
+++ b/third_party/WebKit/Source/modules/peerconnection/RTCDataChannelTest.cpp
@@ -4,6 +4,7 @@
#include "modules/peerconnection/RTCDataChannel.h"
+#include <string>
#include "bindings/core/v8/ExceptionState.h"
#include "core/dom/DOMArrayBuffer.h"
#include "core/dom/DOMException.h"
@@ -146,4 +147,26 @@ TEST(RTCDataChannelTest, BufferedAmountLow) {
std::string(channel->scheduled_events_.back()->type().Utf8().data()));
}
+TEST(RTCDataChannelTest, SendAfterContextDestroyed) {
+ MockHandler* handler = new MockHandler();
+ RTCDataChannel* channel = RTCDataChannel::Create(0, WTF::WrapUnique(handler));
+ handler->ChangeState(WebRTCDataChannelHandlerClient::kReadyStateOpen);
+ channel->ContextDestroyed(nullptr);
+
+ String message(std::string(100, 'A').c_str());
+ DummyExceptionStateForTesting exception_state;
+ channel->send(message, exception_state);
+
+ EXPECT_TRUE(exception_state.HadException());
+}
+
+TEST(RTCDataChannelTest, CloseAfterContextDestroyed) {
+ MockHandler* handler = new MockHandler();
+ RTCDataChannel* channel = RTCDataChannel::Create(0, WTF::WrapUnique(handler));
+ handler->ChangeState(WebRTCDataChannelHandlerClient::kReadyStateOpen);
+ channel->ContextDestroyed(nullptr);
+ channel->close();
+ EXPECT_EQ(String::FromUTF8("closed"), channel->readyState());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/peerconnection/RTCDataChannel.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698