-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test for this change: HistoryUtilsTest.VariousURLTest
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
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,15 @@ | ||
/* 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/. */ | ||
|
||
#define CanAddURLToHistory CanAddURLToHistory_ChromiumImpl | ||
#include "../../../../../chrome/browser/history/history_utils.cc" // NOLINT | ||
#undef CanAddURLToHistory | ||
|
||
bool CanAddURLToHistory(const GURL& url) { | ||
if (!CanAddURLToHistory_ChromiumImpl(url)) | ||
return false; | ||
|
||
return !url.SchemeIs(content::kBraveUIScheme); | ||
} |
36 changes: 36 additions & 0 deletions
36
chromium_src/chrome/browser/history/history_utils_unittest.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,36 @@ | ||
/* 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 "chrome/browser/history/history_utils.h" | ||
#include "components/previews/core/previews_experiments.h" | ||
#include "net/base/url_util.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
#include "url/gurl.h" | ||
|
||
namespace { | ||
// Refered IsLitePageRedirectPreviewDomain() to make sample lite page url. | ||
GURL GetSampleLitePageUrl() { | ||
return net::AppendQueryParameter( | ||
previews::params::GetLitePagePreviewsDomainURL(), | ||
"u", "1234"); | ||
} | ||
} // namespace | ||
|
||
// This test covers all cases that upstream and our version of | ||
// CanAddURLToHistory(). | ||
TEST(HistoryUtilsTest, VariousURLTest) { | ||
EXPECT_TRUE(CanAddURLToHistory(GURL("https://www.brave.com/"))); | ||
EXPECT_FALSE(CanAddURLToHistory(GURL("brave://sync/"))); | ||
EXPECT_FALSE(CanAddURLToHistory(GURL("javascript://test"))); | ||
EXPECT_FALSE(CanAddURLToHistory(GURL("about://test"))); | ||
EXPECT_FALSE(CanAddURLToHistory(GURL("content://test"))); | ||
EXPECT_FALSE(CanAddURLToHistory(GURL("chrome-devtools://test"))); | ||
EXPECT_FALSE(CanAddURLToHistory(GURL("chrome://test"))); | ||
EXPECT_FALSE(CanAddURLToHistory(GURL("view-source://test"))); | ||
EXPECT_FALSE(CanAddURLToHistory(GURL("chrome-native://test"))); | ||
EXPECT_FALSE(CanAddURLToHistory(GURL("chrome-search://test"))); | ||
EXPECT_FALSE(CanAddURLToHistory(GURL("chrome-distiller://test"))); | ||
EXPECT_FALSE(CanAddURLToHistory(GetSampleLitePageUrl())); | ||
} |
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