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

Side by Side Diff: chrome/browser/search/instant_service_unittest.cc

Issue 1908363002: Nuke chrome.embeddedeseach.newTabPage.navigateContentWindow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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
« no previous file with comments | « chrome/browser/search/instant_service.cc ('k') | chrome/browser/ui/browser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/search/instant_service.h" 5 #include "chrome/browser/search/instant_service.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <tuple> 9 #include <tuple>
10 #include <vector> 10 #include <vector>
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 TEST_F(InstantServiceTest, GetSuggestionFromClientSide) { 177 TEST_F(InstantServiceTest, GetSuggestionFromClientSide) {
178 history::MostVisitedURLList url_list; 178 history::MostVisitedURLList url_list;
179 url_list.push_back(history::MostVisitedURL()); 179 url_list.push_back(history::MostVisitedURL());
180 180
181 instant_service_->OnMostVisitedItemsReceived(url_list); 181 instant_service_->OnMostVisitedItemsReceived(url_list);
182 182
183 auto items = instant_service_->most_visited_items_; 183 auto items = instant_service_->most_visited_items_;
184 ASSERT_EQ(1, (int)items.size()); 184 ASSERT_EQ(1, (int)items.size());
185 ASSERT_FALSE(items[0].is_server_side_suggestion); 185 ASSERT_FALSE(items[0].is_server_side_suggestion);
186 } 186 }
187
188 TEST_F(InstantServiceTest, IsValidURLForNavigation) {
189 // chrome:// URLs should never appear in the most visited items list, but even
190 // if it does, deny navigation anyway.
191 InstantMostVisitedItem settings_item;
192 settings_item.url = GURL("chrome://settings");
193 most_visited_items().push_back(settings_item);
194 EXPECT_FALSE(instant_service_->IsValidURLForNavigation(settings_item.url));
195
196 // If a chrome-extension:// URL appears in the most visited items list, allow
197 // navigation to it.
198 InstantMostVisitedItem extension_item;
199 extension_item.url = GURL("chrome-extension://awesome");
200 most_visited_items().push_back(extension_item);
201 EXPECT_TRUE(instant_service_->IsValidURLForNavigation(extension_item.url));
202
203 // The renderer filters out javascript:// URLs so we should never receive a
204 // request to navigate to one. But if we do, deny it.
205 InstantMostVisitedItem js_item;
206 js_item.url = GURL("javascript:'moo'");
207 most_visited_items().push_back(js_item);
208 EXPECT_FALSE(instant_service_->IsValidURLForNavigation(js_item.url));
209
210 // Normal case: a request for a web safe URL in the most visited items should
211 // be allowed.
212 InstantMostVisitedItem example_item;
213 example_item.url = GURL("https://example.com");
214 most_visited_items().push_back(example_item);
215 EXPECT_TRUE(instant_service_->IsValidURLForNavigation(example_item.url));
216
217 // Normal case: a request for a web safe URL in the most visited items should
218 // be allowed as well.
219 InstantMostVisitedItem chromium_item;
220 chromium_item.url = GURL("https://chromium.org");
221 suggestions_items().push_back(chromium_item);
222 EXPECT_TRUE(instant_service_->IsValidURLForNavigation(chromium_item.url));
223
224 // http://chromium.org is web safe, but not in |suggestions_items_| or
225 // |most_visited_items_|, so it should be denied.
226 EXPECT_FALSE(
227 instant_service_->IsValidURLForNavigation(GURL("http://chromium.org")));
228 }
OLDNEW
« no previous file with comments | « chrome/browser/search/instant_service.cc ('k') | chrome/browser/ui/browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698