chromium/content/browser/file_system/file_system_url_loader_factory_browsertest.cc

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

#include "content/browser/file_system/file_system_url_loader_factory.h"

#include <algorithm>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

#include "base/command_line.h"
#include "base/containers/heap_array.h"
#include "base/containers/span.h"
#include "base/feature_list.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/i18n/unicodestring.h"
#include "base/memory/raw_ptr.h"
#include "base/rand_util.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/test/bind.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/mock_callback.h"
#include "build/build_config.h"
#include "components/file_access/scoped_file_access.h"
#include "components/file_access/test/mock_scoped_file_access_delegate.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/test_utils.h"
#include "content/shell/browser/shell.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/mime_util.h"
#include "net/dns/mock_host_resolver.h"
#include "net/http/http_util.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "services/network/test/test_url_loader_client.h"
#include "storage/browser/file_system/external_mount_points.h"
#include "storage/browser/file_system/file_system_context.h"
#include "storage/browser/file_system/file_system_file_util.h"
#include "storage/browser/file_system/file_system_operation_context.h"
#include "storage/browser/file_system/file_system_operation_runner.h"
#include "storage/browser/file_system/file_system_url.h"
#include "storage/browser/file_system/sandbox_file_system_backend_delegate.h"
#include "storage/browser/quota/quota_manager_proxy.h"
#include "storage/browser/test/async_file_test_helper.h"
#include "storage/browser/test/mock_quota_manager.h"
#include "storage/browser/test/mock_quota_manager_proxy.h"
#include "storage/browser/test/mock_special_storage_policy.h"
#include "storage/browser/test/test_file_system_backend.h"
#include "storage/browser/test/test_file_system_context.h"
#include "storage/browser/test/test_file_system_options.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/icu/source/i18n/unicode/datefmt.h"
#include "third_party/icu/source/i18n/unicode/regex.h"
#include "url/gurl.h"
#include "url/origin.h"

BindLambdaForTesting;
URLLoaderFactory;
AsyncFileTestHelper;
FileSystemContext;
FileSystemOperationContext;
FileSystemURL;

namespace content {
namespace {

enum class TestMode {};

// We always use the TEMPORARY FileSystem in these tests.
constexpr char kFileSystemURLPrefix[] =;

constexpr char kValidExternalMountPoint[] =;

constexpr char kTestFileData[] =;

void FillBuffer(base::span<uint8_t> buffer) {}

// An auto mounter that will try to mount anything for `storage_domain` =
// "automount", but will only succeed for the mount point "mnt_name".
bool TestAutoMountForURLRequest(
    const storage::FileSystemRequestInfo& request_info,
    const storage::FileSystemURL& filesystem_url,
    base::OnceCallback<void(base::File::Error result)> callback) {}

void ReadDataPipeInternal(mojo::DataPipeConsumerHandle handle,
                          std::string* result,
                          base::OnceClosure quit_closure) {}

std::string ReadDataPipe(mojo::ScopedDataPipeConsumerHandle handle) {}

// Directory listings can have a HTML header in the file to format the response.
// This function determines if a single line in the response is for a directory
// entry.
bool IsDirectoryListingLine(const std::string& line) {}

// Is the line a title inserted by net::GetDirectoryListingHeader?
bool IsDirectoryListingTitle(const std::string& line) {}

}  // namespace

class FileSystemURLLoaderFactoryTest
    : public ContentBrowserTest,
      public ::testing::WithParamInterface<TestMode> {};

INSTANTIATE_TEST_SUITE_P();

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, DirectoryListing) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, InvalidURL) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, NoSuchRoot) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, NoSuchDirectory) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, Cancel) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, Incognito) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest,
                       AutoMountDirectoryListing) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, AutoMountInvalidRoot) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, AutoMountNoHandler) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, FileTest) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, FileTestDlp) {}

// Verify that when site isolation is enabled, a renderer process for one
// origin can't request filesystem: URLs belonging to another origin.  See
// https://crbug.com/964245.
IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, CrossOriginFileBlocked) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest,
                       FileTestFullSpecifiedRange) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest,
                       FileTestHalfSpecifiedRange) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest,
                       FileTestMultipleRangesNotSupported) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, FileRangeOutOfBounds) {}

// This test times out: http://crbug.com/944647.
IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest,
                       DISABLED_FileDirRedirect) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, FileNoSuchRoot) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, NoSuchFile) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, FileCancel) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, FileGetMimeType) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, FileIncognito) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, FileAutoMountFileTest) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest,
                       FileAutoMountInvalidRoot) {}

IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, FileAutoMountNoHandler) {}

}  // namespace content