From 7fdbb427bc3a2886ef6b5ac6735285b0cb59c0f6 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 11 Aug 2022 16:17:33 -0400 Subject: [PATCH] alloy: Fix flaky OnDraggableRegionsChanged behavior (fixes issue #3374) Disable BackForwardCache globally for the Alloy runtime so that blink::RuntimeEnabledFeatures::BackForwardCacheEnables reports the correct value in the renderer process. --- libcef/common/alloy/alloy_main_delegate.cc | 12 ++++++++++-- tests/ceftests/draggable_regions_unittest.cc | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/libcef/common/alloy/alloy_main_delegate.cc b/libcef/common/alloy/alloy_main_delegate.cc index ad379664b..7c6eb415e 100644 --- a/libcef/common/alloy/alloy_main_delegate.cc +++ b/libcef/common/alloy/alloy_main_delegate.cc @@ -242,9 +242,9 @@ absl::optional AlloyMainDelegate::BasicStartupComplete() { base::NumberToString(settings_->uncaught_exception_stack_size)); } -#if BUILDFLAG(IS_WIN) std::vector disable_features; +#if BUILDFLAG(IS_WIN) if (features::kCalculateNativeWinOcclusion.default_state == base::FEATURE_ENABLED_BY_DEFAULT) { // TODO: Add support for occlusion detection in combination with native @@ -257,6 +257,15 @@ absl::optional AlloyMainDelegate::BasicStartupComplete() { // TODO: Add support for windows spellcheck service (see issue #3055). disable_features.push_back(spellcheck::kWinUseBrowserSpellChecker.name); } +#endif // BUILDFLAG(IS_WIN) + + if (features::kBackForwardCache.default_state == + base::FEATURE_ENABLED_BY_DEFAULT) { + // Disable BackForwardCache globally so that + // blink::RuntimeEnabledFeatures::BackForwardCacheEnabled reports the + // correct value in the renderer process (see issue #3374). + disable_features.push_back(features::kBackForwardCache.name); + } if (!disable_features.empty()) { DCHECK(!base::FeatureList::GetInstance()); @@ -270,7 +279,6 @@ absl::optional AlloyMainDelegate::BasicStartupComplete() { command_line->AppendSwitchASCII(switches::kDisableFeatures, disable_features_str); } -#endif // BUILDFLAG(IS_WIN) } if (application_) { diff --git a/tests/ceftests/draggable_regions_unittest.cc b/tests/ceftests/draggable_regions_unittest.cc index b6fcd3774..5b5251d47 100644 --- a/tests/ceftests/draggable_regions_unittest.cc +++ b/tests/ceftests/draggable_regions_unittest.cc @@ -7,6 +7,9 @@ #include "tests/ceftests/test_handler.h" #include "tests/gtest/include/gtest/gtest.h" +// Set to 1 to enable verbose debugging info logging. +#define VERBOSE_DEBUGGING 0 + namespace { const char kTestHTMLWithRegions[] = @@ -100,6 +103,19 @@ class DraggableRegionsTestHandler : public TestHandler, draggable_regions_changed_ct_++; +#if VERBOSE_DEBUGGING + LOG(INFO) << "step " << step_ << " regions.size " << regions.size() + << " url " << frame->GetURL().ToString(); + if (regions.size() == 2) { + LOG(INFO) << " region[0] x " << regions[0].bounds.x << " y " + << regions[0].bounds.y << " width " << regions[0].bounds.width + << " height " << regions[0].bounds.height; + LOG(INFO) << " region[1] x " << regions[1].bounds.x << " y " + << regions[1].bounds.y << " width " << regions[1].bounds.width + << " height " << regions[1].bounds.height; + } +#endif // VERBOSE_DEBUGGING + switch (step_) { case kStepWithRegions: case kStepWithChangingRegions2: