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

Side by Side Diff: content/browser/browsing_data/clear_site_data_throttle_unittest.cc

Issue 2333733002: Add a fuzzer test for the Clear-Site-Data header. (Closed)
Patch Set: Addressed comments. Created 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "content/browser/browsing_data/clear_site_data_throttle.h" 5 #include "content/browser/browsing_data/clear_site_data_throttle.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "content/public/common/content_switches.h" 10 #include "content/public/common/content_switches.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 EXPECT_TRUE(GetThrottle()->ParseHeader(test_case.header, &actual_cookies, 81 EXPECT_TRUE(GetThrottle()->ParseHeader(test_case.header, &actual_cookies,
82 &actual_storage, &actual_cache, 82 &actual_storage, &actual_cache,
83 &messages)); 83 &messages));
84 84
85 EXPECT_EQ(test_case.cookies, actual_cookies); 85 EXPECT_EQ(test_case.cookies, actual_cookies);
86 EXPECT_EQ(test_case.storage, actual_storage); 86 EXPECT_EQ(test_case.storage, actual_storage);
87 EXPECT_EQ(test_case.cache, actual_cache); 87 EXPECT_EQ(test_case.cache, actual_cache);
88 } 88 }
89 } 89 }
90 90
91 // TODO(msramek): Also test invalid inputs using libFuzzer.
92 TEST_F(ClearSiteDataThrottleTest, InvalidHeader) { 91 TEST_F(ClearSiteDataThrottleTest, InvalidHeader) {
93 struct TestCase { 92 struct TestCase {
94 const char* header; 93 const char* header;
95 const char* console_message; 94 const char* console_message;
96 } test_cases[] = { 95 } test_cases[] = {
97 {"", "Not a valid JSON.\n"}, 96 {"", "Not a valid JSON.\n"},
98 {"\"unclosed quote", "Not a valid JSON.\n"}, 97 {"\"unclosed quote", "Not a valid JSON.\n"},
99 {"\"some text\"", "Expecting a JSON dictionary with a 'types' field.\n"}, 98 {"\"some text\"", "Expecting a JSON dictionary with a 'types' field.\n"},
100 {"{ \"field\" : {} }", 99 {"{ \"field\" : {} }",
101 "Expecting a JSON dictionary with a 'types' field.\n"}, 100 "Expecting a JSON dictionary with a 'types' field.\n"},
(...skipping 23 matching lines...) Expand all
125 for (const auto& message : messages) { 124 for (const auto& message : messages) {
126 EXPECT_EQ(CONSOLE_MESSAGE_LEVEL_ERROR, message.level); 125 EXPECT_EQ(CONSOLE_MESSAGE_LEVEL_ERROR, message.level);
127 multiline_message += message.text + "\n"; 126 multiline_message += message.text + "\n";
128 } 127 }
129 128
130 EXPECT_EQ(test_case.console_message, multiline_message); 129 EXPECT_EQ(test_case.console_message, multiline_message);
131 } 130 }
132 } 131 }
133 132
134 } // namespace content 133 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browsing_data/clear_site_data_throttle.h ('k') | content/test/data/fuzzer_corpus/clear_site_data/all.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698