// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifdef UNSAFE_BUFFERS_BUILD // TODO(crbug.com/351564777): Remove this and convert code to safer constructs. #pragma allow_unsafe_buffers #endif #include "extensions/browser/api/web_request/form_data_parser.h" #include <stddef.h> #include <string_view> #include "base/check.h" #include "testing/gtest/include/gtest/gtest.h" namespace extensions { namespace { // Attempts to create a parser corresponding to the |content_type_header|. // On success, returns the parser. std::unique_ptr<FormDataParser> InitParser( const std::string& content_type_header) { … } // Attempts to run the parser corresponding to the |content_type_header| // on the source represented by the concatenation of blocks from |bytes|. // On success, returns true and the parsed |output|, else false. // Parsed |output| has names on even positions (0, 2, ...), values on odd ones. bool RunParser(const std::string& content_type_header, const std::vector<const std::string_view*>& bytes, std::vector<std::string>* output) { … } // Attempts to run the parser corresponding to the |content_type_header| // on the source represented by the concatenation of blocks from |bytes|. // Checks that the parser fails parsing. bool CheckParserFails(const std::string& content_type_header, const std::vector<const std::string_view*>& bytes) { … } } // namespace TEST(WebRequestFormDataParserTest, Parsing) { … } TEST(WebRequestFormDataParserTest, MalformedPayload) { … } } // namespace extensions