OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/browser/frame_host/cross_site_transferring_request.h" | 8 #include "content/browser/frame_host/cross_site_transferring_request.h" |
9 #include "content/browser/frame_host/interstitial_page_impl.h" | 9 #include "content/browser/frame_host/interstitial_page_impl.h" |
10 #include "content/browser/frame_host/navigation_entry_impl.h" | 10 #include "content/browser/frame_host/navigation_entry_impl.h" |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 | 339 |
340 LoadCommittedDetails details; | 340 LoadCommittedDetails details; |
341 cont.RendererDidNavigate(contents()->GetMainFrame(), params, &details); | 341 cont.RendererDidNavigate(contents()->GetMainFrame(), params, &details); |
342 | 342 |
343 contents()->UpdateTitle(contents()->GetMainFrame(), 0, | 343 contents()->UpdateTitle(contents()->GetMainFrame(), 0, |
344 base::ASCIIToUTF16(" Lots O' Whitespace\n"), | 344 base::ASCIIToUTF16(" Lots O' Whitespace\n"), |
345 base::i18n::LEFT_TO_RIGHT); | 345 base::i18n::LEFT_TO_RIGHT); |
346 EXPECT_EQ(base::ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle()); | 346 EXPECT_EQ(base::ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle()); |
347 } | 347 } |
348 | 348 |
| 349 TEST_F(WebContentsImplTest, UpdateTitleBeforeFirstNavigation) { |
| 350 ASSERT_TRUE(controller().IsInitialNavigation()); |
| 351 const base::string16 title = base::ASCIIToUTF16("Initial Entry Title"); |
| 352 contents()->UpdateTitle(contents()->GetMainFrame(), -1, title, |
| 353 base::i18n::LEFT_TO_RIGHT); |
| 354 EXPECT_EQ(title, contents()->GetTitle()); |
| 355 } |
| 356 |
349 TEST_F(WebContentsImplTest, DontUseTitleFromPendingEntry) { | 357 TEST_F(WebContentsImplTest, DontUseTitleFromPendingEntry) { |
350 const GURL kGURL("chrome://blah"); | 358 const GURL kGURL("chrome://blah"); |
351 controller().LoadURL( | 359 controller().LoadURL( |
352 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 360 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
353 EXPECT_EQ(base::string16(), contents()->GetTitle()); | 361 EXPECT_EQ(base::string16(), contents()->GetTitle()); |
| 362 |
| 363 // Also test setting title while the first navigation is still pending. |
| 364 const base::string16 title = base::ASCIIToUTF16("Initial Entry Title"); |
| 365 contents()->UpdateTitle(contents()->GetMainFrame(), -1, title, |
| 366 base::i18n::LEFT_TO_RIGHT); |
| 367 EXPECT_EQ(title, contents()->GetTitle()); |
354 } | 368 } |
355 | 369 |
356 TEST_F(WebContentsImplTest, UseTitleFromPendingEntryIfSet) { | 370 TEST_F(WebContentsImplTest, UseTitleFromPendingEntryIfSet) { |
357 const GURL kGURL("chrome://blah"); | 371 const GURL kGURL("chrome://blah"); |
358 const base::string16 title = base::ASCIIToUTF16("My Title"); | 372 const base::string16 title = base::ASCIIToUTF16("My Title"); |
359 controller().LoadURL( | 373 controller().LoadURL( |
360 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 374 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
361 | 375 |
362 NavigationEntry* entry = controller().GetVisibleEntry(); | 376 NavigationEntry* entry = controller().GetVisibleEntry(); |
363 ASSERT_EQ(kGURL, entry->GetURL()); | 377 ASSERT_EQ(kGURL, entry->GetURL()); |
(...skipping 2997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3361 backend->AllowCertForHost(*cert, test_url.host(), 1); | 3375 backend->AllowCertForHost(*cert, test_url.host(), 1); |
3362 EXPECT_TRUE(backend->HasAllowException(test_url.host())); | 3376 EXPECT_TRUE(backend->HasAllowException(test_url.host())); |
3363 | 3377 |
3364 contents()->OnDidLoadResourceFromMemoryCache(test_url, "", "GET", "mime type", | 3378 contents()->OnDidLoadResourceFromMemoryCache(test_url, "", "GET", "mime type", |
3365 RESOURCE_TYPE_MAIN_FRAME); | 3379 RESOURCE_TYPE_MAIN_FRAME); |
3366 | 3380 |
3367 EXPECT_TRUE(backend->HasAllowException(test_url.host())); | 3381 EXPECT_TRUE(backend->HasAllowException(test_url.host())); |
3368 } | 3382 } |
3369 | 3383 |
3370 } // namespace content | 3384 } // namespace content |
OLD | NEW |