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

Side by Side Diff: headless/lib/embedder_mojo_browsertest.cc

Issue 2720543002: Fix headless_browsertests failures with PlzNavigate. (Closed)
Patch Set: review comments 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 unified diff | Download patch
OLDNEW
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/strings/string_piece.h" 9 #include "base/strings/string_piece.h"
9 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
10 #include "base/threading/thread_restrictions.h" 11 #include "base/threading/thread_restrictions.h"
11 #include "content/public/test/browser_test.h" 12 #include "content/public/test/browser_test.h"
12 #include "headless/grit/headless_browsertest_resources.h" 13 #include "headless/grit/headless_browsertest_resources.h"
13 #include "headless/lib/embedder_test.mojom.h" 14 #include "headless/lib/embedder_test.mojom.h"
14 #include "headless/public/devtools/domains/network.h" 15 #include "headless/public/devtools/domains/network.h"
15 #include "headless/public/devtools/domains/page.h" 16 #include "headless/public/devtools/domains/page.h"
16 #include "headless/public/devtools/domains/runtime.h" 17 #include "headless/public/devtools/domains/runtime.h"
17 #include "headless/public/headless_browser.h" 18 #include "headless/public/headless_browser.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 219
219 class HttpDisabledByDefaultWhenMojoBindingsUsed : public EmbedderMojoTest, 220 class HttpDisabledByDefaultWhenMojoBindingsUsed : public EmbedderMojoTest,
220 network::Observer, 221 network::Observer,
221 page::Observer { 222 page::Observer {
222 public: 223 public:
223 HttpDisabledByDefaultWhenMojoBindingsUsed() { 224 HttpDisabledByDefaultWhenMojoBindingsUsed() {
224 EXPECT_TRUE(embedded_test_server()->Start()); 225 EXPECT_TRUE(embedded_test_server()->Start());
225 } 226 }
226 227
227 void RunMojoTest() override { 228 void RunMojoTest() override {
229 base::RunLoop run_loop;
228 devtools_client_->GetNetwork()->AddObserver(this); 230 devtools_client_->GetNetwork()->AddObserver(this);
229 devtools_client_->GetNetwork()->Enable(); 231 devtools_client_->GetNetwork()->Enable(run_loop.QuitClosure());
230 } 232 base::MessageLoop::ScopedNestableTaskAllower nest_loop(
231 233 base::MessageLoop::current());
232 GURL GetInitialUrl() const override { 234 run_loop.Run();
233 return embedded_test_server()->GetURL("/page_one.html"); 235 devtools_client_->GetPage()->AddObserver(this);
236 devtools_client_->GetPage()->Enable();
237 devtools_client_->GetPage()->Navigate(
238 embedded_test_server()->GetURL("/page_one.html").spec());
234 } 239 }
235 240
236 void ReturnTestResult(const std::string& result) override { 241 void ReturnTestResult(const std::string& result) override {
237 DisableClientAndFinishAsynchronousTest(); 242 DisableClientAndFinishAsynchronousTest();
238 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"
239 " recieved a mojo callback!"; 244 " recieved a mojo callback!";
240 } 245 }
241 246
242 void OnLoadingFailed(const network::LoadingFailedParams& params) override { 247 void OnLoadingFailed(const network::LoadingFailedParams& params) override {
243 // The navigation should fail since HTTP requests are blackholed. 248 // The navigation should fail since HTTP requests are blackholed.
244 EXPECT_EQ(params.GetErrorText(), "net::ERR_FILE_NOT_FOUND"); 249 EXPECT_EQ(params.GetErrorText(), "net::ERR_FILE_NOT_FOUND");
245 DisableClientAndFinishAsynchronousTest(); 250 DisableClientAndFinishAsynchronousTest();
246 } 251 }
247 252
248 void DisableClientAndFinishAsynchronousTest() { 253 void DisableClientAndFinishAsynchronousTest() {
249 devtools_client_->GetNetwork()->Disable(); 254 devtools_client_->GetNetwork()->Disable();
250 devtools_client_->GetNetwork()->RemoveObserver(this); 255 devtools_client_->GetNetwork()->RemoveObserver(this);
251 FinishAsynchronousTest(); 256 FinishAsynchronousTest();
252 } 257 }
253 }; 258 };
254 259
255 DEVTOOLS_CLIENT_TEST_F(HttpDisabledByDefaultWhenMojoBindingsUsed); 260 DEVTOOLS_CLIENT_TEST_F(HttpDisabledByDefaultWhenMojoBindingsUsed);
256 261
257 } // namespace headless 262 } // namespace headless
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | headless/lib/headless_browser_context_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698