#include "third_party/blink/public/common/shared_storage/module_script_downloader.h"
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/test/task_environment.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
#include "services/network/public/cpp/url_loader_completion_status.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
namespace blink {
namespace {
const char kAsciiResponseBody[] = …;
const char kUtf8ResponseBody[] = …;
const char kNonUtf8ResponseBody[] = …;
const char kAsciiCharset[] = …;
const char kUtf8Charset[] = …;
const char kJavascriptMimeType[] = …;
const char kJsonMimeType[] = …;
void AddResponse(network::TestURLLoaderFactory* url_loader_factory,
const GURL& url,
std::optional<std::string> mime_type,
std::optional<std::string> charset,
const std::string content,
net::HttpStatusCode http_status = net::HTTP_OK,
network::TestURLLoaderFactory::Redirects redirects =
network::TestURLLoaderFactory::Redirects()) { … }
}
class ModuleScriptDownloaderTest : public testing::Test { … };
TEST_F(ModuleScriptDownloaderTest, NetworkError) { … }
TEST_F(ModuleScriptDownloaderTest, HttpError) { … }
TEST_F(ModuleScriptDownloaderTest, Redirect) { … }
TEST_F(ModuleScriptDownloaderTest, Success) { … }
TEST_F(ModuleScriptDownloaderTest, UnexpectedMimeType) { … }
TEST_F(ModuleScriptDownloaderTest, JavscriptMimeTypeVariants) { … }
TEST_F(ModuleScriptDownloaderTest, Charset) { … }
}