Skip to content

Commit 38d5297

Browse files
committed
Add TorDisabled test case
1 parent ed63cdf commit 38d5297

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

browser/tor/onion_location_navigation_throttle_browsertest.cc

+28
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "base/strings/utf_string_conversions.h"
77
#include "brave/browser/profiles/profile_util.h"
88
#include "brave/browser/tor/onion_location_tab_helper.h"
9+
#include "brave/browser/tor/tor_profile_service.h"
910
#include "brave/browser/ui/browser_commands.h"
1011
#include "brave/browser/ui/views/brave_actions/brave_actions_container.h"
1112
#include "brave/browser/ui/views/location_bar/brave_location_bar_view.h"
@@ -165,3 +166,30 @@ IN_PROC_BROWSER_TEST_F(OnionLocationNavigationThrottleBrowserTest,
165166
browser_list->get(1)->tab_strip_model()->GetActiveWebContents();
166167
EXPECT_EQ(web_contents->GetURL(), GURL(kTestOnionURL));
167168
}
169+
170+
IN_PROC_BROWSER_TEST_F(OnionLocationNavigationThrottleBrowserTest,
171+
TorDisabled) {
172+
// Disable tor
173+
tor::TorProfileService::SetTorDisabled(true);
174+
175+
// OnionLocationHeader_
176+
GURL url = test_server()->GetURL("/onion");
177+
ui_test_utils::NavigateToURL(browser(), url);
178+
content::WebContents* web_contents =
179+
browser()->tab_strip_model()->GetActiveWebContents();
180+
tor::OnionLocationTabHelper* helper =
181+
tor::OnionLocationTabHelper::FromWebContents(web_contents);
182+
EXPECT_FALSE(helper->should_show_icon());
183+
EXPECT_TRUE(helper->onion_location().is_empty());
184+
185+
// Onion Domain
186+
ui_test_utils::NavigateToURL(browser(), GURL(kTestOnionURL));
187+
BrowserList* browser_list = BrowserList::GetInstance();
188+
EXPECT_EQ(1U, browser_list->size());
189+
190+
// AutoOnionLocationPref
191+
browser()->profile()->GetPrefs()->SetBoolean(tor::prefs::kAutoOnionLocation,
192+
true);
193+
ui_test_utils::NavigateToURL(browser(), url);
194+
EXPECT_EQ(1U, browser_list->size());
195+
}

0 commit comments

Comments
 (0)