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

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

Issue 2858643002: PS - Filtering activeTab URL (Closed)
Patch Set: ExtensionBuilder in test 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..4f400d0fcc066dec90941e7cb1a364fa244eb714 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
@@ -7,15 +7,31 @@
#include <string>
#include "chromeos/login/login_state.h"
+#include "chromeos/login/scoped_test_public_session_login_state.h"
+#include "extensions/common/extension.h"
+#include "extensions/common/extension_builder.h"
+#include "extensions/common/value_builder.h"
#include "testing/gtest/include/gtest/gtest.h"
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/";
+scoped_refptr<Extension> CreateExtension(const std::string& id) {
+ return ExtensionBuilder()
+ .SetManifest(
+ DictionaryBuilder().Set("name", "test").Set("version", "0.1").Build())
+ .SetID(id)
+ .Build();
+}
+
} // namespace
class ExtensionTabUtilDelegateChromeOSTest : public testing::Test {
@@ -30,25 +46,40 @@ 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_);
+ auto extension = CreateExtension(kWhitelistedId);
+ delegate_.ScrubTabForExtension(extension.get(), nullptr, &tab_);
EXPECT_EQ(kTestUrl, *tab_.url);
}
-TEST_F(ExtensionTabUtilDelegateChromeOSTest, ScrubURL) {
- // Set Public Session state.
- chromeos::LoginState::Initialize();
- chromeos::LoginState::Get()->SetLoggedInState(
- chromeos::LoginState::LOGGED_IN_ACTIVE,
- chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT);
+TEST_F(ExtensionTabUtilDelegateChromeOSTest,
+ NoFilteringOutsidePublicSessionForNonWhitelisted) {
+ ASSERT_FALSE(chromeos::LoginState::IsInitialized());
- delegate_.ScrubTabForExtension(nullptr, nullptr, &tab_);
- EXPECT_EQ(kFilteredUrl, *tab_.url);
+ auto extension = CreateExtension(kNonWhitelistedId);
+ delegate_.ScrubTabForExtension(extension.get(), nullptr, &tab_);
+ EXPECT_EQ(kTestUrl, *tab_.url);
+}
- // Reset state at the end of test.
- chromeos::LoginState::Shutdown();
+TEST_F(ExtensionTabUtilDelegateChromeOSTest,
+ NoFilteringInsidePublicSessionForWhitelisted) {
+ chromeos::ScopedTestPublicSessionLoginState state;
+
+ auto extension = CreateExtension(kWhitelistedId);
+ delegate_.ScrubTabForExtension(extension.get(), nullptr, &tab_);
+ EXPECT_EQ(kTestUrl, *tab_.url);
+}
+
+TEST_F(ExtensionTabUtilDelegateChromeOSTest,
+ FilterInsidePublicSessionNonWhitelisted) {
+ chromeos::ScopedTestPublicSessionLoginState state;
+
+ auto extension = CreateExtension(kNonWhitelistedId);
+ delegate_.ScrubTabForExtension(extension.get(), nullptr, &tab_);
+ EXPECT_EQ(kFilteredUrl, *tab_.url);
}
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698