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 "base/strings/stringprintf.h" | 5 #include "base/strings/stringprintf.h" |
6 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 6 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
7 #include "components/crx_file/id_util.h" | 7 #include "components/crx_file/id_util.h" |
8 #include "content/public/browser/content_browser_client.h" | 8 #include "content/public/browser/content_browser_client.h" |
9 #include "content/public/browser/navigation_handle.h" | 9 #include "content/public/browser/navigation_handle.h" |
10 #include "content/public/common/content_client.h" | 10 #include "content/public/common/content_client.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 ChromeRenderViewHostTestHarness::TearDown(); | 62 ChromeRenderViewHostTestHarness::TearDown(); |
63 } | 63 } |
64 | 64 |
65 // Checks that trying to navigate the given |host| to |url| results in the | 65 // Checks that trying to navigate the given |host| to |url| results in the |
66 // |expected_result|. | 66 // |expected_result|. |
67 void CheckTestCase(content::RenderFrameHost* host, | 67 void CheckTestCase(content::RenderFrameHost* host, |
68 const GURL& url, | 68 const GURL& url, |
69 NavigationThrottle::ThrottleCheckResult expected_result) { | 69 NavigationThrottle::ThrottleCheckResult expected_result) { |
70 std::unique_ptr<content::NavigationHandle> handle = | 70 std::unique_ptr<content::NavigationHandle> handle = |
71 content::NavigationHandle::CreateNavigationHandleForTesting(url, host); | 71 content::NavigationHandle::CreateNavigationHandleForTesting(url, host); |
72 EXPECT_EQ(expected_result, handle->CallWillStartRequestForTesting( | 72 EXPECT_EQ(expected_result, |
73 false, //not post | 73 handle->CallWillStartRequestForTesting( |
74 content::Referrer(), false, | 74 false, // not post |
75 ui::PAGE_TRANSITION_LINK, false)) | 75 content::Referrer(), ui::PAGE_TRANSITION_LINK, false)) |
76 << url; | 76 << url; |
77 } | 77 } |
78 | 78 |
79 const Extension* extension() { return extension_.get(); } | 79 const Extension* extension() { return extension_.get(); } |
80 content::WebContentsTester* web_contents_tester() { | 80 content::WebContentsTester* web_contents_tester() { |
81 return content::WebContentsTester::For(web_contents()); | 81 return content::WebContentsTester::For(web_contents()); |
82 } | 82 } |
83 content::RenderFrameHostTester* render_frame_host_tester( | 83 content::RenderFrameHostTester* render_frame_host_tester( |
84 content::RenderFrameHost* host) { | 84 content::RenderFrameHost* host) { |
85 return content::RenderFrameHostTester::For(host); | 85 return content::RenderFrameHostTester::For(host); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 185 |
186 std::string second_id = crx_file::id_util::GenerateId("bar"); | 186 std::string second_id = crx_file::id_util::GenerateId("bar"); |
187 ASSERT_NE(second_id, extension()->id()); | 187 ASSERT_NE(second_id, extension()->id()); |
188 GURL invalid_url(base::StringPrintf("chrome-extension://%s/accessible.html", | 188 GURL invalid_url(base::StringPrintf("chrome-extension://%s/accessible.html", |
189 second_id.c_str())); | 189 second_id.c_str())); |
190 // Requests to non-existent extensions should be blocked. | 190 // Requests to non-existent extensions should be blocked. |
191 CheckTestCase(child, invalid_url, NavigationThrottle::BLOCK_REQUEST); | 191 CheckTestCase(child, invalid_url, NavigationThrottle::BLOCK_REQUEST); |
192 } | 192 } |
193 | 193 |
194 } // namespace extensions | 194 } // namespace extensions |
OLD | NEW |