OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
6 #include "base/optional.h" | 6 #include "base/optional.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 void RunMojoTest() override { | 227 void RunMojoTest() override { |
228 devtools_client_->GetNetwork()->AddObserver(this); | 228 devtools_client_->GetNetwork()->AddObserver(this); |
229 devtools_client_->GetNetwork()->Enable(); | 229 devtools_client_->GetNetwork()->Enable(); |
230 } | 230 } |
231 | 231 |
232 GURL GetInitialUrl() const override { | 232 GURL GetInitialUrl() const override { |
233 return embedded_test_server()->GetURL("/page_one.html"); | 233 return embedded_test_server()->GetURL("/page_one.html"); |
234 } | 234 } |
235 | 235 |
236 void ReturnTestResult(const std::string& result) override { | 236 void ReturnTestResult(const std::string& result) override { |
237 FinishAsynchronousTest(); | 237 DisableClientAndFinishAsynchronousTest(); |
238 FAIL() << "The HTTP page should not have been served and we should not have" | 238 FAIL() << "The HTTP page should not have been served and we should not have" |
239 " recieved a mojo callback!"; | 239 " recieved a mojo callback!"; |
240 } | 240 } |
241 | 241 |
242 void OnLoadingFailed(const network::LoadingFailedParams& params) override { | 242 void OnLoadingFailed(const network::LoadingFailedParams& params) override { |
243 // The navigation should fail since HTTP requests are blackholed. | 243 // The navigation should fail since HTTP requests are blackholed. |
244 EXPECT_EQ(params.GetErrorText(), "net::ERR_FILE_NOT_FOUND"); | 244 EXPECT_EQ(params.GetErrorText(), "net::ERR_FILE_NOT_FOUND"); |
| 245 DisableClientAndFinishAsynchronousTest(); |
| 246 } |
| 247 |
| 248 void DisableClientAndFinishAsynchronousTest() { |
| 249 devtools_client_->GetNetwork()->Disable(); |
| 250 devtools_client_->GetNetwork()->RemoveObserver(this); |
245 FinishAsynchronousTest(); | 251 FinishAsynchronousTest(); |
246 } | 252 } |
247 }; | 253 }; |
248 | 254 |
249 DEVTOOLS_CLIENT_TEST_F(HttpDisabledByDefaultWhenMojoBindingsUsed); | 255 DEVTOOLS_CLIENT_TEST_F(HttpDisabledByDefaultWhenMojoBindingsUsed); |
250 | 256 |
251 } // namespace headless | 257 } // namespace headless |
OLD | NEW |