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

Unified Diff: chrome/browser/ui/browser_browsertest.cc

Issue 1397673004: Make opening a new tab with the NTP use PAGE_TRANSITION_AUTO_TOPLEVEL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
Index: chrome/browser/ui/browser_browsertest.cc
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc
index 2bb48ceb26d54b9b1f6bf60752c4c7a94a45607c..3d3097d1c5a57997e3d583c35e8b6c5e3f7d2950 100644
--- a/chrome/browser/ui/browser_browsertest.cc
+++ b/chrome/browser/ui/browser_browsertest.cc
@@ -73,6 +73,7 @@
#include "components/app_modal/javascript_app_modal_dialog.h"
#include "components/app_modal/native_app_modal_dialog.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
+#include "components/omnibox/browser/omnibox_view.h"
#include "components/sessions/core/base_session_service_test_helper.h"
#include "components/translate/core/browser/language_state.h"
#include "components/translate/core/common/language_detection_details.h"
@@ -2872,6 +2873,37 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, GetSizeForNewRenderView) {
EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size());
}
+// Opening a new tab and then closing it should return focus to the previous
+// tab.
+// Regression test for http://crbug.com/582249
+IN_PROC_BROWSER_TEST_F(BrowserTest, CloseTabFocus) {
+ chrome::NewTab(browser());
+ chrome::NewTab(browser());
+ chrome::NewTab(browser());
+ EXPECT_EQ(3, browser()->tab_strip_model()->active_index());
+
+ browser()->tab_strip_model()->ActivateTabAt(0, true);
+ EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
+
+ chrome::NewTab(browser());
+ EXPECT_EQ(4, browser()->tab_strip_model()->active_index());
+
+ chrome::CloseTab(browser());
+ EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
+
+ // Check opening a new tab via Alt+Enter in the omnibox.
+ browser()->tab_strip_model()->ActivateTabAt(1, true);
+ EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
+
+ browser()->GetOmniboxView()->SetUserText(
+ ASCIIToUTF16("http://www.google.com"));
+ browser()->GetOmniboxView()->model()->AcceptInput(NEW_FOREGROUND_TAB, false);
+ EXPECT_EQ(4, browser()->tab_strip_model()->active_index());
+
+ chrome::CloseTab(browser());
+ EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
+}
+
IN_PROC_BROWSER_TEST_F(BrowserTest, CanDuplicateTab) {
GURL url(ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory),

Powered by Google App Engine
This is Rietveld 408576698