| 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/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/string_piece.h" | 9 #include "base/strings/string_piece.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 host_resolver_rules_ = | 188 host_resolver_rules_ = |
| 189 base::StringPrintf("MAP not-an-actual-domain.tld 127.0.0.1:%d", | 189 base::StringPrintf("MAP not-an-actual-domain.tld 127.0.0.1:%d", |
| 190 embedded_test_server()->host_port_pair().port()); | 190 embedded_test_server()->host_port_pair().port()); |
| 191 | 191 |
| 192 EmbedderMojoTest::SetUpOnMainThread(); | 192 EmbedderMojoTest::SetUpOnMainThread(); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void RunMojoTest() override {} | 195 void RunMojoTest() override {} |
| 196 | 196 |
| 197 GURL GetInitialUrl() const override { | 197 GURL GetInitialUrl() const override { |
| 198 return embedded_test_server()->GetURL("/page_one.html"); | 198 return embedded_test_server()->GetURL("/mojo_page_one.html"); |
| 199 } | 199 } |
| 200 | 200 |
| 201 // embedder_test::TestEmbedderService: | 201 // embedder_test::TestEmbedderService: |
| 202 void ReturnTestResult(const std::string& result) override { | 202 void ReturnTestResult(const std::string& result) override { |
| 203 if (result == "page one") { | 203 if (result == "page one") { |
| 204 seen_page_one_ = true; | 204 seen_page_one_ = true; |
| 205 devtools_client_->GetPage()->Navigate( | 205 devtools_client_->GetPage()->Navigate( |
| 206 "http://not-an-actual-domain.tld/page_two.html"); | 206 "http://not-an-actual-domain.tld/mojo_page_two.html"); |
| 207 } else { | 207 } else { |
| 208 EXPECT_TRUE(seen_page_one_); | 208 EXPECT_TRUE(seen_page_one_); |
| 209 EXPECT_EQ("page two", result); | 209 EXPECT_EQ("page two", result); |
| 210 FinishAsynchronousTest(); | 210 FinishAsynchronousTest(); |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| 214 private: | 214 private: |
| 215 bool seen_page_one_; | 215 bool seen_page_one_; |
| 216 }; | 216 }; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 228 void RunMojoTest() override { | 228 void RunMojoTest() override { |
| 229 base::RunLoop run_loop; | 229 base::RunLoop run_loop; |
| 230 devtools_client_->GetNetwork()->AddObserver(this); | 230 devtools_client_->GetNetwork()->AddObserver(this); |
| 231 devtools_client_->GetNetwork()->Enable(run_loop.QuitClosure()); | 231 devtools_client_->GetNetwork()->Enable(run_loop.QuitClosure()); |
| 232 base::MessageLoop::ScopedNestableTaskAllower nest_loop( | 232 base::MessageLoop::ScopedNestableTaskAllower nest_loop( |
| 233 base::MessageLoop::current()); | 233 base::MessageLoop::current()); |
| 234 run_loop.Run(); | 234 run_loop.Run(); |
| 235 devtools_client_->GetPage()->AddObserver(this); | 235 devtools_client_->GetPage()->AddObserver(this); |
| 236 devtools_client_->GetPage()->Enable(); | 236 devtools_client_->GetPage()->Enable(); |
| 237 devtools_client_->GetPage()->Navigate( | 237 devtools_client_->GetPage()->Navigate( |
| 238 embedded_test_server()->GetURL("/page_one.html").spec()); | 238 embedded_test_server()->GetURL("/mojo_page_one.html").spec()); |
| 239 } | 239 } |
| 240 | 240 |
| 241 void ReturnTestResult(const std::string& result) override { | 241 void ReturnTestResult(const std::string& result) override { |
| 242 DisableClientAndFinishAsynchronousTest(); | 242 DisableClientAndFinishAsynchronousTest(); |
| 243 FAIL() << "The HTTP page should not have been served and we should not have" | 243 FAIL() << "The HTTP page should not have been served and we should not have" |
| 244 " recieved a mojo callback!"; | 244 " recieved a mojo callback!"; |
| 245 } | 245 } |
| 246 | 246 |
| 247 void OnLoadingFailed(const network::LoadingFailedParams& params) override { | 247 void OnLoadingFailed(const network::LoadingFailedParams& params) override { |
| 248 // The navigation should fail since HTTP requests are blackholed. | 248 // The navigation should fail since HTTP requests are blackholed. |
| 249 EXPECT_EQ(params.GetErrorText(), "net::ERR_FILE_NOT_FOUND"); | 249 EXPECT_EQ(params.GetErrorText(), "net::ERR_FILE_NOT_FOUND"); |
| 250 DisableClientAndFinishAsynchronousTest(); | 250 DisableClientAndFinishAsynchronousTest(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 void DisableClientAndFinishAsynchronousTest() { | 253 void DisableClientAndFinishAsynchronousTest() { |
| 254 devtools_client_->GetNetwork()->Disable(); | 254 devtools_client_->GetNetwork()->Disable(); |
| 255 devtools_client_->GetNetwork()->RemoveObserver(this); | 255 devtools_client_->GetNetwork()->RemoveObserver(this); |
| 256 FinishAsynchronousTest(); | 256 FinishAsynchronousTest(); |
| 257 } | 257 } |
| 258 }; | 258 }; |
| 259 | 259 |
| 260 DEVTOOLS_CLIENT_TEST_F(HttpDisabledByDefaultWhenMojoBindingsUsed); | 260 DEVTOOLS_CLIENT_TEST_F(HttpDisabledByDefaultWhenMojoBindingsUsed); |
| 261 | 261 |
| 262 } // namespace headless | 262 } // namespace headless |
| OLD | NEW |