#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "extensions/common/extension.h"
#include "extensions/test/test_extension_dir.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "services/network/public/cpp/features.h"
namespace extensions {
namespace {
std::unique_ptr<net::test_server::HttpResponse> HandleEchoOrigin(
const net::test_server::HttpRequest& request) { … }
constexpr char kFetchScript[] = …;
constexpr char kDOMFetchScript[] = …;
constexpr char kFetchPostScript[] = …;
class ExtensionFetchTest : public ExtensionApiTest { … };
IN_PROC_BROWSER_TEST_F(ExtensionFetchTest, ExtensionCanFetchExtensionResource) { … }
IN_PROC_BROWSER_TEST_F(ExtensionFetchTest,
ExtensionCanFetchHostedResourceWithHostPermissions) { … }
IN_PROC_BROWSER_TEST_F(
ExtensionFetchTest,
ExtensionCannotFetchHostedResourceWithoutHostPermissions) { … }
IN_PROC_BROWSER_TEST_F(ExtensionFetchTest,
HostCanFetchWebAccessibleExtensionResource) { … }
IN_PROC_BROWSER_TEST_F(
ExtensionFetchTest,
HostCanFetchWebAccessibleExtensionResource_FetchFromServiceWorker) { … }
IN_PROC_BROWSER_TEST_F(ExtensionFetchTest,
HostCannotFetchNonWebAccessibleExtensionResource) { … }
IN_PROC_BROWSER_TEST_F(ExtensionFetchTest, FetchResponseType) { … }
IN_PROC_BROWSER_TEST_F(ExtensionFetchTest, OriginOnPostWithPermissions) { … }
IN_PROC_BROWSER_TEST_F(ExtensionFetchTest, OriginOnPostWithoutPermissions) { … }
IN_PROC_BROWSER_TEST_F(ExtensionFetchTest, ExtensionResourceShouldNotBeOpaque) { … }
}
}