#include <memory>
#include <string>
#include "base/barrier_closure.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/test/metrics/histogram_tester.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/chrome_test_utils.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/prefs/pref_service.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_base.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/prerender_test_util.h"
#include "data_saver.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/network_quality_tracker.h"
#include "third_party/blink/public/common/features.h"
namespace {
std::unique_ptr<net::test_server::HttpResponse> CaptureHeaderHandlerWithContent(
const std::string& path,
net::test_server::HttpRequest::HeaderMap* header_map,
const std::string& mime_type,
const std::string& content,
base::OnceClosure done_callback,
const net::test_server::HttpRequest& request) { … }
class TestEffectiveConnectionTypeObserver
: public network::NetworkQualityTracker::EffectiveConnectionTypeObserver { … };
class TestRTTAndThroughputEstimatesObserver
: public network::NetworkQualityTracker::RTTAndThroughputEstimatesObserver { … };
}
class DataSaverBrowserTest : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(DataSaverBrowserTest, DataSaverEnabled) { … }
IN_PROC_BROWSER_TEST_F(DataSaverBrowserTest, DataSaverDisabled) { … }
IN_PROC_BROWSER_TEST_F(DataSaverBrowserTest, DataSaverDisabledInIncognito) { … }
IN_PROC_BROWSER_TEST_F(DataSaverBrowserTest,
DataSaverEnabledDisablesPrerendering) { … }
class DataSaverWithServerBrowserTest : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(DataSaverWithServerBrowserTest, DISABLED_ReloadPage) { … }
class DataSaverForWorkerBrowserTest : public InProcessBrowserTest,
public testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(DataSaverForWorkerBrowserTest,
DISABLED_DedicatedWorker) { … }
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_SharedWorker …
#else
#define MAYBE_SharedWorker …
#endif
IN_PROC_BROWSER_TEST_P(DataSaverForWorkerBrowserTest, MAYBE_SharedWorker) { … }
IN_PROC_BROWSER_TEST_P(DataSaverForWorkerBrowserTest, ServiceWorker_Register) { … }
IN_PROC_BROWSER_TEST_P(DataSaverForWorkerBrowserTest, ServiceWorker_Update) { … }
IN_PROC_BROWSER_TEST_P(DataSaverForWorkerBrowserTest,
DISABLED_FetchFromWorker) { … }
IN_PROC_BROWSER_TEST_P(DataSaverForWorkerBrowserTest,
DISABLED_FetchFromSharedWorker) { … }
IN_PROC_BROWSER_TEST_P(DataSaverForWorkerBrowserTest,
DISABLED_FetchFromServiceWorker) { … }
IN_PROC_BROWSER_TEST_P(
DataSaverForWorkerBrowserTest,
DISABLED_FetchFromServiceWorkerControlledPage_NoFetchHandler) { … }
IN_PROC_BROWSER_TEST_P(
DataSaverForWorkerBrowserTest,
DISABLED_FetchFromServiceWorkerControlledPage_PassThrough) { … }
IN_PROC_BROWSER_TEST_P(
DataSaverForWorkerBrowserTest,
DISABLED_FetchFromServiceWorkerControlledPage_RespondWithFetch) { … }
class DataSaverWithImageServerBrowserTest : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(DataSaverWithImageServerBrowserTest,
ImgSrcset_DataSaverEnabled) { … }
IN_PROC_BROWSER_TEST_F(DataSaverWithImageServerBrowserTest,
ImgSrcset_DataSaverDisabled) { … }