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

Unified Diff: ppapi/tests/test_websocket.cc

Issue 510663002: PepperWebSocketHost should not call blink::WebSocket APIs after closed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 | « ppapi/tests/test_websocket.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/tests/test_websocket.cc
diff --git a/ppapi/tests/test_websocket.cc b/ppapi/tests/test_websocket.cc
index b2702bf3d8fb87d856390db13f1497e0b09fc935..e0a54aa6aa9c9821d7dc3739e1948a675a3cceb0 100644
--- a/ppapi/tests/test_websocket.cc
+++ b/ppapi/tests/test_websocket.cc
@@ -224,6 +224,7 @@ void TestWebSocket::RunTests(const std::string& filter) {
RUN_TEST_WITH_REFERENCE_CHECK(AbortSendMessageCall, filter);
RUN_TEST_WITH_REFERENCE_CHECK(AbortCloseCall, filter);
RUN_TEST_WITH_REFERENCE_CHECK(AbortReceiveMessageCall, filter);
+ RUN_TEST_WITH_REFERENCE_CHECK(ClosedFromServerWhileSending, filter);
RUN_TEST_WITH_REFERENCE_CHECK(CcInterfaces, filter);
@@ -1158,6 +1159,33 @@ std::string TestWebSocket::TestAbortReceiveMessageCall() {
PASS();
}
+std::string TestWebSocket::TestClosedFromServerWhileSending() {
+ // Connect to test echo server.
+ const pp::Var protocols[] = { pp::Var() };
+ TestWebSocketAPI websocket(instance_);
+ int32_t result =
+ websocket.Connect(pp::Var(GetFullURL(kEchoServerURL)), protocols, 0U);
+ ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
+ websocket.WaitForConnected();
+
+ result = websocket.Send(pp::Var("hello"));
+ ASSERT_EQ(PP_OK, result);
+ result = websocket.Send(pp::Var("Goodbye"));
+ // We send many messages so that PepperWebSocketHost::SendText is called
+ // after PepperWebSocketHost::didClose is called.
+ // Note: We must not wait for CLOSED event here because
+ // WebSocketResource::SendMessage doesn't call PepperWebSocketHost::SendText
+ // when its internal state is CLOSING or CLOSED. We want to test if the
+ // pepper WebSocket works well when WebSocketResource is OPEN and
+ // PepperWebSocketHost is CLOSED.
+ for (size_t i = 0; i < 10000; ++i) {
Adam Rice 2014/08/27 05:58:57 Nit: this test could be flaky. However, I can't se
yhirano 2014/08/27 07:06:32 me neither.
+ result = websocket.Send(pp::Var(""));
+ ASSERT_EQ(PP_OK, result);
+ }
+
+ PASS();
+}
+
std::string TestWebSocket::TestCcInterfaces() {
// C++ bindings is simple straightforward, then just verifies interfaces work
// as a interface bridge fine.
« no previous file with comments | « ppapi/tests/test_websocket.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698