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

Side by Side Diff: webkit/glue/glue_serialize_unittest.cc

Issue 10695107: Fix: file permissions when restoring a page with file inputs with selected files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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
« webkit/glue/glue_serialize.cc ('K') | « webkit/glue/glue_serialize.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string> 5 #include <string>
6 6
7 #include "base/pickle.h" 7 #include "base/pickle.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPBody. h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPBody. h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 item.setHTTPBody(http_body); 274 item.setHTTPBody(http_body);
275 275
276 std::string serialized_item = webkit_glue::HistoryItemToString(item); 276 std::string serialized_item = webkit_glue::HistoryItemToString(item);
277 const std::vector<FilePath>& file_paths = 277 const std::vector<FilePath>& file_paths =
278 webkit_glue::FilePathsFromHistoryState(serialized_item); 278 webkit_glue::FilePathsFromHistoryState(serialized_item);
279 ASSERT_EQ(2U, file_paths.size()); 279 ASSERT_EQ(2U, file_paths.size());
280 EXPECT_EQ(file_path1, file_paths[0]); 280 EXPECT_EQ(file_path1, file_paths[0]);
281 EXPECT_EQ(file_path2, file_paths[1]); 281 EXPECT_EQ(file_path2, file_paths[1]);
282 } 282 }
283 283
284 TEST_F(GlueSerializeTest, FilePathsFromInputsInHistoryState) {
285 WebHistoryItem item;
286 item.initialize();
287
288 FilePath file_path_bad(FILE_PATH_LITERAL("bad-file.txt"));
289 FilePath file_path_good(FILE_PATH_LITERAL("good-file.txt"));
290 WebVector<WebString> document_state(size_t(13));
291 document_state[0] = WebString::fromUTF8(
292 "something and WebKit serialized form state version 5 and more");
293 document_state[1] = WebString::fromUTF8("name1");
294 document_state[2] = WebString::fromUTF8("not-a-file"); // control type
295 document_state[3] = WebString::fromUTF8("key");
296 document_state[4] = WebString::fromUTF8("2");
297 document_state[5] = webkit_glue::FilePathToWebString(file_path_bad);
298 document_state[6] = WebString::fromUTF8("filename");
299
300 document_state[7] = WebString::fromUTF8("name2");
301 document_state[8] = WebString::fromUTF8("file"); // control type
302 document_state[9] = WebString::fromUTF8("key");
303 document_state[10] = WebString::fromUTF8("2");
304 document_state[11] = webkit_glue::FilePathToWebString(file_path_good);
305 document_state[12] = WebString::fromUTF8("filename");
306 item.setDocumentState(document_state);
307
308 std::string serialized_item = webkit_glue::HistoryItemToString(item);
309 const std::vector<FilePath>& file_paths =
310 webkit_glue::FilePathsFromInputsInHistoryState(serialized_item);
311 ASSERT_EQ(1U, file_paths.size());
312 EXPECT_EQ(file_path_good, file_paths[0]);
313 }
314
284 // Makes sure that a HistoryItem containing password data remains intact after 315 // Makes sure that a HistoryItem containing password data remains intact after
285 // being serialized and deserialized. 316 // being serialized and deserialized.
286 TEST_F(GlueSerializeTest, HistoryItemWithPasswordsSerializeTest) { 317 TEST_F(GlueSerializeTest, HistoryItemWithPasswordsSerializeTest) {
287 const WebHistoryItem& item = MakeHistoryItemWithPasswordData(true); 318 const WebHistoryItem& item = MakeHistoryItemWithPasswordData(true);
288 const std::string& serialized_item = webkit_glue::HistoryItemToString(item); 319 const std::string& serialized_item = webkit_glue::HistoryItemToString(item);
289 const WebHistoryItem& deserialized_item = 320 const WebHistoryItem& deserialized_item =
290 webkit_glue::HistoryItemFromString(serialized_item); 321 webkit_glue::HistoryItemFromString(serialized_item);
291 322
292 ASSERT_FALSE(item.isNull()); 323 ASSERT_FALSE(item.isNull());
293 ASSERT_FALSE(deserialized_item.isNull()); 324 ASSERT_FALSE(deserialized_item.isNull());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 361
331 ASSERT_FALSE(item1.isNull()); 362 ASSERT_FALSE(item1.isNull());
332 ASSERT_FALSE(item2.isNull()); 363 ASSERT_FALSE(item2.isNull());
333 364
334 // Form data was not removed. 365 // Form data was not removed.
335 HistoryItemExpectEqual(item1, item2, 366 HistoryItemExpectEqual(item1, item2,
336 webkit_glue::HistoryItemCurrentVersion()); 367 webkit_glue::HistoryItemCurrentVersion());
337 } 368 }
338 369
339 } // namespace 370 } // namespace
OLDNEW
« webkit/glue/glue_serialize.cc ('K') | « webkit/glue/glue_serialize.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698