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

Unified Diff: chrome/browser/net/chrome_network_delegate_unittest.cc

Issue 940373002: First-Party Cookies: Wire it up as an experimental web platform feature (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@first-party
Patch Set: Created 5 years, 10 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/net/chrome_network_delegate_unittest.cc
diff --git a/chrome/browser/net/chrome_network_delegate_unittest.cc b/chrome/browser/net/chrome_network_delegate_unittest.cc
index 4b722dd325fab760787b7b6d480f850cb835e510..d542e40c7fdb03572135b03e9f67f5a0dcc99733 100644
--- a/chrome/browser/net/chrome_network_delegate_unittest.cc
+++ b/chrome/browser/net/chrome_network_delegate_unittest.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/net/chrome_network_delegate.h"
+#include "base/command_line.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
@@ -13,6 +14,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_pref_service_syncable.h"
#include "chrome/test/base/testing_profile.h"
+#include "content/public/common/content_switches.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "net/base/request_priority.h"
#include "net/url_request/url_request.h"
@@ -23,11 +25,13 @@
#include "chrome/browser/extensions/event_router_forwarder.h"
#endif
-#if defined(ENABLE_EXTENSIONS)
class ChromeNetworkDelegateTest : public testing::Test {
protected:
ChromeNetworkDelegateTest()
- : forwarder_(new extensions::EventRouterForwarder()) {
+#if defined(ENABLE_EXTENSIONS)
+ : forwarder_(new extensions::EventRouterForwarder())
+#endif
+ {
}
void SetUp() override {
@@ -43,9 +47,10 @@ class ChromeNetworkDelegateTest : public testing::Test {
scoped_ptr<ChromeNetworkDelegate> CreateNetworkDelegate() {
return make_scoped_ptr(
- new ChromeNetworkDelegate(forwarder_.get(), &pref_member_));
+ new ChromeNetworkDelegate(forwarder(), &pref_member_));
}
+#if defined(ENABLE_EXTENSIONS)
// Implementation moved here for access to private bits.
void NeverThrottleLogicImpl() {
scoped_ptr<ChromeNetworkDelegate> delegate(CreateNetworkDelegate());
@@ -79,20 +84,41 @@ class ChromeNetworkDelegateTest : public testing::Test {
ASSERT_FALSE(delegate->OnCanThrottleRequest(*extension_request));
ASSERT_FALSE(delegate->OnCanThrottleRequest(*web_page_request));
}
+#endif
private:
+ extensions::EventRouterForwarder* forwarder() {
+#if defined(ENABLE_EXTENSIONS)
mmenke 2015/02/20 16:30:39 All these ifdefs seem ugly, and this setup all see
Mike West 2015/02/23 15:51:17 I either have ifdefs here, or in the new test, as
+ return forwarder_.get();
+#else
+ return NULL;
+#endif
+ }
+
bool never_throttle_requests_original_value_;
base::MessageLoopForIO message_loop_;
+#if defined(ENABLE_EXTENSIONS)
scoped_refptr<extensions::EventRouterForwarder> forwarder_;
+#endif
BooleanPrefMember pref_member_;
};
+#if defined(ENABLE_EXTENSIONS)
TEST_F(ChromeNetworkDelegateTest, NeverThrottleLogic) {
NeverThrottleLogicImpl();
}
#endif // defined(ENABLE_EXTENSIONS)
+TEST_F(ChromeNetworkDelegateTest, EnableFirstPartyCookiesIffFlagEnabled) {
+ scoped_ptr<ChromeNetworkDelegate> delegate(CreateNetworkDelegate());
+
+ // Off by default, on if the switch is present.
+ EXPECT_FALSE(delegate->FirstPartyCookieExperimentEnabled());
+ delegate->SetExperimentalWebPlatformFeaturesEnabled();
+ EXPECT_TRUE(delegate->FirstPartyCookieExperimentEnabled());
+}
+
class ChromeNetworkDelegateSafeSearchTest : public testing::Test {
public:
ChromeNetworkDelegateSafeSearchTest()
@@ -313,4 +339,3 @@ TEST_F(ChromeNetworkDelegatePrivacyModeTest,
EXPECT_FALSE(network_delegate_->CanEnablePrivacyMode(kAllowedSite,
kBlockedFirstPartySite));
}
-

Powered by Google App Engine
This is Rietveld 408576698