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" | |
5 #include "content/public/test/browser_test.h" | 7 #include "content/public/test/browser_test.h" |
6 #include "headless/public/devtools/domains/network.h" | 8 #include "headless/public/devtools/domains/network.h" |
7 #include "headless/public/devtools/domains/page.h" | 9 #include "headless/public/devtools/domains/page.h" |
8 #include "headless/public/headless_devtools_client.h" | 10 #include "headless/public/headless_devtools_client.h" |
9 #include "headless/public/util/expedited_dispatcher.h" | 11 #include "headless/public/util/expedited_dispatcher.h" |
10 #include "headless/public/util/generic_url_request_job.h" | 12 #include "headless/public/util/generic_url_request_job.h" |
11 #include "headless/public/util/url_fetcher.h" | 13 #include "headless/public/util/url_fetcher.h" |
12 #include "headless/test/headless_browser_test.h" | 14 #include "headless/test/headless_browser_test.h" |
13 #include "net/url_request/url_request_job_factory.h" | 15 #include "net/url_request/url_request_job_factory.h" |
14 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 })"; | 163 })"; |
162 | 164 |
163 } // namespace | 165 } // namespace |
164 | 166 |
165 class ProtocolHandlerRequestIdCorrelationTest | 167 class ProtocolHandlerRequestIdCorrelationTest |
166 : public HeadlessAsyncDevTooledBrowserTest, | 168 : public HeadlessAsyncDevTooledBrowserTest, |
167 public network::Observer, | 169 public network::Observer, |
168 public page::Observer { | 170 public page::Observer { |
169 public: | 171 public: |
170 void RunDevTooledTest() override { | 172 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 | |
171 EXPECT_TRUE(embedded_test_server()->Start()); | 180 EXPECT_TRUE(embedded_test_server()->Start()); |
172 devtools_client_->GetPage()->AddObserver(this); | 181 devtools_client_->GetPage()->AddObserver(this); |
173 devtools_client_->GetPage()->Enable(); | 182 devtools_client_->GetPage()->Enable(); |
183 | |
184 base::RunLoop run_loop; | |
174 devtools_client_->GetNetwork()->AddObserver(this); | 185 devtools_client_->GetNetwork()->AddObserver(this); |
175 devtools_client_->GetNetwork()->Enable(); | 186 devtools_client_->GetNetwork()->Enable(run_loop.QuitClosure()); |
187 base::MessageLoop::ScopedNestableTaskAllower nest_loop( | |
188 base::MessageLoop::current()); | |
189 run_loop.Run(); | |
nasko
2017/03/06 18:38:49
The explanation of why this is needed is at https:
| |
190 | |
176 devtools_client_->GetPage()->Navigate("http://foo.com/index.html"); | 191 devtools_client_->GetPage()->Navigate("http://foo.com/index.html"); |
177 } | 192 } |
178 | 193 |
179 ProtocolHandlerMap GetProtocolHandlers() override { | 194 ProtocolHandlerMap GetProtocolHandlers() override { |
180 ProtocolHandlerMap protocol_handlers; | 195 ProtocolHandlerMap protocol_handlers; |
181 std::unique_ptr<RequestIdCorrelationProtocolHandler> http_handler( | 196 std::unique_ptr<RequestIdCorrelationProtocolHandler> http_handler( |
182 new RequestIdCorrelationProtocolHandler(browser()->BrowserIOThread())); | 197 new RequestIdCorrelationProtocolHandler(browser()->BrowserIOThread())); |
183 http_handler_ = http_handler.get(); | 198 http_handler_ = http_handler.get(); |
184 http_handler_->InsertResponse("http://foo.com/index.html", | 199 http_handler_->InsertResponse("http://foo.com/index.html", |
185 {kIndexHtml, "text/html"}); | 200 {kIndexHtml, "text/html"}); |
(...skipping 23 matching lines...) Expand all Loading... | |
209 } | 224 } |
210 | 225 |
211 private: | 226 private: |
212 std::map<std::string, std::string> url_to_devtools_id_; | 227 std::map<std::string, std::string> url_to_devtools_id_; |
213 RequestIdCorrelationProtocolHandler* http_handler_; // NOT OWNED | 228 RequestIdCorrelationProtocolHandler* http_handler_; // NOT OWNED |
214 }; | 229 }; |
215 | 230 |
216 HEADLESS_ASYNC_DEVTOOLED_TEST_F(ProtocolHandlerRequestIdCorrelationTest); | 231 HEADLESS_ASYNC_DEVTOOLED_TEST_F(ProtocolHandlerRequestIdCorrelationTest); |
217 | 232 |
218 } // namespace headless | 233 } // namespace headless |
OLD | NEW |