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

Side by Side Diff: chrome/browser/extensions/extension_navigation_throttle_unittest.cc

Issue 2696493003: Introduce SubframeNavigationFilteringThrottle (Closed)
Patch Set: fix use after stack return, make code nicer Created 3 years, 10 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 "base/memory/ptr_util.h" 5 #include "base/memory/ptr_util.h"
6 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
7 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 7 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
8 #include "components/crx_file/id_util.h" 8 #include "components/crx_file/id_util.h"
9 #include "content/public/browser/content_browser_client.h" 9 #include "content/public/browser/content_browser_client.h"
10 #include "content/public/browser/navigation_handle.h" 10 #include "content/public/browser/navigation_handle.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // |expected_result|. 69 // |expected_result|.
70 void CheckTestCase(content::RenderFrameHost* host, 70 void CheckTestCase(content::RenderFrameHost* host,
71 const GURL& url, 71 const GURL& url,
72 NavigationThrottle::ThrottleCheckResult expected_result) { 72 NavigationThrottle::ThrottleCheckResult expected_result) {
73 std::unique_ptr<content::NavigationHandle> handle = 73 std::unique_ptr<content::NavigationHandle> handle =
74 content::NavigationHandle::CreateNavigationHandleForTesting(url, host); 74 content::NavigationHandle::CreateNavigationHandleForTesting(url, host);
75 EXPECT_EQ(expected_result, 75 EXPECT_EQ(expected_result,
76 handle->CallWillStartRequestForTesting( 76 handle->CallWillStartRequestForTesting(
77 /*is_post=*/false, content::Referrer(), 77 /*is_post=*/false, content::Referrer(),
78 /*has_user_gesture=*/false, ui::PAGE_TRANSITION_LINK, 78 /*has_user_gesture=*/false, ui::PAGE_TRANSITION_LINK,
79 /*is_external_protocol=*/false)) 79 /*is_external_protocol=*/false,
80 content::NavigationHandle::ThrottleChecksFinishedCallback()))
80 << url; 81 << url;
81 } 82 }
82 83
83 const Extension* extension() { return extension_.get(); } 84 const Extension* extension() { return extension_.get(); }
84 content::WebContentsTester* web_contents_tester() { 85 content::WebContentsTester* web_contents_tester() {
85 return content::WebContentsTester::For(web_contents()); 86 return content::WebContentsTester::For(web_contents());
86 } 87 }
87 content::RenderFrameHostTester* render_frame_host_tester( 88 content::RenderFrameHostTester* render_frame_host_tester(
88 content::RenderFrameHost* host) { 89 content::RenderFrameHost* host) {
89 return content::RenderFrameHostTester::For(host); 90 return content::RenderFrameHostTester::For(host);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 190
190 std::string second_id = crx_file::id_util::GenerateId("bar"); 191 std::string second_id = crx_file::id_util::GenerateId("bar");
191 ASSERT_NE(second_id, extension()->id()); 192 ASSERT_NE(second_id, extension()->id());
192 GURL invalid_url(base::StringPrintf("chrome-extension://%s/accessible.html", 193 GURL invalid_url(base::StringPrintf("chrome-extension://%s/accessible.html",
193 second_id.c_str())); 194 second_id.c_str()));
194 // Requests to non-existent extensions should be blocked. 195 // Requests to non-existent extensions should be blocked.
195 CheckTestCase(child, invalid_url, NavigationThrottle::BLOCK_REQUEST); 196 CheckTestCase(child, invalid_url, NavigationThrottle::BLOCK_REQUEST);
196 } 197 }
197 198
198 } // namespace extensions 199 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698