| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |