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

Side by Side Diff: chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc

Issue 2190463008: Add an error page for HTTP 404 error pages without bodies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switch runtime test to title1.html Created 4 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <list> 5 #include <list>
6 #include <set> 6 #include <set>
7 7
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "content/public/common/context_menu_params.h" 43 #include "content/public/common/context_menu_params.h"
44 #include "content/public/common/resource_type.h" 44 #include "content/public/common/resource_type.h"
45 #include "content/public/common/url_constants.h" 45 #include "content/public/common/url_constants.h"
46 #include "content/public/test/browser_test_utils.h" 46 #include "content/public/test/browser_test_utils.h"
47 #include "content/public/test/test_utils.h" 47 #include "content/public/test/test_utils.h"
48 #include "extensions/browser/extension_system.h" 48 #include "extensions/browser/extension_system.h"
49 #include "extensions/common/switches.h" 49 #include "extensions/common/switches.h"
50 #include "extensions/test/result_catcher.h" 50 #include "extensions/test/result_catcher.h"
51 #include "net/dns/mock_host_resolver.h" 51 #include "net/dns/mock_host_resolver.h"
52 #include "net/test/embedded_test_server/embedded_test_server.h" 52 #include "net/test/embedded_test_server/embedded_test_server.h"
53 #include "net/test/embedded_test_server/http_request.h"
54 #include "net/test/embedded_test_server/http_response.h"
53 #include "third_party/WebKit/public/web/WebContextMenuData.h" 55 #include "third_party/WebKit/public/web/WebContextMenuData.h"
54 #include "third_party/WebKit/public/web/WebInputEvent.h" 56 #include "third_party/WebKit/public/web/WebInputEvent.h"
55 57
56 using content::ResourceType; 58 using content::ResourceType;
57 using content::WebContents; 59 using content::WebContents;
58 60
59 namespace extensions { 61 namespace extensions {
60 62
61 namespace { 63 namespace {
62 64
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 if (throttle) 325 if (throttle)
324 throttles->push_back(throttle); 326 throttles->push_back(throttle);
325 } 327 }
326 328
327 private: 329 private:
328 scoped_refptr<TestNavigationListener> test_navigation_listener_; 330 scoped_refptr<TestNavigationListener> test_navigation_listener_;
329 331
330 DISALLOW_COPY_AND_ASSIGN(TestResourceDispatcherHostDelegate); 332 DISALLOW_COPY_AND_ASSIGN(TestResourceDispatcherHostDelegate);
331 }; 333 };
332 334
335 // Handles requests for URLs with paths of "/test*" sent to the test server, so
336 // tests request a URL that receives a non-error response.
337 std::unique_ptr<net::test_server::HttpResponse> HandleTestRequest(
338 const net::test_server::HttpRequest& request) {
339 if (!base::StartsWith(request.relative_url, "/test",
340 base::CompareCase::SENSITIVE)) {
341 return nullptr;
342 }
343 std::unique_ptr<net::test_server::BasicHttpResponse> response(
344 new net::test_server::BasicHttpResponse());
345 response->set_content("This space intentionally left blank.");
346 return std::move(response);
347 }
348
333 } // namespace 349 } // namespace
334 350
335 class WebNavigationApiTest : public ExtensionApiTest { 351 class WebNavigationApiTest : public ExtensionApiTest {
336 public: 352 public:
337 WebNavigationApiTest() {} 353 WebNavigationApiTest() {
354 embedded_test_server()->RegisterRequestHandler(
355 base::Bind(&HandleTestRequest));
356 }
338 ~WebNavigationApiTest() override {} 357 ~WebNavigationApiTest() override {}
339 358
340 void SetUpInProcessBrowserTestFixture() override { 359 void SetUpInProcessBrowserTestFixture() override {
341 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); 360 ExtensionApiTest::SetUpInProcessBrowserTestFixture();
342 361
343 FrameNavigationState::set_allow_extension_scheme(true); 362 FrameNavigationState::set_allow_extension_scheme(true);
344 363
345 base::CommandLine::ForCurrentProcess()->AppendSwitch( 364 base::CommandLine::ForCurrentProcess()->AppendSwitch(
346 switches::kAllowLegacyExtensionManifests); 365 switches::kAllowLegacyExtensionManifests);
347 366
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 435
417 // Wait for the extension to set itself up and return control to us. 436 // Wait for the extension to set itself up and return control to us.
418 ASSERT_TRUE( 437 ASSERT_TRUE(
419 RunExtensionTest("webnavigation/serverRedirectSingleProcess")) 438 RunExtensionTest("webnavigation/serverRedirectSingleProcess"))
420 << message_; 439 << message_;
421 440
422 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 441 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
423 content::WaitForLoadStop(tab); 442 content::WaitForLoadStop(tab);
424 443
425 ResultCatcher catcher; 444 ResultCatcher catcher;
426 GURL url(base::StringPrintf( 445 GURL url(
427 "http://www.a.com:%u/" 446 base::StringPrintf("http://www.a.com:%u/extensions/api_test/"
428 "extensions/api_test/webnavigation/serverRedirectSingleProcess/a.html", 447 "webnavigation/serverRedirectSingleProcess/a.html",
429 embedded_test_server()->port())); 448 embedded_test_server()->port()));
430 449
431 ui_test_utils::NavigateToURL(browser(), url); 450 ui_test_utils::NavigateToURL(browser(), url);
432 451
433 url = GURL(base::StringPrintf( 452 url = GURL(base::StringPrintf(
434 "http://www.b.com:%u/server-redirect?http://www.b.com:%u/", 453 "http://www.b.com:%u/server-redirect?http://www.b.com:%u/test",
435 embedded_test_server()->port(), 454 embedded_test_server()->port(), embedded_test_server()->port()));
436 embedded_test_server()->port()));
437 455
438 ui_test_utils::NavigateToURL(browser(), url); 456 ui_test_utils::NavigateToURL(browser(), url);
439 457
440 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 458 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
441 } 459 }
442 460
443 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, ForwardBack) { 461 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, ForwardBack) {
444 ASSERT_TRUE(StartEmbeddedTestServer()); 462 ASSERT_TRUE(StartEmbeddedTestServer());
445 ASSERT_TRUE(RunExtensionTest("webnavigation/forwardBack")) << message_; 463 ASSERT_TRUE(RunExtensionTest("webnavigation/forwardBack")) << message_;
446 } 464 }
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 "extensions/api_test/webnavigation/crash/b.html", 790 "extensions/api_test/webnavigation/crash/b.html",
773 embedded_test_server()->port())); 791 embedded_test_server()->port()));
774 ui_test_utils::NavigateToURL(browser(), url); 792 ui_test_utils::NavigateToURL(browser(), url);
775 793
776 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 794 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
777 } 795 }
778 796
779 #endif 797 #endif
780 798
781 } // namespace extensions 799 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698