| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/run_loop.h" | |
| 6 #include "content/public/common/browser_side_navigation_policy.h" | |
| 7 #include "content/public/test/browser_test.h" | 5 #include "content/public/test/browser_test.h" |
| 8 #include "headless/public/devtools/domains/network.h" | 6 #include "headless/public/devtools/domains/network.h" |
| 9 #include "headless/public/devtools/domains/page.h" | 7 #include "headless/public/devtools/domains/page.h" |
| 10 #include "headless/public/headless_devtools_client.h" | 8 #include "headless/public/headless_devtools_client.h" |
| 11 #include "headless/public/util/expedited_dispatcher.h" | 9 #include "headless/public/util/expedited_dispatcher.h" |
| 12 #include "headless/public/util/generic_url_request_job.h" | 10 #include "headless/public/util/generic_url_request_job.h" |
| 13 #include "headless/public/util/url_fetcher.h" | 11 #include "headless/public/util/url_fetcher.h" |
| 14 #include "headless/test/headless_browser_test.h" | 12 #include "headless/test/headless_browser_test.h" |
| 15 #include "net/url_request/url_request_job_factory.h" | 13 #include "net/url_request/url_request_job_factory.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 })"; | 161 })"; |
| 164 | 162 |
| 165 } // namespace | 163 } // namespace |
| 166 | 164 |
| 167 class ProtocolHandlerRequestIdCorrelationTest | 165 class ProtocolHandlerRequestIdCorrelationTest |
| 168 : public HeadlessAsyncDevTooledBrowserTest, | 166 : public HeadlessAsyncDevTooledBrowserTest, |
| 169 public network::Observer, | 167 public network::Observer, |
| 170 public page::Observer { | 168 public page::Observer { |
| 171 public: | 169 public: |
| 172 void RunDevTooledTest() override { | 170 void RunDevTooledTest() override { |
| 173 if (content::IsBrowserSideNavigationEnabled()) { | |
| 174 // TODO: get this working with PlzNavigate. | |
| 175 // See discussion on https://codereview.chromium.org/2695923010/ | |
| 176 FinishAsynchronousTest(); | |
| 177 return; | |
| 178 } | |
| 179 | |
| 180 EXPECT_TRUE(embedded_test_server()->Start()); | 171 EXPECT_TRUE(embedded_test_server()->Start()); |
| 181 devtools_client_->GetPage()->AddObserver(this); | 172 devtools_client_->GetPage()->AddObserver(this); |
| 182 devtools_client_->GetPage()->Enable(); | 173 devtools_client_->GetPage()->Enable(); |
| 183 | |
| 184 base::RunLoop run_loop; | |
| 185 devtools_client_->GetNetwork()->AddObserver(this); | 174 devtools_client_->GetNetwork()->AddObserver(this); |
| 186 devtools_client_->GetNetwork()->Enable(run_loop.QuitClosure()); | 175 devtools_client_->GetNetwork()->Enable(); |
| 187 base::MessageLoop::ScopedNestableTaskAllower nest_loop( | |
| 188 base::MessageLoop::current()); | |
| 189 run_loop.Run(); | |
| 190 | |
| 191 devtools_client_->GetPage()->Navigate("http://foo.com/index.html"); | 176 devtools_client_->GetPage()->Navigate("http://foo.com/index.html"); |
| 192 } | 177 } |
| 193 | 178 |
| 194 ProtocolHandlerMap GetProtocolHandlers() override { | 179 ProtocolHandlerMap GetProtocolHandlers() override { |
| 195 ProtocolHandlerMap protocol_handlers; | 180 ProtocolHandlerMap protocol_handlers; |
| 196 std::unique_ptr<RequestIdCorrelationProtocolHandler> http_handler( | 181 std::unique_ptr<RequestIdCorrelationProtocolHandler> http_handler( |
| 197 new RequestIdCorrelationProtocolHandler(browser()->BrowserIOThread())); | 182 new RequestIdCorrelationProtocolHandler(browser()->BrowserIOThread())); |
| 198 http_handler_ = http_handler.get(); | 183 http_handler_ = http_handler.get(); |
| 199 http_handler_->InsertResponse("http://foo.com/index.html", | 184 http_handler_->InsertResponse("http://foo.com/index.html", |
| 200 {kIndexHtml, "text/html"}); | 185 {kIndexHtml, "text/html"}); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 224 } | 209 } |
| 225 | 210 |
| 226 private: | 211 private: |
| 227 std::map<std::string, std::string> url_to_devtools_id_; | 212 std::map<std::string, std::string> url_to_devtools_id_; |
| 228 RequestIdCorrelationProtocolHandler* http_handler_; // NOT OWNED | 213 RequestIdCorrelationProtocolHandler* http_handler_; // NOT OWNED |
| 229 }; | 214 }; |
| 230 | 215 |
| 231 HEADLESS_ASYNC_DEVTOOLED_TEST_F(ProtocolHandlerRequestIdCorrelationTest); | 216 HEADLESS_ASYNC_DEVTOOLED_TEST_F(ProtocolHandlerRequestIdCorrelationTest); |
| 232 | 217 |
| 233 } // namespace headless | 218 } // namespace headless |
| OLD | NEW |