-
Notifications
You must be signed in to change notification settings - Fork 865
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable SXG and WebBundles blink experimental features.
Fixes brave/brave-browser#11133 - Modified redirect-cc.py to allow overriding files under out/XXX/gen - Overrode getter methods for: * SignedExchangePrefetchCacheForNavigations * SignedExchangeSubresourcePrefetch * SubresourceWebBundles to always return `false`
- Loading branch information
Showing
5 changed files
with
152 additions
and
4 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
chromium_src/third_party/blink/renderer/platform/runtime_enabled_features.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* Copyright (c) 2020 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "third_party/blink/renderer/platform/runtime_enabled_features.h" | ||
|
||
#define RuntimeEnabledFeatures RuntimeEnabledFeaturesBase | ||
#include "../gen/third_party/blink/renderer/platform/runtime_enabled_features.cc" | ||
#undef RuntimeEnabledFeatures | ||
|
42 changes: 42 additions & 0 deletions
42
chromium_src/third_party/blink/renderer/platform/runtime_enabled_features.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* Copyright (c) 2020 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_CHROMIUM_SRC_THIRD_PARTY_BLINK_RENDERER_PLATFORM_RUNTIME_ENABLED_FEATURES_H_ | ||
#define BRAVE_CHROMIUM_SRC_THIRD_PARTY_BLINK_RENDERER_PLATFORM_RUNTIME_ENABLED_FEATURES_H_ | ||
|
||
#define RuntimeEnabledFeatures RuntimeEnabledFeaturesBase | ||
#include "../gen/third_party/blink/renderer/platform/runtime_enabled_features.h" | ||
#undef RuntimeEnabledFeatures | ||
|
||
namespace blink { | ||
|
||
class PLATFORM_EXPORT RuntimeEnabledFeatures | ||
: public RuntimeEnabledFeaturesBase { | ||
STATIC_ONLY(RuntimeEnabledFeatures); | ||
|
||
public: | ||
// Hide these base class static methods: | ||
static bool SignedExchangePrefetchCacheForNavigationsEnabled() { | ||
return false; | ||
} | ||
static bool SignedExchangePrefetchCacheForNavigationsEnabled( | ||
const FeatureContext*) { | ||
return false; | ||
} | ||
static bool SignedExchangeSubresourcePrefetchEnabledByRuntimeFlag() { | ||
return false; | ||
} | ||
static bool SignedExchangeSubresourcePrefetchEnabled(const FeatureContext*) { | ||
return false; | ||
} | ||
static bool SubresourceWebBundlesEnabled() { return false; } | ||
static bool SubresourceWebBundlesEnabled(const FeatureContext*) { | ||
return false; | ||
} | ||
}; | ||
|
||
} // namespace blink | ||
|
||
#endif // BRAVE_CHROMIUM_SRC_THIRD_PARTY_BLINK_RENDERER_PLATFORM_RUNTIME_ENABLED_FEATURES_H_ |
91 changes: 91 additions & 0 deletions
91
chromium_src/third_party/blink/renderer/platform/runtime_enabled_features_test.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "third_party/blink/renderer/platform/runtime_enabled_features.h" | ||
|
||
#include "testing/gtest/include/gtest/gtest.h" | ||
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h" | ||
|
||
namespace blink { | ||
namespace { | ||
|
||
class RuntimeEnabledFeaturesTest : public testing::Test { | ||
public: | ||
void CheckAllDisabled() { | ||
EXPECT_FALSE(RuntimeEnabledFeatures:: | ||
SignedExchangePrefetchCacheForNavigationsEnabled()); | ||
EXPECT_FALSE(RuntimeEnabledFeatures:: | ||
SignedExchangePrefetchCacheForNavigationsEnabled(nullptr)); | ||
EXPECT_FALSE(RuntimeEnabledFeatures:: | ||
SignedExchangeSubresourcePrefetchEnabledByRuntimeFlag()); | ||
EXPECT_FALSE( | ||
RuntimeEnabledFeatures::SignedExchangeSubresourcePrefetchEnabled( | ||
nullptr)); | ||
EXPECT_FALSE(RuntimeEnabledFeatures::SubresourceWebBundlesEnabled()); | ||
EXPECT_FALSE(RuntimeEnabledFeatures::SubresourceWebBundlesEnabled(nullptr)); | ||
} | ||
|
||
void CheckChromiumImplState(bool state) { | ||
EXPECT_EQ(state, RuntimeEnabledFeaturesBase:: | ||
SignedExchangePrefetchCacheForNavigationsEnabled()); | ||
EXPECT_EQ(state, RuntimeEnabledFeaturesBase:: | ||
SignedExchangePrefetchCacheForNavigationsEnabled(nullptr)); | ||
EXPECT_EQ(state, RuntimeEnabledFeaturesBase:: | ||
SignedExchangeSubresourcePrefetchEnabledByRuntimeFlag()); | ||
EXPECT_EQ( | ||
state, | ||
RuntimeEnabledFeaturesBase::SignedExchangeSubresourcePrefetchEnabled( | ||
nullptr)); | ||
EXPECT_EQ(state, | ||
RuntimeEnabledFeaturesBase::SubresourceWebBundlesEnabled()); | ||
EXPECT_EQ(state, RuntimeEnabledFeaturesBase::SubresourceWebBundlesEnabled( | ||
nullptr)); | ||
} | ||
|
||
void CheckChromiumImplDisabled() { CheckChromiumImplState(false); } | ||
void CheckChromiumImplEnabled() { CheckChromiumImplState(true); } | ||
|
||
void SetFeaturesState(bool state) { | ||
RuntimeEnabledFeatures::SetSignedExchangePrefetchCacheForNavigationsEnabled( | ||
state); | ||
RuntimeEnabledFeatures::SetSignedExchangeSubresourcePrefetchEnabled(state); | ||
RuntimeEnabledFeatures::SetSubresourceWebBundlesEnabled(state); | ||
} | ||
|
||
void SetFeaturesDisabled() { SetFeaturesState(false); } | ||
void SetFeaturesEnabled() { SetFeaturesState(true); } | ||
}; | ||
|
||
TEST_F(RuntimeEnabledFeaturesTest, TestSXGandWebBundlesDisabled) { | ||
// Initial state - all disabled. | ||
CheckChromiumImplDisabled(); | ||
CheckAllDisabled(); | ||
|
||
// Enable SXG and WebBundles | ||
SetFeaturesEnabled(); | ||
// Check that features are enabled via the chromium implementation | ||
CheckChromiumImplEnabled(); | ||
// Should all come back as disabled. | ||
CheckAllDisabled(); | ||
|
||
// Reset to disabled. | ||
SetFeaturesDisabled(); | ||
CheckChromiumImplDisabled(); | ||
CheckAllDisabled(); | ||
|
||
// Enable using SetFeatureEnabledFromString API. | ||
RuntimeEnabledFeatures::SetFeatureEnabledFromString( | ||
"SignedExchangePrefetchCacheForNavigations", true); | ||
RuntimeEnabledFeatures::SetFeatureEnabledFromString( | ||
"SignedExchangeSubresourcePrefetch", true); | ||
RuntimeEnabledFeatures::SetFeatureEnabledFromString("SubresourceWebBundles", | ||
true); | ||
// Check that features are enabled via the chromium implementation | ||
CheckChromiumImplEnabled(); | ||
// Should all come back as disabled. | ||
CheckAllDisabled(); | ||
} | ||
|
||
} // namespace | ||
} // namespace blink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters