#include <stddef.h>
#include <stdint.h>
#include <map>
#include <memory>
#include <set>
#include <utility>
#include "base/command_line.h"
#include "base/format_macros.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/field_trial_param_associator.h"
#include "base/metrics/field_trial_params.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_clock.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/test/with_feature_override.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/predictors/loading_predictor.h"
#include "chrome/browser/predictors/loading_predictor_factory.h"
#include "chrome/browser/predictors/loading_test_util.h"
#include "chrome/browser/preloading/prefetch/no_state_prefetch/no_state_prefetch_unit_test_utils.h"
#include "chrome/browser/preloading/preloading_prefs.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/no_state_prefetch/browser/no_state_prefetch_contents.h"
#include "components/no_state_prefetch/browser/no_state_prefetch_field_trial.h"
#include "components/no_state_prefetch/browser/no_state_prefetch_handle.h"
#include "components/no_state_prefetch/browser/no_state_prefetch_link_manager.h"
#include "components/no_state_prefetch/browser/no_state_prefetch_manager.h"
#include "components/no_state_prefetch/common/no_state_prefetch_origin.h"
#include "components/no_state_prefetch/common/no_state_prefetch_utils.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
#include "mojo/public/cpp/bindings/unique_receiver_set.h"
#include "net/base/network_change_notifier.h"
#include "net/http/http_cache.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "url/gurl.h"
Time;
TimeTicks;
Referrer;
namespace prerender {
namespace {
class TestNetworkBytesChangedObserver
: public prerender::NoStatePrefetchHandle::Observer { … };
const gfx::Size kDefaultViewSize(640, 480);
}
class MockNetworkChangeNotifier4GMetered : public net::NetworkChangeNotifier { … };
class MockNetworkChangeNotifier4GUnmetered : public net::NetworkChangeNotifier { … };
class MockNetworkChangeNotifierWifiMetered : public net::NetworkChangeNotifier { … };
class NoStatePrefetchTest : public testing::Test { … };
TEST_F(NoStatePrefetchTest, RespectsThirdPartyCookiesPref) { … }
class NoStatePrefetchGWSPrefetchHoldbackTest : public NoStatePrefetchTest { … };
TEST_F(NoStatePrefetchGWSPrefetchHoldbackTest,
GWSPrefetchHoldbackNonGWSSReferrer) { … }
TEST_F(NoStatePrefetchGWSPrefetchHoldbackTest, GWSPrefetchHoldbackGWSReferrer) { … }
class NoStatePrefetchGWSPrefetchHoldbackOffTest : public NoStatePrefetchTest { … };
TEST_F(NoStatePrefetchGWSPrefetchHoldbackOffTest,
GWSPrefetchHoldbackOffNonGWSReferrer) { … }
TEST_F(NoStatePrefetchGWSPrefetchHoldbackOffTest,
GWSPrefetchHoldbackOffGWSReferrer) { … }
class PrerendererNavigationPredictorPrefetchHoldbackTest
: public NoStatePrefetchTest { … };
TEST_F(PrerendererNavigationPredictorPrefetchHoldbackTest,
PredictorPrefetchHoldbackNonPredictorReferrer) { … }
TEST_F(NoStatePrefetchTest, LinkRelNextWithNSPDisabled) { … }
class PrerendererNavigationPredictorPrefetchHoldbackDisabledTest
: public NoStatePrefetchTest { … };
TEST_F(PrerendererNavigationPredictorPrefetchHoldbackDisabledTest,
PredictorPrefetchHoldbackOffNonPredictorReferrer) { … }
TEST_F(NoStatePrefetchTest, DISABLED_PrerenderDisabledOnLowEndDevice) { … }
TEST_F(NoStatePrefetchTest, FoundTest) { … }
TEST_F(NoStatePrefetchTest, DISABLED_DuplicateTest_NoStatePrefetch) { … }
TEST_F(NoStatePrefetchTest, ExpireTest) { … }
TEST_F(NoStatePrefetchTest, BadURLTest) { … }
TEST_F(NoStatePrefetchTest, LinkManagerNavigateAwayExpire) { … }
TEST_F(NoStatePrefetchTest, LinkManagerNavigateAwayNearExpiry) { … }
TEST_F(NoStatePrefetchTest, LinkManagerNavigateAwayLaunchAnother) { … }
TEST_F(NoStatePrefetchTest, NoStatePrefetchDuplicate) { … }
TEST_F(NoStatePrefetchTest, MaxConcurrencyTest) { … }
TEST_F(NoStatePrefetchTest, DISABLED_AliasURLTest) { … }
TEST_F(NoStatePrefetchTest, SourceRenderViewClosed) { … }
TEST_F(NoStatePrefetchTest, RecentlyVisited) { … }
TEST_F(NoStatePrefetchTest, NotSoRecentlyVisited) { … }
TEST_F(NoStatePrefetchTest, FragmentMatchesTest) { … }
TEST_F(NoStatePrefetchTest, FragmentsDifferTest) { … }
TEST_F(NoStatePrefetchTest, ClearTest) { … }
TEST_F(NoStatePrefetchTest, CancelAllTest) { … }
class NoStatePrefetchFallbackToPreconnectTest
: public base::test::WithFeatureOverride,
public NoStatePrefetchTest { … };
INSTANTIATE_FEATURE_OVERRIDE_TEST_SUITE(…);
TEST_P(NoStatePrefetchFallbackToPreconnectTest, LinkRelPrerender) { … }
TEST_F(NoStatePrefetchTest, LinkRelStillAllowedWhenDisabled) { … }
TEST_F(NoStatePrefetchTest, LinkRelAllowedOnCellular) { … }
TEST_F(NoStatePrefetchTest, LinkManagerCancel) { … }
TEST_F(NoStatePrefetchTest, LinkManagerAbandon) { … }
TEST_F(NoStatePrefetchTest, LinkManagerAbandonThenCancel) { … }
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || \
BUILDFLAG(IS_CHROMEOS)
#define MAYBE_LinkManagerAddTwiceCancelTwice …
#else
#define MAYBE_LinkManagerAddTwiceCancelTwice …
#endif
TEST_F(NoStatePrefetchTest, MAYBE_LinkManagerAddTwiceCancelTwice) { … }
TEST_F(NoStatePrefetchTest, DISABLED_LinkManagerAddTwiceAbandonTwiceUseTwice) { … }
TEST_F(NoStatePrefetchTest, LinkManagerExpireThenCancel) { … }
TEST_F(NoStatePrefetchTest, LinkManagerExpireThenAddAgain) { … }
TEST_F(NoStatePrefetchTest, DISABLED_LinkManagerCancelThenAddAgain) { … }
TEST_F(NoStatePrefetchTest, DISABLED_LinkManagerAbandonInactivePrerender) { … }
TEST_F(NoStatePrefetchTest, LinkManagerWaitToLaunchNotLaunched) { … }
TEST_F(NoStatePrefetchTest, LinkManagerExpireRevealingLaunch) { … }
TEST_F(NoStatePrefetchTest, NoStatePrefetchContentsIsValidHttpMethod) { … }
TEST_F(NoStatePrefetchTest, NoPrerenderInSingleProcess) { … }
}