1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 #include "build/build_config.h"
8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
10 #include "chrome/browser/ui/browser_command_controller.h"
11 #include "chrome/browser/ui/browser_commands.h"
12 #include "chrome/browser/ui/browser_finder.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
15 #include "chrome/common/pref_names.h"
16 #include "chrome/common/url_constants.h"
17 #include "chrome/test/base/browser_with_test_window_test.h"
18 #include "chrome/test/base/testing_profile.h"
19 #include "components/bookmarks/browser/bookmark_model.h"
20 #include "components/bookmarks/test/bookmark_test_helpers.h"
21 #include "components/zoom/page_zoom.h"
22 #include "components/zoom/zoom_controller.h"
23 #include "content/public/browser/navigation_controller.h"
24 #include "content/public/browser/navigation_entry.h"
25 #include "content/public/browser/web_contents.h"
26 #include "content/public/common/page_zoom.h"
27 #include "content/public/test/navigation_simulator.h"
28 #include "content/public/test/test_renderer_host.h"
29 #include "testing/gtest/include/gtest/gtest.h"
30 #include "third_party/blink/public/common/page/page_zoom.h"
31 #include "third_party/blink/public/common/renderer_preferences/renderer_preferences.h"
35 using bookmarks::BookmarkModel;
36 using content::OpenURLParams;
37 using content::Referrer;
38 using content::WebContents;
39 using zoom::ZoomController;
41 class BrowserCommandsTest : public BrowserWithTestWindowTest {
43 BrowserCommandsTest() = default;
44 ~BrowserCommandsTest() override = default;
46 // BrowserWithTestWindowTest overrides.
47 TestingProfile::TestingFactories GetTestingFactories() override {
48 return {{BookmarkModelFactory::GetInstance(),
49 BookmarkModelFactory::GetDefaultFactory()}};
53 // Tests IDC_SELECT_TAB_0, IDC_SELECT_NEXT_TAB, IDC_SELECT_PREVIOUS_TAB and
54 // IDC_SELECT_LAST_TAB.
55 TEST_F(BrowserCommandsTest, TabNavigationAccelerators) {
56 GURL about_blank(url::kAboutBlankURL);
59 AddTab(browser(), about_blank);
60 AddTab(browser(), about_blank);
61 AddTab(browser(), about_blank);
63 // Select the second tab.
64 browser()->tab_strip_model()->ActivateTabAt(1);
66 CommandUpdater* updater = browser()->command_controller();
68 // Navigate to the first tab using an accelerator.
69 updater->ExecuteCommand(IDC_SELECT_TAB_0);
70 ASSERT_EQ(0, browser()->tab_strip_model()->active_index());
72 // Navigate to the second tab using the next accelerators.
73 updater->ExecuteCommand(IDC_SELECT_NEXT_TAB);
74 ASSERT_EQ(1, browser()->tab_strip_model()->active_index());
76 // Navigate back to the first tab using the previous accelerators.
77 updater->ExecuteCommand(IDC_SELECT_PREVIOUS_TAB);
78 ASSERT_EQ(0, browser()->tab_strip_model()->active_index());
80 // Navigate to the last tab using the select last accelerator.
81 updater->ExecuteCommand(IDC_SELECT_LAST_TAB);
82 ASSERT_EQ(2, browser()->tab_strip_model()->active_index());
85 // Tests IDC_DUPLICATE_TAB.
86 TEST_F(BrowserCommandsTest, DuplicateTab) {
87 GURL url1("http://foo/1");
88 GURL url2("http://foo/2");
89 GURL url3("http://foo/3");
90 GURL url4("http://foo/4");
92 // Navigate to three urls, plus a pending URL that hasn't committed.
93 AddTab(browser(), url1);
94 NavigateAndCommitActiveTab(url2);
95 NavigateAndCommitActiveTab(url3);
96 content::NavigationController& orig_controller =
97 browser()->tab_strip_model()->GetWebContentsAt(0)->GetController();
98 orig_controller.LoadURL(
99 url4, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
100 EXPECT_EQ(3, orig_controller.GetEntryCount());
101 EXPECT_TRUE(orig_controller.GetPendingEntry());
103 size_t initial_window_count = chrome::GetTotalBrowserCount();
105 // Duplicate the tab.
106 chrome::ExecuteCommand(browser(), IDC_DUPLICATE_TAB);
108 // The duplicated tab should not end up in a new window.
109 size_t window_count = chrome::GetTotalBrowserCount();
110 ASSERT_EQ(initial_window_count, window_count);
112 // And we should have a newly duplicated tab.
113 ASSERT_EQ(2, browser()->tab_strip_model()->count());
115 // Verify the stack of urls.
116 content::NavigationController& controller =
117 browser()->tab_strip_model()->GetWebContentsAt(1)->GetController();
118 EXPECT_EQ(3, controller.GetEntryCount());
119 EXPECT_EQ(2, controller.GetCurrentEntryIndex());
120 EXPECT_EQ(url1, controller.GetEntryAtIndex(0)->GetURL());
121 EXPECT_EQ(url2, controller.GetEntryAtIndex(1)->GetURL());
122 EXPECT_EQ(url3, controller.GetEntryAtIndex(2)->GetURL());
123 EXPECT_FALSE(controller.GetPendingEntry());
126 // Tests IDC_VIEW_SOURCE (See http://crbug.com/138140).
127 TEST_F(BrowserCommandsTest, ViewSource) {
128 GURL url1("http://foo/1");
129 GURL url1_subframe("http://foo/subframe");
130 GURL url2("http://foo/2");
132 // Navigate to a URL and simulate a subframe committing.
133 AddTab(browser(), url1);
134 content::RenderFrameHostTester* rfh_tester =
135 content::RenderFrameHostTester::For(browser()
137 ->GetWebContentsAt(0)
138 ->GetPrimaryMainFrame());
139 content::RenderFrameHost* subframe = rfh_tester->AppendChild("subframe");
140 content::NavigationSimulator::NavigateAndCommitFromDocument(
141 GURL(url1_subframe), subframe);
143 // Now start a pending navigation that hasn't committed.
144 content::NavigationController& orig_controller =
145 browser()->tab_strip_model()->GetWebContentsAt(0)->GetController();
146 orig_controller.LoadURL(
147 url2, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
148 EXPECT_EQ(1, orig_controller.GetEntryCount());
149 EXPECT_TRUE(orig_controller.GetPendingEntry());
151 size_t initial_window_count = chrome::GetTotalBrowserCount();
154 chrome::ExecuteCommand(browser(), IDC_VIEW_SOURCE);
156 // The view source tab should not end up in a new window.
157 size_t window_count = chrome::GetTotalBrowserCount();
158 ASSERT_EQ(initial_window_count, window_count);
160 // And we should have a newly duplicated tab.
161 ASSERT_EQ(2, browser()->tab_strip_model()->count());
163 // Verify we are viewing the source of the last committed entry.
164 GURL view_source_url("view-source:http://foo/1");
165 content::NavigationController& controller =
166 browser()->tab_strip_model()->GetWebContentsAt(1)->GetController();
167 EXPECT_EQ(1, controller.GetEntryCount());
168 EXPECT_EQ(0, controller.GetCurrentEntryIndex());
169 EXPECT_EQ(url1, controller.GetEntryAtIndex(0)->GetURL());
170 EXPECT_EQ(view_source_url, controller.GetEntryAtIndex(0)->GetVirtualURL());
171 EXPECT_FALSE(controller.GetPendingEntry());
174 TEST_F(BrowserCommandsTest, BookmarkCurrentTab) {
175 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile());
176 bookmarks::test::WaitForBookmarkModelToLoad(model);
178 // Navigate to a url.
179 GURL url1("http://foo/1");
180 AddTab(browser(), url1);
181 browser()->OpenURL(OpenURLParams(url1, Referrer(),
182 WindowOpenDisposition::CURRENT_TAB,
183 ui::PAGE_TRANSITION_TYPED, false));
185 chrome::BookmarkCurrentTab(browser());
187 // It should now be bookmarked in the bookmark model.
188 EXPECT_EQ(profile(), browser()->profile());
189 EXPECT_TRUE(model->IsBookmarked(url1));
192 // Tests back/forward in new tab (Control + Back/Forward button in the UI).
193 TEST_F(BrowserCommandsTest, BackForwardInNewTab) {
194 GURL url1("http://foo/1");
195 GURL url2("http://foo/2");
197 // Make a tab with the two pages navigated in it.
198 AddTab(browser(), url1);
199 NavigateAndCommitActiveTab(url2);
201 // Go back in a new background tab.
202 chrome::GoBack(browser(), WindowOpenDisposition::NEW_BACKGROUND_TAB);
203 EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
204 ASSERT_EQ(2, browser()->tab_strip_model()->count());
206 WebContents* zeroth = browser()->tab_strip_model()->GetWebContentsAt(0);
207 WebContents* first = browser()->tab_strip_model()->GetWebContentsAt(1);
209 // The original tab should be unchanged.
210 EXPECT_EQ(url2, zeroth->GetLastCommittedURL());
211 EXPECT_TRUE(zeroth->GetController().CanGoBack());
212 EXPECT_FALSE(zeroth->GetController().CanGoForward());
214 // The new tab should be like the first one but navigated back. Since we
215 // didn't wait for the load to complete, we can't use GetLastCommittedURL.
216 EXPECT_EQ(url1, first->GetVisibleURL());
217 EXPECT_FALSE(first->GetController().CanGoBack());
218 EXPECT_TRUE(first->GetController().CanGoForward());
220 // Select the second tab and make it go forward in a new background tab.
221 browser()->tab_strip_model()->ActivateTabAt(
222 1, TabStripUserGestureDetails(
223 TabStripUserGestureDetails::GestureType::kOther));
224 // TODO(crbug.com/11055): It should not be necessary to commit the load here,
225 // but because of this bug, it will assert later if we don't. When the bug is
226 // fixed, one of the three commits here related to this bug should be removed
227 // (to test both codepaths).
228 CommitPendingLoad(&first->GetController());
229 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
230 chrome::GoForward(browser(), WindowOpenDisposition::NEW_BACKGROUND_TAB);
232 // The previous tab should be unchanged and still in the foreground.
233 EXPECT_EQ(url1, first->GetLastCommittedURL());
234 EXPECT_FALSE(first->GetController().CanGoBack());
235 EXPECT_TRUE(first->GetController().CanGoForward());
236 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
238 // There should be a new tab navigated forward.
239 ASSERT_EQ(3, browser()->tab_strip_model()->count());
240 WebContents* second = browser()->tab_strip_model()->GetWebContentsAt(2);
241 // Since we didn't wait for load to complete, we can't use
242 // GetLastCommittedURL.
243 EXPECT_EQ(url2, second->GetVisibleURL());
244 EXPECT_TRUE(second->GetController().CanGoBack());
245 EXPECT_FALSE(second->GetController().CanGoForward());
247 // Now do back in a new foreground tab. Don't bother re-checking every sngle
248 // thing above, just validate that it's opening properly.
249 browser()->tab_strip_model()->ActivateTabAt(
250 2, TabStripUserGestureDetails(
251 TabStripUserGestureDetails::GestureType::kOther));
252 // TODO(crbug.com/11055): see the comment above about why we need this.
253 CommitPendingLoad(&second->GetController());
254 chrome::GoBack(browser(), WindowOpenDisposition::NEW_FOREGROUND_TAB);
255 ASSERT_EQ(3, browser()->tab_strip_model()->active_index());
257 browser()->tab_strip_model()->GetActiveWebContents()->
260 // Same thing again for forward.
261 // TODO(crbug.com/11055): see the comment above about why we need this.
263 browser()->tab_strip_model()->GetActiveWebContents()->GetController());
264 chrome::GoForward(browser(), WindowOpenDisposition::NEW_FOREGROUND_TAB);
265 ASSERT_EQ(4, browser()->tab_strip_model()->active_index());
267 browser()->tab_strip_model()->GetActiveWebContents()->
271 // Tests back/forward in new tab (Control + Back/Forward button in the UI)
272 // with Tab Groups enabled.
273 TEST_F(BrowserCommandsTest, BackForwardInNewTabWithGroup) {
274 GURL url1("http://foo/1");
275 GURL url2("http://foo/2");
276 ASSERT_TRUE(browser()->tab_strip_model()->SupportsTabGroups());
278 // Make a tab with the two pages navigated in it.
279 AddTab(browser(), url1);
280 NavigateAndCommitActiveTab(url2);
282 // Add the tab to a Tab Group.
283 const tab_groups::TabGroupId group_id =
284 browser()->tab_strip_model()->AddToNewGroup({0});
286 // Go back in a new background tab.
287 chrome::GoBack(browser(), WindowOpenDisposition::NEW_BACKGROUND_TAB);
288 ASSERT_EQ(0, browser()->tab_strip_model()->active_index());
289 ASSERT_EQ(2, browser()->tab_strip_model()->count());
291 // The new tab should have inherited the tab group from the old tab.
292 EXPECT_EQ(group_id, browser()->tab_strip_model()->GetTabGroupForTab(1));
294 // Select the second tab and make it go forward in a new background tab.
295 browser()->tab_strip_model()->ActivateTabAt(
296 1, TabStripUserGestureDetails(
297 TabStripUserGestureDetails::GestureType::kOther));
298 // TODO(crbug.com/11055): see the comment above about why we need this.
300 &browser()->tab_strip_model()->GetActiveWebContents()->GetController());
301 chrome::GoForward(browser(), WindowOpenDisposition::NEW_BACKGROUND_TAB);
303 // The new tab should have inherited the tab group from the old tab.
304 EXPECT_EQ(group_id, browser()->tab_strip_model()->GetTabGroupForTab(2));
307 TEST_F(BrowserCommandsTest, OnMaxZoomIn) {
308 TabStripModel* tab_strip_model = browser()->tab_strip_model();
310 GURL url("http://www.google.com");
311 AddTab(browser(), url);
312 WebContents* first_tab = tab_strip_model->GetWebContentsAt(0);
314 // Continue to zoom in until zoom percent reaches 500.
315 for (int i = 0; i < 9; ++i) {
316 zoom::PageZoom::Zoom(first_tab, content::PAGE_ZOOM_IN);
319 // TODO(a.sarkar.arun@gmail.com): Figure out why Zoom-In menu item is not
320 // disabled after Max-zoom is reached. Force disable Zoom-In menu item
321 // from the context menu since it breaks try jobs on bots.
322 if (chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS))
323 chrome::UpdateCommandEnabled(browser(), IDC_ZOOM_PLUS, false);
325 ZoomController* zoom_controller = ZoomController::FromWebContents(first_tab);
326 EXPECT_FLOAT_EQ(500.0f, zoom_controller->GetZoomPercent());
327 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS));
328 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL));
329 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS));
332 TEST_F(BrowserCommandsTest, OnMaxZoomOut) {
333 TabStripModel* tab_strip_model = browser()->tab_strip_model();
335 GURL url("http://www.google.com");
336 AddTab(browser(), url);
337 WebContents* first_tab = tab_strip_model->GetWebContentsAt(0);
339 // Continue to zoom out until zoom percent reaches 25.
340 for (int i = 0; i < 7; ++i) {
341 zoom::PageZoom::Zoom(first_tab, content::PAGE_ZOOM_OUT);
344 ZoomController* zoom_controller = ZoomController::FromWebContents(first_tab);
345 EXPECT_FLOAT_EQ(25.0f, zoom_controller->GetZoomPercent());
346 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS));
347 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL));
348 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS));
351 TEST_F(BrowserCommandsTest, OnZoomReset) {
352 TabStripModel* tab_strip_model = browser()->tab_strip_model();
354 GURL url("http://www.google.com");
355 AddTab(browser(), url);
356 WebContents* first_tab = tab_strip_model->GetWebContentsAt(0);
358 // Change the zoom percentage to 100.
359 zoom::PageZoom::Zoom(first_tab, content::PAGE_ZOOM_RESET);
361 ZoomController* zoom_controller = ZoomController::FromWebContents(first_tab);
362 EXPECT_FLOAT_EQ(100.0f, zoom_controller->GetZoomPercent());
363 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS));
364 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL));
365 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS));
367 // Changing the page scale factor will re-enable IDC_ZOOM_NORMAL
368 zoom_controller->SetPageScaleFactorIsOneForTesting(false);
369 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL));
372 TEST_F(BrowserCommandsTest, OnZoomLevelChanged) {
373 TabStripModel* tab_strip_model = browser()->tab_strip_model();
375 GURL url("http://www.google.com");
376 AddTab(browser(), url);
377 WebContents* first_tab = tab_strip_model->GetWebContentsAt(0);
379 // Changing zoom percentage from default should enable all the zoom
381 zoom::PageZoom::Zoom(first_tab, content::PAGE_ZOOM_IN);
383 ZoomController* zoom_controller = ZoomController::FromWebContents(first_tab);
384 EXPECT_FLOAT_EQ(110.0f, zoom_controller->GetZoomPercent());
385 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS));
386 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL));
387 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS));
390 TEST_F(BrowserCommandsTest, OnZoomChangedForActiveTab) {
391 TabStripModel* tab_strip_model = browser()->tab_strip_model();
393 GURL url("http://www.google.com");
394 GURL url1("http://code.google.com");
397 AddTab(browser(), url);
398 AddTab(browser(), url1);
399 WebContents* first_tab = tab_strip_model->GetWebContentsAt(0);
401 ZoomController* zoom_controller = ZoomController::FromWebContents(first_tab);
402 EXPECT_FLOAT_EQ(100.0f, zoom_controller->GetZoomPercent());
403 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS));
404 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL));
405 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS));
408 WebContents* second_tab = tab_strip_model->GetWebContentsAt(1);
410 tab_strip_model->ActivateTabAt(
411 1, TabStripUserGestureDetails(
412 TabStripUserGestureDetails::GestureType::kOther));
413 EXPECT_TRUE(tab_strip_model->IsTabSelected(1));
414 zoom::PageZoom::Zoom(second_tab, content::PAGE_ZOOM_OUT);
416 zoom_controller = ZoomController::FromWebContents(second_tab);
417 EXPECT_FLOAT_EQ(90.0f, zoom_controller->GetZoomPercent());
418 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS));
419 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL));
420 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS));
423 TEST_F(BrowserCommandsTest, OnDefaultZoomLevelChanged) {
424 TabStripModel* tab_strip_model = browser()->tab_strip_model();
425 GURL url("http://code.google.com");
426 AddTab(browser(), url);
427 WebContents* tab = tab_strip_model->GetWebContentsAt(0);
428 ZoomController* zoom_controller = ZoomController::FromWebContents(tab);
430 // Set the default zoom level to 125.
431 profile()->GetZoomLevelPrefs()->SetDefaultZoomLevelPref(
432 blink::PageZoomFactorToZoomLevel(1.25));
433 EXPECT_FLOAT_EQ(125.0f, zoom_controller->GetZoomPercent());
435 // Actual Size from context menu should be disabled now.
436 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS));
437 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL));
438 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS));
440 // Change the zoom level.
441 zoom::PageZoom::Zoom(tab, content::PAGE_ZOOM_IN);
443 EXPECT_FLOAT_EQ(150.0f, zoom_controller->GetZoomPercent());
445 // Tab no longer at default zoom hence actual size should be enabled.
446 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_PLUS));
447 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_NORMAL));
448 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ZOOM_MINUS));
451 TEST_F(BrowserCommandsTest, ToggleCaretBrowsing) {
452 // Set initial known state for browser process TestingProfile.
453 PrefService* pref_service = profile()->GetPrefs();
454 pref_service->SetBoolean(prefs::kCaretBrowsingEnabled, false);
455 pref_service->SetBoolean(prefs::kShowCaretBrowsingDialog, false);
457 #if BUILDFLAG(IS_MAC)
458 // On Mac, caret browsing should be disabled unless focus is in web content.
459 // Make sure it's disabled initially and doesn't toggle if executed.
460 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_CARET_BROWSING_TOGGLE));
461 chrome::ExecuteCommand(browser(), IDC_CARET_BROWSING_TOGGLE);
462 EXPECT_FALSE(pref_service->GetBoolean(prefs::kCaretBrowsingEnabled));
465 // Create multiple tabs to test if caret browsing mode gets broadcast to all
466 // tabs when toggled. (For the purposes of testing, this simulates
467 // putting focus in web contents as a side effect.)
468 GURL about_blank(url::kAboutBlankURL);
470 for (int i = 0; i < tab_count; ++i) {
471 AddTab(browser(), about_blank);
474 // Toggle on caret browsing.
475 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_CARET_BROWSING_TOGGLE));
476 chrome::ExecuteCommand(browser(), IDC_CARET_BROWSING_TOGGLE);
477 EXPECT_TRUE(pref_service->GetBoolean(prefs::kCaretBrowsingEnabled));
479 // Add another tab after toggling caret browsing mode--it should also have
480 // caret browsing mode set.
481 AddTab(browser(), about_blank);
484 // Check renderer preferences for each tab.
485 for (int i = 0; i < tab_count; ++i) {
486 WebContents* web_contents =
487 browser()->tab_strip_model()->GetWebContentsAt(i);
488 blink::RendererPreferences* renderer_preferences =
489 web_contents->GetMutableRendererPrefs();
490 EXPECT_TRUE(renderer_preferences->caret_browsing_enabled);
493 // Toggle off caret browsing.
494 chrome::ExecuteCommand(browser(), IDC_CARET_BROWSING_TOGGLE);
495 EXPECT_FALSE(pref_service->GetBoolean(prefs::kCaretBrowsingEnabled));
497 // Add another tab after toggling caret browsing mode--it should also have
498 // caret browsing mode unset.
499 AddTab(browser(), about_blank);
502 // Check renderer preferences for each tab.
503 for (int i = 0; i < tab_count; ++i) {
504 WebContents* web_contents =
505 browser()->tab_strip_model()->GetWebContentsAt(i);
506 blink::RendererPreferences* renderer_preferences =
507 web_contents->GetMutableRendererPrefs();
508 EXPECT_FALSE(renderer_preferences->caret_browsing_enabled);
512 TEST_F(BrowserCommandsTest, TabSearchCommandStatus) {
513 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_TAB_SEARCH));
514 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_TAB_SEARCH_CLOSE));