alloy: Fix flaky OnDraggableRegionsChanged behavior (fixes issue #3374)

Disable BackForwardCache globally for the Alloy runtime so that
blink::RuntimeEnabledFeatures::BackForwardCacheEnabled reports the
correct value in the renderer process.
This commit is contained in:
Marshall Greenblatt 2022-08-11 16:17:33 -04:00
parent 69bf4a73da
commit 181df42df2
2 changed files with 26 additions and 2 deletions

View File

@ -246,9 +246,9 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) {
base::NumberToString(settings_->uncaught_exception_stack_size)); base::NumberToString(settings_->uncaught_exception_stack_size));
} }
#if BUILDFLAG(IS_WIN)
std::vector<std::string> disable_features; std::vector<std::string> disable_features;
#if BUILDFLAG(IS_WIN)
if (features::kCalculateNativeWinOcclusion.default_state == if (features::kCalculateNativeWinOcclusion.default_state ==
base::FEATURE_ENABLED_BY_DEFAULT) { base::FEATURE_ENABLED_BY_DEFAULT) {
// TODO: Add support for occlusion detection in combination with native // TODO: Add support for occlusion detection in combination with native
@ -261,6 +261,15 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) {
// TODO: Add support for windows spellcheck service (see issue #3055). // TODO: Add support for windows spellcheck service (see issue #3055).
disable_features.push_back(spellcheck::kWinUseBrowserSpellChecker.name); 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()) { if (!disable_features.empty()) {
DCHECK(!base::FeatureList::GetInstance()); DCHECK(!base::FeatureList::GetInstance());
@ -274,7 +283,6 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) {
command_line->AppendSwitchASCII(switches::kDisableFeatures, command_line->AppendSwitchASCII(switches::kDisableFeatures,
disable_features_str); disable_features_str);
} }
#endif // BUILDFLAG(IS_WIN)
} }
if (application_) { if (application_) {

View File

@ -7,6 +7,9 @@
#include "tests/ceftests/test_handler.h" #include "tests/ceftests/test_handler.h"
#include "tests/gtest/include/gtest/gtest.h" #include "tests/gtest/include/gtest/gtest.h"
// Set to 1 to enable verbose debugging info logging.
#define VERBOSE_DEBUGGING 0
namespace { namespace {
const char kTestHTMLWithRegions[] = const char kTestHTMLWithRegions[] =
@ -100,6 +103,19 @@ class DraggableRegionsTestHandler : public TestHandler,
draggable_regions_changed_ct_++; 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_) { switch (step_) {
case kStepWithRegions: case kStepWithRegions:
case kStepWithChangingRegions2: case kStepWithChangingRegions2: