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

Unified Diff: headless/lib/headless_devtools_client_browsertest.cc

Issue 2748743002: Headless: Strip X-DevTools-Emulate-Network-Conditions-Client-Id (Closed)
Patch Set: Change capitalization Created 3 years, 9 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
« no previous file with comments | « headless/lib/browser/headless_url_request_context_getter.cc ('k') | headless/test/test_protocol_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/lib/headless_devtools_client_browsertest.cc
diff --git a/headless/lib/headless_devtools_client_browsertest.cc b/headless/lib/headless_devtools_client_browsertest.cc
index 3783183459b045723a4d6f5fd18d988fac69c899..7c58943e32b477facfe031185c6486c78f7f7f2f 100644
--- a/headless/lib/headless_devtools_client_browsertest.cc
+++ b/headless/lib/headless_devtools_client_browsertest.cc
@@ -22,6 +22,7 @@
#include "headless/public/headless_devtools_client.h"
#include "headless/public/headless_devtools_target.h"
#include "headless/test/headless_browser_test.h"
+#include "headless/test/test_protocol_handler.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
@@ -885,4 +886,51 @@ class HeadlessDevToolsNetworkBlockedUrlTest
HEADLESS_ASYNC_DEVTOOLED_TEST_F(HeadlessDevToolsNetworkBlockedUrlTest);
+namespace {
+// Keep in sync with X_DevTools_Emulate_Network_Conditions_Client_Id defined in
+// HTTPNames.json5.
+const char kDevToolsEmulateNetworkConditionsClientId[] =
+ "X-DevTools-Emulate-Network-Conditions-Client-Id";
+} // namespace
+
+class DevToolsHeaderStrippingTest : public HeadlessAsyncDevTooledBrowserTest,
+ public page::Observer,
+ public network::Observer {
+ void RunDevTooledTest() override {
+ EXPECT_TRUE(embedded_test_server()->Start());
+ base::RunLoop run_loop;
+ devtools_client_->GetPage()->AddObserver(this);
+ devtools_client_->GetPage()->Enable();
+ // Enable network domain in order to get DevTools to add the header.
+ devtools_client_->GetNetwork()->AddObserver(this);
+ devtools_client_->GetNetwork()->Enable(run_loop.QuitClosure());
+ base::MessageLoop::ScopedNestableTaskAllower nest_loop(
+ base::MessageLoop::current());
+ run_loop.Run();
+ devtools_client_->GetPage()->Navigate(
+ "http://not-an-actual-domain.tld/hello.html");
+ }
+
+ ProtocolHandlerMap GetProtocolHandlers() override {
+ const std::string kResponseBody = "<p>HTTP response body</p>";
+ ProtocolHandlerMap protocol_handlers;
+ protocol_handlers[url::kHttpScheme] =
+ base::MakeUnique<TestProtocolHandler>(kResponseBody);
+ test_handler_ = static_cast<TestProtocolHandler*>(
+ protocol_handlers[url::kHttpScheme].get());
+ return protocol_handlers;
+ }
+
+ void OnLoadEventFired(const page::LoadEventFiredParams&) override {
+ EXPECT_FALSE(test_handler_->last_http_request_headers().IsEmpty());
+ EXPECT_FALSE(test_handler_->last_http_request_headers().HasHeader(
+ kDevToolsEmulateNetworkConditionsClientId));
+ FinishAsynchronousTest();
+ }
+
+ TestProtocolHandler* test_handler_; // NOT OWNED
+};
+
+HEADLESS_ASYNC_DEVTOOLED_TEST_F(DevToolsHeaderStrippingTest);
+
} // namespace headless
« no previous file with comments | « headless/lib/browser/headless_url_request_context_getter.cc ('k') | headless/test/test_protocol_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698