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

Side by Side Diff: webkit/plugins/ppapi/url_request_info_unittest.cc

Issue 7706021: Convert FileRefImpl and URLRequestInfo to shared_impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tests fixed Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/shared_impl/url_request_info_impl.h"
5 #include "ppapi/thunk/thunk.h" 6 #include "ppapi/thunk/thunk.h"
6 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 7 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
7 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h"
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
10 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 11 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
11 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" 12 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h"
12 #include "webkit/plugins/ppapi/ppapi_unittest.h" 13 #include "webkit/plugins/ppapi/ppapi_unittest.h"
13 14
14 using WebKit::WebCString; 15 using WebKit::WebCString;
(...skipping 30 matching lines...) Expand all
45 46
46 class URLRequestInfoTest : public PpapiUnittest { 47 class URLRequestInfoTest : public PpapiUnittest {
47 public: 48 public:
48 URLRequestInfoTest() { 49 URLRequestInfoTest() {
49 } 50 }
50 51
51 virtual void SetUp() { 52 virtual void SetUp() {
52 PpapiUnittest::SetUp(); 53 PpapiUnittest::SetUp();
53 54
54 // Must be after our base class's SetUp for the instance to be valid. 55 // Must be after our base class's SetUp for the instance to be valid.
55 info_ = new PPB_URLRequestInfo_Impl(instance()->pp_instance()); 56 info_ = new PPB_URLRequestInfo_Impl(instance()->pp_instance(),
57 ::ppapi::PPB_URLRequestInfo_Data());
56 } 58 }
57 59
58 static void SetUpTestCase() { 60 static void SetUpTestCase() {
59 web_view_ = WebView::create(NULL); 61 web_view_ = WebView::create(NULL);
60 web_view_->initializeMainFrame(&web_frame_client_); 62 web_view_->initializeMainFrame(&web_frame_client_);
61 WebURL web_url(GURL("")); 63 WebURL web_url(GURL(""));
62 WebURLRequest url_request; 64 WebURLRequest url_request;
63 url_request.initialize(); 65 url_request.initialize();
64 url_request.setURL(web_url); 66 url_request.setURL(web_url);
65 frame_ = web_view_->mainFrame(); 67 frame_ = web_view_->mainFrame();
66 frame_->loadRequest(url_request); 68 frame_->loadRequest(url_request);
67 } 69 }
68 70
69 static void TearDownTestCase() { 71 static void TearDownTestCase() {
70 web_view_->close(); 72 web_view_->close();
71 } 73 }
72 74
73 bool GetDownloadToFile() { 75 bool GetDownloadToFile() {
74 WebURLRequest web_request = info_->ToWebURLRequest(frame_); 76 WebURLRequest web_request;
77 if (!info_->ToWebURLRequest(frame_, &web_request))
78 return false;
75 return web_request.downloadToFile(); 79 return web_request.downloadToFile();
76 } 80 }
77 81
78 WebCString GetURL() { 82 WebCString GetURL() {
79 WebURLRequest web_request = info_->ToWebURLRequest(frame_); 83 WebURLRequest web_request;
84 if (!info_->ToWebURLRequest(frame_, &web_request))
85 return WebCString();
80 return web_request.url().spec(); 86 return web_request.url().spec();
81 } 87 }
82 88
83 WebString GetMethod() { 89 WebString GetMethod() {
84 WebURLRequest web_request = info_->ToWebURLRequest(frame_); 90 WebURLRequest web_request;
91 if (!info_->ToWebURLRequest(frame_, &web_request))
92 return WebString();
85 return web_request.httpMethod(); 93 return web_request.httpMethod();
86 } 94 }
87 95
88 WebString GetHeaderValue(const char* field) { 96 WebString GetHeaderValue(const char* field) {
89 WebURLRequest web_request = info_->ToWebURLRequest(frame_); 97 WebURLRequest web_request;
98 if (!info_->ToWebURLRequest(frame_, &web_request))
99 return WebString();
90 return web_request.httpHeaderField(WebString::fromUTF8(field)); 100 return web_request.httpHeaderField(WebString::fromUTF8(field));
91 } 101 }
92 102
103 bool SetBooleanProperty(PP_URLRequestProperty prop, bool b) {
104 return info_->SetBooleanProperty(prop, b);
105 }
106 bool SetStringProperty(PP_URLRequestProperty prop, const std::string& s) {
107 return info_->SetStringProperty(prop, s);
108 }
109
93 scoped_refptr<PPB_URLRequestInfo_Impl> info_; 110 scoped_refptr<PPB_URLRequestInfo_Impl> info_;
94 111
95 static TestWebFrameClient web_frame_client_; 112 static TestWebFrameClient web_frame_client_;
96 static WebView* web_view_; 113 static WebView* web_view_;
97 static WebFrame* frame_; 114 static WebFrame* frame_;
98 }; 115 };
99 116
100 TestWebFrameClient URLRequestInfoTest::web_frame_client_; 117 TestWebFrameClient URLRequestInfoTest::web_frame_client_;
101 WebView* URLRequestInfoTest::web_view_; 118 WebView* URLRequestInfoTest::web_view_;
102 WebFrame* URLRequestInfoTest::frame_; 119 WebFrame* URLRequestInfoTest::frame_;
103 120
104 TEST_F(URLRequestInfoTest, GetInterface) { 121 TEST_F(URLRequestInfoTest, GetInterface) {
105 const PPB_URLRequestInfo* interface = 122 const PPB_URLRequestInfo* interface =
106 ::ppapi::thunk::GetPPB_URLRequestInfo_Thunk(); 123 ::ppapi::thunk::GetPPB_URLRequestInfo_Thunk();
107 ASSERT_TRUE(interface); 124 EXPECT_TRUE(interface);
108 ASSERT_TRUE(interface->Create); 125 EXPECT_TRUE(interface->Create);
109 ASSERT_TRUE(interface->IsURLRequestInfo); 126 EXPECT_TRUE(interface->IsURLRequestInfo);
110 ASSERT_TRUE(interface->SetProperty); 127 EXPECT_TRUE(interface->SetProperty);
111 ASSERT_TRUE(interface->AppendDataToBody); 128 EXPECT_TRUE(interface->AppendDataToBody);
112 ASSERT_TRUE(interface->AppendFileToBody); 129 EXPECT_TRUE(interface->AppendFileToBody);
113 ASSERT_TRUE(interface->Create); 130 EXPECT_TRUE(interface->Create);
114 ASSERT_TRUE(interface->Create); 131 EXPECT_TRUE(interface->Create);
115 } 132 }
116 133
117 TEST_F(URLRequestInfoTest, AsURLRequestInfo) { 134 TEST_F(URLRequestInfoTest, AsURLRequestInfo) {
118 ASSERT_EQ(info_, info_->AsPPB_URLRequestInfo_API()); 135 EXPECT_EQ(info_, info_->AsPPB_URLRequestInfo_API());
119 } 136 }
120 137
121 TEST_F(URLRequestInfoTest, StreamToFile) { 138 TEST_F(URLRequestInfoTest, StreamToFile) {
122 info_->SetStringProperty(PP_URLREQUESTPROPERTY_URL, "http://www.google.com"); 139 SetStringProperty(PP_URLREQUESTPROPERTY_URL, "http://www.google.com");
123 140
124 ASSERT_FALSE(GetDownloadToFile()); 141 EXPECT_FALSE(GetDownloadToFile());
125 142
126 ASSERT_TRUE(info_->SetBooleanProperty( 143 EXPECT_TRUE(SetBooleanProperty(
127 PP_URLREQUESTPROPERTY_STREAMTOFILE, true)); 144 PP_URLREQUESTPROPERTY_STREAMTOFILE, true));
128 ASSERT_TRUE(GetDownloadToFile()); 145 EXPECT_TRUE(GetDownloadToFile());
129 146
130 ASSERT_TRUE(info_->SetBooleanProperty( 147 EXPECT_TRUE(SetBooleanProperty(
131 PP_URLREQUESTPROPERTY_STREAMTOFILE, false)); 148 PP_URLREQUESTPROPERTY_STREAMTOFILE, false));
132 ASSERT_FALSE(GetDownloadToFile()); 149 EXPECT_FALSE(GetDownloadToFile());
133 } 150 }
134 151
135 TEST_F(URLRequestInfoTest, FollowRedirects) { 152 TEST_F(URLRequestInfoTest, FollowRedirects) {
136 ASSERT_TRUE(info_->follow_redirects()); 153 EXPECT_TRUE(info_->GetData().follow_redirects);
137 154
138 ASSERT_TRUE(info_->SetBooleanProperty( 155 EXPECT_TRUE(SetBooleanProperty(
139 PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS, false)); 156 PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS, false));
140 ASSERT_FALSE(info_->follow_redirects()); 157 EXPECT_FALSE(info_->GetData().follow_redirects);
141 158
142 ASSERT_TRUE(info_->SetBooleanProperty( 159 EXPECT_TRUE(SetBooleanProperty(
143 PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS, true)); 160 PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS, true));
144 ASSERT_TRUE(info_->follow_redirects()); 161 EXPECT_TRUE(info_->GetData().follow_redirects);
145 } 162 }
146 163
147 TEST_F(URLRequestInfoTest, RecordDownloadProgress) { 164 TEST_F(URLRequestInfoTest, RecordDownloadProgress) {
148 ASSERT_FALSE(info_->record_download_progress()); 165 EXPECT_FALSE(info_->GetData().record_download_progress);
149 166
150 ASSERT_TRUE(info_->SetBooleanProperty( 167 EXPECT_TRUE(SetBooleanProperty(
151 PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS, true)); 168 PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS, true));
152 ASSERT_TRUE(info_->record_download_progress()); 169 EXPECT_TRUE(info_->GetData().record_download_progress);
153 170
154 ASSERT_TRUE(info_->SetBooleanProperty( 171 EXPECT_TRUE(SetBooleanProperty(
155 PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS, false)); 172 PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS, false));
156 ASSERT_FALSE(info_->record_download_progress()); 173 EXPECT_FALSE(info_->GetData().record_download_progress);
157 } 174 }
158 175
159 TEST_F(URLRequestInfoTest, RecordUploadProgress) { 176 TEST_F(URLRequestInfoTest, RecordUploadProgress) {
160 ASSERT_FALSE(info_->record_upload_progress()); 177 EXPECT_FALSE(info_->GetData().record_upload_progress);
161 178
162 ASSERT_TRUE(info_->SetBooleanProperty( 179 EXPECT_TRUE(SetBooleanProperty(
163 PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS, true)); 180 PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS, true));
164 ASSERT_TRUE(info_->record_upload_progress()); 181 EXPECT_TRUE(info_->GetData().record_upload_progress);
165 182
166 ASSERT_TRUE(info_->SetBooleanProperty( 183 EXPECT_TRUE(SetBooleanProperty(
167 PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS, false)); 184 PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS, false));
168 ASSERT_FALSE(info_->record_upload_progress()); 185 EXPECT_FALSE(info_->GetData().record_upload_progress);
169 } 186 }
170 187
171 TEST_F(URLRequestInfoTest, AllowCrossOriginRequests) { 188 TEST_F(URLRequestInfoTest, AllowCrossOriginRequests) {
172 ASSERT_FALSE(info_->allow_cross_origin_requests()); 189 EXPECT_FALSE(info_->GetData().allow_cross_origin_requests);
173 190
174 ASSERT_TRUE(info_->SetBooleanProperty( 191 EXPECT_TRUE(SetBooleanProperty(
175 PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS, true)); 192 PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS, true));
176 ASSERT_TRUE(info_->allow_cross_origin_requests()); 193 EXPECT_TRUE(info_->GetData().allow_cross_origin_requests);
177 194
178 ASSERT_TRUE(info_->SetBooleanProperty( 195 EXPECT_TRUE(SetBooleanProperty(
179 PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS, false)); 196 PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS, false));
180 ASSERT_FALSE(info_->allow_cross_origin_requests()); 197 EXPECT_FALSE(info_->GetData().allow_cross_origin_requests);
181 } 198 }
182 199
183 TEST_F(URLRequestInfoTest, AllowCredentials) { 200 TEST_F(URLRequestInfoTest, AllowCredentials) {
184 ASSERT_FALSE(info_->allow_credentials()); 201 EXPECT_FALSE(info_->GetData().allow_credentials);
185 202
186 ASSERT_TRUE(info_->SetBooleanProperty( 203 EXPECT_TRUE(SetBooleanProperty(
187 PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS, true)); 204 PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS, true));
188 ASSERT_TRUE(info_->allow_credentials()); 205 EXPECT_TRUE(info_->GetData().allow_credentials);
189 206
190 ASSERT_TRUE(info_->SetBooleanProperty( 207 EXPECT_TRUE(SetBooleanProperty(
191 PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS, false)); 208 PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS, false));
192 ASSERT_FALSE(info_->allow_credentials()); 209 EXPECT_FALSE(info_->GetData().allow_credentials);
193 } 210 }
194 211
195 TEST_F(URLRequestInfoTest, SetURL) { 212 TEST_F(URLRequestInfoTest, SetURL) {
196 // Test default URL is "about:blank". 213 // Test default URL is "about:blank".
197 ASSERT_TRUE(IsExpected(GetURL(), "about:blank")); 214 EXPECT_TRUE(IsExpected(GetURL(), "about:blank"));
198 215
199 const char* url = "http://www.google.com/"; 216 const char* url = "http://www.google.com/";
200 ASSERT_TRUE(info_->SetStringProperty( 217 EXPECT_TRUE(SetStringProperty(
201 PP_URLREQUESTPROPERTY_URL, url)); 218 PP_URLREQUESTPROPERTY_URL, url));
202 ASSERT_TRUE(IsExpected(GetURL(), url)); 219 EXPECT_TRUE(IsExpected(GetURL(), url));
203 } 220 }
204 221
205 TEST_F(URLRequestInfoTest, JavascriptURL) { 222 TEST_F(URLRequestInfoTest, JavascriptURL) {
206 const char* url = "javascript:foo = bar"; 223 const char* url = "javascript:foo = bar";
207 ASSERT_FALSE(info_->RequiresUniversalAccess()); 224 EXPECT_FALSE(info_->RequiresUniversalAccess());
208 info_->SetStringProperty(PP_URLREQUESTPROPERTY_URL, url); 225 SetStringProperty(PP_URLREQUESTPROPERTY_URL, url);
209 ASSERT_TRUE(info_->RequiresUniversalAccess()); 226 EXPECT_TRUE(info_->RequiresUniversalAccess());
210 } 227 }
211 228
212 TEST_F(URLRequestInfoTest, SetMethod) { 229 TEST_F(URLRequestInfoTest, SetMethod) {
213 // Test default method is "GET". 230 // Test default method is "GET".
214 ASSERT_TRUE(IsExpected(GetMethod(), "GET")); 231 EXPECT_TRUE(IsExpected(GetMethod(), "GET"));
215 ASSERT_TRUE(info_->SetStringProperty( 232 EXPECT_TRUE(SetStringProperty(
216 PP_URLREQUESTPROPERTY_METHOD, "POST")); 233 PP_URLREQUESTPROPERTY_METHOD, "POST"));
217 ASSERT_TRUE(IsExpected(GetMethod(), "POST")); 234 EXPECT_TRUE(IsExpected(GetMethod(), "POST"));
218 235
219 // Test that method names are converted to upper case. 236 // Test that method names are converted to upper case.
220 ASSERT_TRUE(info_->SetStringProperty( 237 EXPECT_TRUE(SetStringProperty(
221 PP_URLREQUESTPROPERTY_METHOD, "get")); 238 PP_URLREQUESTPROPERTY_METHOD, "get"));
222 ASSERT_TRUE(IsExpected(GetMethod(), "GET")); 239 EXPECT_TRUE(IsExpected(GetMethod(), "GET"));
223 ASSERT_TRUE(info_->SetStringProperty( 240 EXPECT_TRUE(SetStringProperty(
224 PP_URLREQUESTPROPERTY_METHOD, "post")); 241 PP_URLREQUESTPROPERTY_METHOD, "post"));
225 ASSERT_TRUE(IsExpected(GetMethod(), "POST")); 242 EXPECT_TRUE(IsExpected(GetMethod(), "POST"));
226 } 243 }
227 244
228 TEST_F(URLRequestInfoTest, SetInvalidMethod) { 245 TEST_F(URLRequestInfoTest, SetInvalidMethod) {
229 ASSERT_FALSE(info_->SetStringProperty( 246 EXPECT_FALSE(SetStringProperty(
230 PP_URLREQUESTPROPERTY_METHOD, "CONNECT")); 247 PP_URLREQUESTPROPERTY_METHOD, "CONNECT"));
231 ASSERT_FALSE(info_->SetStringProperty( 248 EXPECT_FALSE(SetStringProperty(
232 PP_URLREQUESTPROPERTY_METHOD, "connect")); 249 PP_URLREQUESTPROPERTY_METHOD, "connect"));
233 ASSERT_FALSE(info_->SetStringProperty( 250 EXPECT_FALSE(SetStringProperty(
234 PP_URLREQUESTPROPERTY_METHOD, "TRACE")); 251 PP_URLREQUESTPROPERTY_METHOD, "TRACE"));
235 ASSERT_FALSE(info_->SetStringProperty( 252 EXPECT_FALSE(SetStringProperty(
236 PP_URLREQUESTPROPERTY_METHOD, "trace")); 253 PP_URLREQUESTPROPERTY_METHOD, "trace"));
237 ASSERT_FALSE(info_->SetStringProperty( 254 EXPECT_FALSE(SetStringProperty(
238 PP_URLREQUESTPROPERTY_METHOD, "TRACK")); 255 PP_URLREQUESTPROPERTY_METHOD, "TRACK"));
239 ASSERT_FALSE(info_->SetStringProperty( 256 EXPECT_FALSE(SetStringProperty(
240 PP_URLREQUESTPROPERTY_METHOD, "track")); 257 PP_URLREQUESTPROPERTY_METHOD, "track"));
241 258
242 ASSERT_FALSE(info_->SetStringProperty( 259 EXPECT_FALSE(SetStringProperty(
243 PP_URLREQUESTPROPERTY_METHOD, "POST\x0d\x0ax-csrf-token:\x20test1234")); 260 PP_URLREQUESTPROPERTY_METHOD, "POST\x0d\x0ax-csrf-token:\x20test1234"));
244 } 261 }
245 262
246 TEST_F(URLRequestInfoTest, SetValidHeaders) { 263 TEST_F(URLRequestInfoTest, SetValidHeaders) {
247 // Test default header field. 264 // Test default header field.
248 ASSERT_TRUE(IsExpected( 265 EXPECT_TRUE(IsExpected(
249 GetHeaderValue("foo"), "")); 266 GetHeaderValue("foo"), ""));
250 // Test that we can set a header field. 267 // Test that we can set a header field.
251 ASSERT_TRUE(info_->SetStringProperty( 268 EXPECT_TRUE(SetStringProperty(
252 PP_URLREQUESTPROPERTY_HEADERS, "foo: bar")); 269 PP_URLREQUESTPROPERTY_HEADERS, "foo: bar"));
253 ASSERT_TRUE(IsExpected( 270 EXPECT_TRUE(IsExpected(
254 GetHeaderValue("foo"), "bar")); 271 GetHeaderValue("foo"), "bar"));
255 // Test that we can set multiple header fields using \n delimiter. 272 // Test that we can set multiple header fields using \n delimiter.
256 ASSERT_TRUE(info_->SetStringProperty( 273 EXPECT_TRUE(SetStringProperty(
257 PP_URLREQUESTPROPERTY_HEADERS, "foo: bar\nbar: baz")); 274 PP_URLREQUESTPROPERTY_HEADERS, "foo: bar\nbar: baz"));
258 ASSERT_TRUE(IsExpected( 275 EXPECT_TRUE(IsExpected(
259 GetHeaderValue("foo"), "bar")); 276 GetHeaderValue("foo"), "bar"));
260 ASSERT_TRUE(IsExpected( 277 EXPECT_TRUE(IsExpected(
261 GetHeaderValue("bar"), "baz")); 278 GetHeaderValue("bar"), "baz"));
262 } 279 }
263 280
264 TEST_F(URLRequestInfoTest, SetInvalidHeaders) { 281 TEST_F(URLRequestInfoTest, SetInvalidHeaders) {
265 const char* const kForbiddenHeaderFields[] = { 282 const char* const kForbiddenHeaderFields[] = {
266 "accept-charset", 283 "accept-charset",
267 "accept-encoding", 284 "accept-encoding",
268 "connection", 285 "connection",
269 "content-length", 286 "content-length",
270 "cookie", 287 "cookie",
(...skipping 13 matching lines...) Expand all
284 "via", 301 "via",
285 302
286 "proxy-foo", // Test for any header starting with proxy- or sec-. 303 "proxy-foo", // Test for any header starting with proxy- or sec-.
287 "sec-foo", 304 "sec-foo",
288 }; 305 };
289 306
290 // Test that no forbidden header fields can be set. 307 // Test that no forbidden header fields can be set.
291 for (size_t i = 0; i < arraysize(kForbiddenHeaderFields); ++i) { 308 for (size_t i = 0; i < arraysize(kForbiddenHeaderFields); ++i) {
292 std::string headers(kForbiddenHeaderFields[i]); 309 std::string headers(kForbiddenHeaderFields[i]);
293 headers.append(": foo"); 310 headers.append(": foo");
294 ASSERT_FALSE(info_->SetStringProperty( 311 SetStringProperty(
295 PP_URLREQUESTPROPERTY_HEADERS, headers.c_str())); 312 PP_URLREQUESTPROPERTY_HEADERS, headers.c_str());
296 ASSERT_TRUE(IsNullOrEmpty(GetHeaderValue(kForbiddenHeaderFields[i]))); 313 EXPECT_TRUE(IsNullOrEmpty(GetHeaderValue(kForbiddenHeaderFields[i])));
297 } 314 }
298 315
299 // Test that forbidden header can't be set in various ways. 316 // Test that forbidden header can't be set in various ways.
300 ASSERT_FALSE(info_->SetStringProperty( 317 SetStringProperty(PP_URLREQUESTPROPERTY_HEADERS, "cookie : foo");
301 PP_URLREQUESTPROPERTY_HEADERS, "cookie : foo")); 318 EXPECT_TRUE(IsNullOrEmpty(GetHeaderValue("cookie")));
302 ASSERT_TRUE(IsNullOrEmpty(GetHeaderValue("cookie")));
303 319
304 // Test that forbidden header can't be set with an allowed one. 320 // Test that forbidden header can't be set with an allowed one.
305 ASSERT_FALSE(info_->SetStringProperty( 321 SetStringProperty(PP_URLREQUESTPROPERTY_HEADERS, "foo: bar\ncookie: foo");
306 PP_URLREQUESTPROPERTY_HEADERS, "foo: bar\ncookie: foo")); 322 EXPECT_TRUE(IsNullOrEmpty(GetHeaderValue("cookie")));
307 ASSERT_TRUE(IsNullOrEmpty(GetHeaderValue("cookie")));
308 } 323 }
309 324
310 // TODO(bbudge) Unit tests for AppendDataToBody, AppendFileToBody. 325 // TODO(bbudge) Unit tests for AppendDataToBody, AppendFileToBody.
311 326
312 } // namespace ppapi 327 } // namespace ppapi
313 } // namespace webkit 328 } // namespace webkit
314 329
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698