| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 "extensions/api_test/webnavigation/crash/b.html", | 791 "extensions/api_test/webnavigation/crash/b.html", |
| 773 embedded_test_server()->port())); | 792 embedded_test_server()->port())); |
| 774 ui_test_utils::NavigateToURL(browser(), url); | 793 ui_test_utils::NavigateToURL(browser(), url); |
| 775 | 794 |
| 776 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 795 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 777 } | 796 } |
| 778 | 797 |
| 779 #endif | 798 #endif |
| 780 | 799 |
| 781 } // namespace extensions | 800 } // namespace extensions |
| OLD | NEW |