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

Unified Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 1372133002: Don't rely on |entry| being null in initial title logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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: content/browser/web_contents/web_contents_impl_unittest.cc
diff --git a/content/browser/web_contents/web_contents_impl_unittest.cc b/content/browser/web_contents/web_contents_impl_unittest.cc
index 4ead8c17f480c5074735a4bd660e813c448622f7..7dabef2c4418b69bd157b570272a33405d0cf2aa 100644
--- a/content/browser/web_contents/web_contents_impl_unittest.cc
+++ b/content/browser/web_contents/web_contents_impl_unittest.cc
@@ -346,11 +346,25 @@ TEST_F(WebContentsImplTest, UpdateTitle) {
EXPECT_EQ(base::ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle());
}
+TEST_F(WebContentsImplTest, UpdateTitleBeforeFirstNavigation) {
+ ASSERT_TRUE(controller().IsInitialNavigation());
+ const base::string16 title = base::ASCIIToUTF16("Initial Entry Title");
+ contents()->UpdateTitle(contents()->GetMainFrame(), -1, title,
+ base::i18n::LEFT_TO_RIGHT);
+ EXPECT_EQ(title, contents()->GetTitle());
+}
+
TEST_F(WebContentsImplTest, DontUseTitleFromPendingEntry) {
const GURL kGURL("chrome://blah");
controller().LoadURL(
kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
EXPECT_EQ(base::string16(), contents()->GetTitle());
+
+ // Also test setting title while the first navigation is still pending.
+ const base::string16 title = base::ASCIIToUTF16("Initial Entry Title");
+ contents()->UpdateTitle(contents()->GetMainFrame(), -1, title,
+ base::i18n::LEFT_TO_RIGHT);
+ EXPECT_EQ(title, contents()->GetTitle());
}
TEST_F(WebContentsImplTest, UseTitleFromPendingEntryIfSet) {

Powered by Google App Engine
This is Rietveld 408576698