summaryrefslogtreecommitdiffstats
path: root/ppapi/tests
diff options
context:
space:
mode:
authortoyoshim@chromium.org <toyoshim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-24 08:06:49 +0000
committertoyoshim@chromium.org <toyoshim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-24 08:06:49 +0000
commit2c32b260acba08f15bc13e8508a4a71a9b58f3ca (patch)
tree4416ee1987e70e2c320ac97e87d514251bb97da4 /ppapi/tests
parentd87e7e762b0b9ff778934d6c56bca4dec01572a7 (diff)
downloadchromium_src-2c32b260acba08f15bc13e8508a4a71a9b58f3ca.zip
chromium_src-2c32b260acba08f15bc13e8508a4a71a9b58f3ca.tar.gz
chromium_src-2c32b260acba08f15bc13e8508a4a71a9b58f3ca.tar.bz2
WebSocket Pepper API: PPB_WebSocket::close must accept undefined reason
IDL defines close behavior as it ignores the reason argument if the type of reason is PP_VARTYPE_UNDEFINED. BUG=124609 TEST=browser_tests --gtest_filter='*WebSocket*' Review URL: http://codereview.chromium.org/10167028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133646 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/tests')
-rw-r--r--ppapi/tests/test_websocket.cc68
1 files changed, 65 insertions, 3 deletions
diff --git a/ppapi/tests/test_websocket.cc b/ppapi/tests/test_websocket.cc
index 8e0c29b..eff333a 100644
--- a/ppapi/tests/test_websocket.cc
+++ b/ppapi/tests/test_websocket.cc
@@ -450,11 +450,12 @@ std::string TestWebSocket::TestValidConnect() {
std::string TestWebSocket::TestInvalidClose() {
PP_Var reason = CreateVarString("close for test");
TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback another_callback(instance_->pp_instance());
// Close before connect.
PP_Resource ws = websocket_interface_->Create(instance_->pp_instance());
- int32_t result = websocket_interface_->Close(
- ws, PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason,
+ int32_t result = websocket_interface_->Close(ws,
+ PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason,
callback.GetCallback().pp_completion_callback());
ASSERT_EQ(PP_ERROR_FAILED, result);
core_interface_->ReleaseResource(ws);
@@ -468,6 +469,39 @@ std::string TestWebSocket::TestInvalidClose() {
ASSERT_EQ(PP_ERROR_NOACCESS, result);
core_interface_->ReleaseResource(ws);
+ // Close with PP_VARTYPE_NULL.
+ ws = Connect(GetFullURL(kEchoServerURL), &result, "");
+ ASSERT_TRUE(ws);
+ ASSERT_EQ(PP_OK, result);
+ result = websocket_interface_->Close(ws,
+ PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, PP_MakeNull(),
+ callback.GetCallback().pp_completion_callback());
+ ASSERT_EQ(PP_ERROR_BADARGUMENT, result);
+ core_interface_->ReleaseResource(ws);
+
+ // Close with PP_VARTYPE_NULL and ongoing receive message.
+ ws = Connect(GetFullURL(kEchoServerURL), &result, "");
+ ASSERT_TRUE(ws);
+ ASSERT_EQ(PP_OK, result);
+ PP_Var receive_message_var;
+ result = websocket_interface_->ReceiveMessage(ws, &receive_message_var,
+ callback.GetCallback().pp_completion_callback());
+ ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
+ result = websocket_interface_->Close(ws,
+ PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, PP_MakeNull(),
+ another_callback.GetCallback().pp_completion_callback());
+ ASSERT_EQ(PP_ERROR_BADARGUMENT, result);
+ const char* send_message = "hi";
+ PP_Var send_message_var = CreateVarString(send_message);
+ result = websocket_interface_->SendMessage(ws, send_message_var);
+ ReleaseVar(send_message_var);
+ ASSERT_EQ(PP_OK, result);
+ result = callback.WaitForResult();
+ ASSERT_EQ(PP_OK, result);
+ ASSERT_TRUE(AreEqualWithString(receive_message_var, send_message));
+ ReleaseVar(receive_message_var);
+ core_interface_->ReleaseResource(ws);
+
ReleaseVar(reason);
PASS();
@@ -493,6 +527,18 @@ std::string TestWebSocket::TestValidClose() {
ASSERT_EQ(PP_OK, result);
core_interface_->ReleaseResource(ws);
+ // Close with PP_VARTYPE_UNDEFINED.
+ ws = Connect(GetFullURL(kEchoServerURL), &result, "");
+ ASSERT_TRUE(ws);
+ ASSERT_EQ(PP_OK, result);
+ result = websocket_interface_->Close(ws,
+ PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, PP_MakeUndefined(),
+ callback.GetCallback().pp_completion_callback());
+ ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
+ result = callback.WaitForResult();
+ ASSERT_EQ(PP_OK, result);
+ core_interface_->ReleaseResource(ws);
+
// Close in connecting.
// The ongoing connect failed with PP_ERROR_ABORTED, then the close is done
// successfully.
@@ -546,6 +592,23 @@ std::string TestWebSocket::TestValidClose() {
ASSERT_EQ(PP_OK, result);
core_interface_->ReleaseResource(ws);
+ // Close with PP_VARTYPE_UNDEFINED and ongoing receive message.
+ ws = Connect(GetFullURL(kEchoServerURL), &result, "");
+ ASSERT_TRUE(ws);
+ ASSERT_EQ(PP_OK, result);
+ result = websocket_interface_->ReceiveMessage(ws, &receive_message_var,
+ callback.GetCallback().pp_completion_callback());
+ ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
+ result = websocket_interface_->Close(ws,
+ PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, PP_MakeUndefined(),
+ another_callback.GetCallback().pp_completion_callback());
+ ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
+ result = callback.WaitForResult();
+ ASSERT_EQ(PP_ERROR_ABORTED, result);
+ result = another_callback.WaitForResult();
+ ASSERT_EQ(PP_OK, result);
+ core_interface_->ReleaseResource(ws);
+
ReleaseVar(reason);
ReleaseVar(url);
@@ -1311,4 +1374,3 @@ std::string TestWebSocket::TestUtilityBufferedAmount() {
PASS();
}
-