chromium/third_party/blink/common/shared_storage/module_script_downloader_unittest.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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()) {}

}  // namespace

class ModuleScriptDownloaderTest : public testing::Test {};

TEST_F(ModuleScriptDownloaderTest, NetworkError) {}

// HTTP 404 responses are treated as failures.
TEST_F(ModuleScriptDownloaderTest, HttpError) {}

// Redirect responses are treated as failures.
TEST_F(ModuleScriptDownloaderTest, Redirect) {}

TEST_F(ModuleScriptDownloaderTest, Success) {}

// Test unexpected response mime type.
TEST_F(ModuleScriptDownloaderTest, UnexpectedMimeType) {}

// Test all Javscript type strings.
TEST_F(ModuleScriptDownloaderTest, JavscriptMimeTypeVariants) {}

TEST_F(ModuleScriptDownloaderTest, Charset) {}

}  // namespace blink