This change adds `[[clang::no_destroy]]` to all places where `-Wexit-time-destructors` has caused an error. This is a mechanical change, and the individual cases must be fixed separately. Chromium changes: https://chromium.googlesource.com/chromium/src/+/62849b7b1a562b823e34e64ec54b9724dc88cbfd commit 62849b7b1a562b823e34e64ec54b9724dc88cbfd Author: Claudio DeSouza <cdesouza@chromium.org> Date: Mon Aug 25 07:58:19 2025 -0700 Reland "[exit-time-destructors] Enable by default" This reverts commit cfbf29170f0b3e73e580d291085c188f8aa8cfa0. The cause for the revert was breakage elsewhere that needed exclusions, which are being handdled in https://crrev.com/c/6863758 Bug: 40031409, 430332953 Original change's description: > Revert "[exit-time-destructors] Enable by default" > > This reverts commit 180c32cb5158bb4039235288b38813697b757e1a. > > Reason for revert: Broke the build on some bots: > https://ci.chromium.org/ui/p/chromium/builders/ci/chromeos-arm-generic-rel/148963/overview > > Bug: 40031409, 430332953 > Original change's description: > > [exit-time-destructors] Enable by default > > > > This CL enables `-Wexit-time-destructors` as a default warning in > > Chromium. As the value of `is_wexit_time_destructors_default` is being > > flipped, it is expected that the old config, `wexit_time_destructors`, > > which was a opt-in, will become no-op, while the newly introduced > > opt-out config will have its effect in places with pending issues. > > > > There are exclusions being added to `warning_suppression.txt` for > > certain paths under `//third_party/`. These entries attempt to be the > > narrowest possible. Work is under way to eliminate completely the need > > for these, but this is in general slow (although fixes have been merged > > into dawn, v8, and pdfium). > > > > Bug: 40031409, 430332953 > > Change-Id: I0c01c1e4ef8dfdcc319538cbda7991f364a6f22c > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6826535 > > Reviewed-by: Devon Loehr <dloehr@google.com> > > Commit-Queue: Claudio DeSouza <cdesouza@chromium.org> > > Cr-Commit-Position: refs/heads/main@{#1502919} > > Bug: 40031409, 430332953 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Change-Id: Icefe8b2206147767f0c074362e995af2030a1fd6 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6860282 > Auto-Submit: Thomas Guilbert <tguilbert@chromium.org> > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> > Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> > Reviewed-by: Devon Loehr <dloehr@google.com> > Cr-Commit-Position: refs/heads/main@{#1502936} Bug: 40031409, 430332953 Change-Id: Ib556482a0b31814107eafe3620af13e0d272cd76 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6859042 Reviewed-by: William Liu <liuwilliam@chromium.org> Reviewed-by: Devon Loehr <dloehr@google.com> Commit-Queue: Claudio DeSouza <cdesouza@chromium.org> Cr-Commit-Position: refs/heads/main@{#1505863}
141 lines
5.7 KiB
C++
141 lines
5.7 KiB
C++
/* Copyright (c) 2019 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 <optional>
|
|
|
|
#include "brave/components/update_client/buildflags.h"
|
|
#include "build/build_config.h"
|
|
#include "chrome/browser/domain_reliability/service_factory.h"
|
|
#include "chrome/common/chrome_switches.h"
|
|
#include "chrome/test/base/platform_browser_test.h"
|
|
#include "components/component_updater/component_updater_switches.h"
|
|
#include "components/embedder_support/switches.h"
|
|
#include "components/sync/base/command_line_switches.h"
|
|
#include "content/public/test/browser_test.h"
|
|
#include "services/network/public/cpp/network_switches.h"
|
|
|
|
using BraveMainDelegateBrowserTest = PlatformBrowserTest;
|
|
|
|
constexpr char kBraveOriginTrialsPublicKey[] =
|
|
"bYUKPJoPnCxeNvu72j4EmPuK7tr1PAC7SHh8ld9Mw3E=,"
|
|
"fMS4mpO6buLQ/QMd+zJmxzty/VQ6B1EUZqoCU04zoRU=";
|
|
|
|
struct SyncUrlTestCase {
|
|
// Input parameters for SetUpCommandLine
|
|
std::optional<std::string> input_sync_url;
|
|
std::optional<std::string> input_unsafe_origin;
|
|
|
|
// Expected results after command line processing
|
|
bool expect_sync_url_switch;
|
|
std::optional<std::string> expected_sync_url_value;
|
|
|
|
// Test case name suffix
|
|
const char* test_name_suffix;
|
|
};
|
|
|
|
class BraveMainDelegateSyncUrlBrowserTest
|
|
: public PlatformBrowserTest,
|
|
public testing::WithParamInterface<SyncUrlTestCase> {
|
|
public:
|
|
void SetUpCommandLine(base::CommandLine* command_line) override {
|
|
PlatformBrowserTest::SetUpCommandLine(command_line);
|
|
const SyncUrlTestCase& test_case = GetParam();
|
|
if (test_case.input_sync_url) {
|
|
command_line->AppendSwitchASCII(syncer::kSyncServiceURL,
|
|
*test_case.input_sync_url);
|
|
}
|
|
if (test_case.input_unsafe_origin) {
|
|
command_line->AppendSwitchASCII(
|
|
network::switches::kUnsafelyTreatInsecureOriginAsSecure,
|
|
*test_case.input_unsafe_origin);
|
|
}
|
|
}
|
|
};
|
|
|
|
// TODO(https://github.com/brave/brave-browser/issues/48713): This is a case of
|
|
// `-Wexit-time-destructors` violation and `[[clang::no_destroy]]` has been
|
|
// added in the meantime to fix the build error. Remove this attribute and
|
|
// provide a proper fix.
|
|
[[clang::no_destroy]] const SyncUrlTestCase kSyncUrlTestCases[] = {
|
|
// Test Case 1: HTTPS URL (secure)
|
|
// A secure HTTPS URL should be accepted and retained unchanged
|
|
{"https://some-sync-server.com/v2", std::nullopt, true,
|
|
"https://some-sync-server.com/v2", "Secure"},
|
|
|
|
// Test Case 2: No URL provided
|
|
// When no sync URL is provided, the switch should be removed entirely
|
|
{std::nullopt, std::nullopt, false, std::nullopt, "None"},
|
|
|
|
// Test Case 3: HTTP URL (insecure)
|
|
// An insecure HTTP URL should be rejected and the switch removed
|
|
// unless the origin is explicitly marked as safe
|
|
{"http://insecure-sync-server.com/v2", std::nullopt,
|
|
false, // Should be removed
|
|
std::nullopt, "Insecure"},
|
|
|
|
// Test Case 4: Localhost HTTP URL
|
|
// Localhost is considered a potentially trustworthy origin,
|
|
// so HTTP is allowed for localhost URLs
|
|
{"http://localhost:8295/v2", std::nullopt,
|
|
true, // Localhost is always allowed
|
|
"http://localhost:8295/v2", "Localhost"},
|
|
|
|
// Test Case 5: Insecure HTTP URL with origin explicitly marked as safe
|
|
// When an origin is explicitly marked as safe via the
|
|
// |--unsafely-treat-insecure-origin-as-secure| switch, HTTP is allowed
|
|
{"http://insecure-sync-server.com/v2", "http://insecure-sync-server.com",
|
|
true, // Allowed via unsafe origin switch
|
|
"http://insecure-sync-server.com/v2", "InsecureButAllowed"}};
|
|
|
|
IN_PROC_BROWSER_TEST_P(BraveMainDelegateSyncUrlBrowserTest, SyncUrlHandling) {
|
|
const SyncUrlTestCase& test_case = GetParam();
|
|
const base::CommandLine* command_line =
|
|
base::CommandLine::ForCurrentProcess();
|
|
|
|
EXPECT_EQ(test_case.expect_sync_url_switch,
|
|
command_line->HasSwitch(syncer::kSyncServiceURL));
|
|
|
|
if (test_case.expect_sync_url_switch) {
|
|
ASSERT_TRUE(test_case.expected_sync_url_value.has_value());
|
|
EXPECT_EQ(*test_case.expected_sync_url_value,
|
|
command_line->GetSwitchValueASCII(syncer::kSyncServiceURL));
|
|
} else {
|
|
// If the switch is not expected, the value should also not be expected.
|
|
ASSERT_FALSE(test_case.expected_sync_url_value.has_value());
|
|
}
|
|
}
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
|
SyncUrlTests,
|
|
BraveMainDelegateSyncUrlBrowserTest,
|
|
testing::ValuesIn(kSyncUrlTestCases),
|
|
[](const testing::TestParamInfo<SyncUrlTestCase>& info) {
|
|
return info.param.test_name_suffix;
|
|
});
|
|
|
|
IN_PROC_BROWSER_TEST_F(BraveMainDelegateBrowserTest,
|
|
DomainReliabilityServiceDisabled) {
|
|
EXPECT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch(
|
|
switches::kDisableDomainReliability));
|
|
EXPECT_FALSE(domain_reliability::ShouldCreateService());
|
|
}
|
|
|
|
IN_PROC_BROWSER_TEST_F(BraveMainDelegateBrowserTest,
|
|
ComponentUpdaterReplacement) {
|
|
EXPECT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch(
|
|
switches::kComponentUpdater));
|
|
EXPECT_EQ(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
|
|
switches::kComponentUpdater),
|
|
std::string("url-source=") + BUILDFLAG(UPDATER_PROD_ENDPOINT));
|
|
}
|
|
|
|
IN_PROC_BROWSER_TEST_F(BraveMainDelegateBrowserTest, OriginTrialsTest) {
|
|
EXPECT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch(
|
|
embedder_support::kOriginTrialPublicKey));
|
|
EXPECT_EQ(kBraveOriginTrialsPublicKey,
|
|
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
|
|
embedder_support::kOriginTrialPublicKey));
|
|
}
|