GURL constructor uses scheme registry which now DCHECKs if accessed before being initialized with schemes. Converted BraveStatsUpdater::g_base_update_url_ to std::string. Converted SuggestedSitesProvider::suggested_sites_ to method local static. Converted oauth_url in binance_service.cc to const char[]. Also, moved inside functions in several unit tests. Chromium change: https://chromium.googlesource.com/chromium/src/+/2add7d44778f7be638639aeb26a3b14f0b222e09 commit 2add7d44778f7be638639aeb26a3b14f0b222e09 Author: Michael Thiessen <mthiesse@chromium.org> Date: Wed Feb 5 13:49:38 2020 +0000 Lock SchemeRegistry on first use. This change locks the SchemeRegistry on first use, which required refactoring url_util.cc to differentiate between SchemeRegistry use for adding Schemes, and SchemeRegistry use for using Schemes. Tests can now only modify schemes after initialization by calling url::UnlockForTests(), which creates a scoped object that resets the schemes, so tests can't mistakenly leave global scheme state modified. This change required changes to browser startup to decouple scheme registration from ContentMain, found here: https://chromium-review.googlesource.com/c/chromium/src/+/1945926 Doc: https://docs.google.com/document/d/1kDKqBaq-b6EbUm0F4ea7ARoksUcj1KUx3qxFuSXEwM4/edit Bug: 783819
30 lines
1.0 KiB
C++
30 lines
1.0 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 "brave/common/brave_content_client.h"
|
|
|
|
#include "content/common/url_schemes.h"
|
|
#include "content/public/common/url_constants.h"
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
|
#include "url/gurl.h"
|
|
#include "url/url_util.h"
|
|
|
|
TEST(BraveContentClientTest, AdditionalSchemesTest) {
|
|
url::ScopedSchemeRegistryForTests scoped_registry;
|
|
BraveContentClient content_client;
|
|
content::SetContentClient(&content_client);
|
|
content::ReRegisterContentSchemesForTests();
|
|
|
|
const GURL sync_url("brave://sync");
|
|
EXPECT_TRUE(sync_url.is_valid());
|
|
EXPECT_TRUE(sync_url.has_host());
|
|
EXPECT_EQ("sync", sync_url.host());
|
|
|
|
const GURL chrome_sync_url("chrome://sync");
|
|
EXPECT_TRUE(chrome_sync_url.is_valid());
|
|
EXPECT_TRUE(chrome_sync_url.has_host());
|
|
EXPECT_EQ("sync", chrome_sync_url.host());
|
|
}
|