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

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

Issue 2830903003: PS - Scrub URL down to origin in Public Sessions (Closed)
Patch Set: Rebase 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
new file mode 100644
index 0000000000000000000000000000000000000000..9ded86efc10967c5cc86e16b1e69f743f309dfef
--- /dev/null
+++ b/chrome/browser/chromeos/extensions/extension_tab_util_delegate_chromeos_unittest.cc
@@ -0,0 +1,54 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/extensions/extension_tab_util_delegate_chromeos.h"
+
+#include <string>
+
+#include "chromeos/login/login_state.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace extensions {
+
+namespace {
+
+const char kTestUrl[] = "http://www.foo.bar/baz?key=val";
+const char kFilteredUrl[] = "http://www.foo.bar/";
+
+} // namespace
+
+class ExtensionTabUtilDelegateChromeOSTest : public testing::Test {
+ protected:
+ void SetUp() override;
+
+ ExtensionTabUtilDelegateChromeOS delegate_;
+ api::tabs::Tab tab_;
+};
+
+void ExtensionTabUtilDelegateChromeOSTest::SetUp() {
+ tab_.url.reset(new std::string(kTestUrl));
+}
+
+TEST_F(ExtensionTabUtilDelegateChromeOSTest, NoFilteringOutsidePublicSession) {
+ ASSERT_FALSE(chromeos::LoginState::IsInitialized());
+
+ delegate_.ScrubTabForExtension(nullptr, 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);
+
+ delegate_.ScrubTabForExtension(nullptr, nullptr, &tab_);
+ EXPECT_EQ(kFilteredUrl, *tab_.url);
+
+ // Reset state at the end of test.
+ chromeos::LoginState::Shutdown();
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698