Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Unified Diff: chrome/browser/chromeos/extensions/extension_tab_util_delegate_chromeos_unittest.cc

Issue 2858643002: PS - Filtering activeTab URL (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/extensions/extension_tab_util_delegate_chromeos_unittest.cc
diff --git a/chrome/browser/chromeos/extensions/extension_tab_util_delegate_chromeos_unittest.cc b/chrome/browser/chromeos/extensions/extension_tab_util_delegate_chromeos_unittest.cc
index 9ded86efc10967c5cc86e16b1e69f743f309dfef..7b441e387d950ac2feaed31cfc82009e409be8aa 100644
--- a/chrome/browser/chromeos/extensions/extension_tab_util_delegate_chromeos_unittest.cc
+++ b/chrome/browser/chromeos/extensions/extension_tab_util_delegate_chromeos_unittest.cc
@@ -13,6 +13,10 @@ namespace extensions {
namespace {
+const char kWhitelistedId[] = "cbkkbcmdlboombapidmoeolnmdacpkch";
+// Use an extension ID that will never be whitelisted.
+const char kNonWhitelistedId[] = "bogus";
+
const char kTestUrl[] = "http://www.foo.bar/baz?key=val";
const char kFilteredUrl[] = "http://www.foo.bar/";
@@ -30,21 +34,46 @@ void ExtensionTabUtilDelegateChromeOSTest::SetUp() {
tab_.url.reset(new std::string(kTestUrl));
}
-TEST_F(ExtensionTabUtilDelegateChromeOSTest, NoFilteringOutsidePublicSession) {
+TEST_F(ExtensionTabUtilDelegateChromeOSTest,
+ NoFilteringOutsidePublicSessionForWhitelisted) {
ASSERT_FALSE(chromeos::LoginState::IsInitialized());
- delegate_.ScrubTabForExtension(nullptr, nullptr, &tab_);
+ delegate_.ScrubTabForExtension(kWhitelistedId, &tab_);
+ EXPECT_EQ(kTestUrl, *tab_.url);
+}
+
+TEST_F(ExtensionTabUtilDelegateChromeOSTest,
+ NoFilteringOutsidePublicSessionForNonWhitelisted) {
+ ASSERT_FALSE(chromeos::LoginState::IsInitialized());
+
+ delegate_.ScrubTabForExtension(kNonWhitelistedId, &tab_);
+ EXPECT_EQ(kTestUrl, *tab_.url);
+}
+
+TEST_F(ExtensionTabUtilDelegateChromeOSTest,
+ NoFilteringInsidePublicSessionForWhitelisted) {
+ // Set Public Session state.
+ chromeos::LoginState::Initialize();
+ chromeos::LoginState::Get()->SetLoggedInState(
+ chromeos::LoginState::LOGGED_IN_ACTIVE,
Devlin 2017/05/03 15:14:15 drive-by: indentation looks off here.
+ chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT);
+
+ delegate_.ScrubTabForExtension(kWhitelistedId, &tab_);
EXPECT_EQ(kTestUrl, *tab_.url);
+
+ // Reset state at the end of test.
+ chromeos::LoginState::Shutdown();
}
-TEST_F(ExtensionTabUtilDelegateChromeOSTest, ScrubURL) {
+TEST_F(ExtensionTabUtilDelegateChromeOSTest,
+ FilterInsidePublicSessionNonWhitelisted) {
// Set Public Session state.
chromeos::LoginState::Initialize();
Devlin 2017/05/03 15:14:15 This pattern: chromeos::LoginState::Initialize();
Ivan Šandrk 2017/05/03 17:52:46 Yes, perfect! Done. Logged a bug for myself to re
chromeos::LoginState::Get()->SetLoggedInState(
Devlin 2017/05/03 15:14:15 ditto re indentation
chromeos::LoginState::LOGGED_IN_ACTIVE,
chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT);
- delegate_.ScrubTabForExtension(nullptr, nullptr, &tab_);
+ delegate_.ScrubTabForExtension(kNonWhitelistedId, &tab_);
EXPECT_EQ(kFilteredUrl, *tab_.url);
// Reset state at the end of test.

Powered by Google App Engine
This is Rietveld 408576698