| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/thunk/thunk.h" | 5 #include "ppapi/thunk/thunk.h" |
| 6 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 6 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 7 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" | 7 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" |
| 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" | 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 10 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 10 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 info_->SetStringProperty(PP_URLREQUESTPROPERTY_URL, url); | 201 info_->SetStringProperty(PP_URLREQUESTPROPERTY_URL, url); |
| 202 ASSERT_TRUE(info_->RequiresUniversalAccess()); | 202 ASSERT_TRUE(info_->RequiresUniversalAccess()); |
| 203 } | 203 } |
| 204 | 204 |
| 205 TEST_F(URLRequestInfoTest, SetMethod) { | 205 TEST_F(URLRequestInfoTest, SetMethod) { |
| 206 // Test default method is "GET". | 206 // Test default method is "GET". |
| 207 ASSERT_TRUE(IsExpected(GetMethod(), "GET")); | 207 ASSERT_TRUE(IsExpected(GetMethod(), "GET")); |
| 208 ASSERT_TRUE(info_->SetStringProperty( | 208 ASSERT_TRUE(info_->SetStringProperty( |
| 209 PP_URLREQUESTPROPERTY_METHOD, "POST")); | 209 PP_URLREQUESTPROPERTY_METHOD, "POST")); |
| 210 ASSERT_TRUE(IsExpected(GetMethod(), "POST")); | 210 ASSERT_TRUE(IsExpected(GetMethod(), "POST")); |
| 211 |
| 212 // Test that method names are converted to upper case. |
| 213 ASSERT_TRUE(info_->SetStringProperty( |
| 214 PP_URLREQUESTPROPERTY_METHOD, "get")); |
| 215 ASSERT_TRUE(IsExpected(GetMethod(), "GET")); |
| 216 ASSERT_TRUE(info_->SetStringProperty( |
| 217 PP_URLREQUESTPROPERTY_METHOD, "post")); |
| 218 ASSERT_TRUE(IsExpected(GetMethod(), "POST")); |
| 219 } |
| 220 |
| 221 TEST_F(URLRequestInfoTest, SetInvalidMethod) { |
| 222 ASSERT_FALSE(info_->SetStringProperty( |
| 223 PP_URLREQUESTPROPERTY_METHOD, "CONNECT")); |
| 224 ASSERT_FALSE(info_->SetStringProperty( |
| 225 PP_URLREQUESTPROPERTY_METHOD, "connect")); |
| 226 ASSERT_FALSE(info_->SetStringProperty( |
| 227 PP_URLREQUESTPROPERTY_METHOD, "TRACE")); |
| 228 ASSERT_FALSE(info_->SetStringProperty( |
| 229 PP_URLREQUESTPROPERTY_METHOD, "trace")); |
| 230 ASSERT_FALSE(info_->SetStringProperty( |
| 231 PP_URLREQUESTPROPERTY_METHOD, "TRACK")); |
| 232 ASSERT_FALSE(info_->SetStringProperty( |
| 233 PP_URLREQUESTPROPERTY_METHOD, "track")); |
| 234 |
| 235 ASSERT_FALSE(info_->SetStringProperty( |
| 236 PP_URLREQUESTPROPERTY_METHOD, "POST\x0d\x0ax-csrf-token:\x20test1234")); |
| 211 } | 237 } |
| 212 | 238 |
| 213 TEST_F(URLRequestInfoTest, SetValidHeaders) { | 239 TEST_F(URLRequestInfoTest, SetValidHeaders) { |
| 214 // Test default header field. | 240 // Test default header field. |
| 215 ASSERT_TRUE(IsExpected( | 241 ASSERT_TRUE(IsExpected( |
| 216 GetHeaderValue("foo"), "")); | 242 GetHeaderValue("foo"), "")); |
| 217 // Test that we can set a header field. | 243 // Test that we can set a header field. |
| 218 ASSERT_TRUE(info_->SetStringProperty( | 244 ASSERT_TRUE(info_->SetStringProperty( |
| 219 PP_URLREQUESTPROPERTY_HEADERS, "foo: bar")); | 245 PP_URLREQUESTPROPERTY_HEADERS, "foo: bar")); |
| 220 ASSERT_TRUE(IsExpected( | 246 ASSERT_TRUE(IsExpected( |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 ASSERT_FALSE(info_->SetStringProperty( | 298 ASSERT_FALSE(info_->SetStringProperty( |
| 273 PP_URLREQUESTPROPERTY_HEADERS, "foo: bar\ncookie: foo")); | 299 PP_URLREQUESTPROPERTY_HEADERS, "foo: bar\ncookie: foo")); |
| 274 ASSERT_TRUE(IsNullOrEmpty(GetHeaderValue("cookie"))); | 300 ASSERT_TRUE(IsNullOrEmpty(GetHeaderValue("cookie"))); |
| 275 } | 301 } |
| 276 | 302 |
| 277 // TODO(bbudge) Unit tests for AppendDataToBody, AppendFileToBody. | 303 // TODO(bbudge) Unit tests for AppendDataToBody, AppendFileToBody. |
| 278 | 304 |
| 279 } // namespace ppapi | 305 } // namespace ppapi |
| 280 } // namespace webkit | 306 } // namespace webkit |
| 281 | 307 |
| OLD | NEW |