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

Unified Diff: chrome/browser/ui/search/search_ipc_router_unittest.cc

Issue 410533002: Merge 278958 "Discard ChromeViewHostMsg_SearchBox* IPCs if they ..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1985/src
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/search/search_ipc_router_policy_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/search/search_ipc_router_unittest.cc
diff --git a/chrome/browser/ui/search/search_ipc_router_unittest.cc b/chrome/browser/ui/search/search_ipc_router_unittest.cc
index ca11a804cdb98ca0d4ae6621be6d72c3169584f6..091b02781a4b58b56239b32099b2ff8da921bbfa 100644
--- a/chrome/browser/ui/search/search_ipc_router_unittest.cc
+++ b/chrome/browser/ui/search/search_ipc_router_unittest.cc
@@ -180,7 +180,10 @@ class SearchIPCRouterTest : public BrowserWithTestWindowTest {
}
void OnMessageReceived(const IPC::Message& message) {
- GetSearchIPCRouter().OnMessageReceived(message);
+ bool should_handle_message =
+ chrome::IsRenderedInInstantProcess(web_contents(), profile());
+ bool handled = GetSearchIPCRouter().OnMessageReceived(message);
+ ASSERT_EQ(should_handle_message, handled);
}
bool IsActiveTab(content::WebContents* contents) {
@@ -192,6 +195,26 @@ class SearchIPCRouterTest : public BrowserWithTestWindowTest {
base::FieldTrialList field_trial_list_;
};
+TEST_F(SearchIPCRouterTest, IgnoreMessagesFromNonInstantRenderers) {
+ NavigateAndCommitActiveTab(GURL("file://foo/bar"));
+ SetupMockDelegateAndPolicy();
+ GURL destination_url("www.foo.com");
+ EXPECT_CALL(*mock_delegate(), NavigateToURL(destination_url, CURRENT_TAB,
+ true)).Times(0);
+ content::WebContents* contents = web_contents();
+ bool is_active_tab = IsActiveTab(contents);
+ EXPECT_TRUE(is_active_tab);
+
+ MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
+ EXPECT_CALL(*policy, ShouldProcessNavigateToURL(is_active_tab)).Times(0);
+
+ scoped_ptr<IPC::Message> message(new ChromeViewHostMsg_SearchBoxNavigate(
+ contents->GetRoutingID(),
+ contents->GetController().GetVisibleEntry()->GetPageID(),
+ destination_url, CURRENT_TAB, true));
+ OnMessageReceived(*message);
+}
+
TEST_F(SearchIPCRouterTest, ProcessVoiceSearchSupportMsg) {
NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
SetupMockDelegateAndPolicy();
@@ -285,7 +308,7 @@ TEST_F(SearchIPCRouterTest, HandleTabChangedEvents) {
}
TEST_F(SearchIPCRouterTest, ProcessNavigateToURLMsg) {
- NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
+ NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
SetupMockDelegateAndPolicy();
GURL destination_url("www.foo.com");
EXPECT_CALL(*mock_delegate(), NavigateToURL(destination_url, CURRENT_TAB,
« no previous file with comments | « chrome/browser/ui/search/search_ipc_router_policy_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698