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

Side by Side Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 1777903003: Ensure the NavigationHandle's nav entry ID is updated during transfers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix else branch Created 4 years, 9 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
OLDNEW
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 <stdint.h> 5 #include <stdint.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 347
348 DISALLOW_COPY_AND_ASSIGN(FakeValidationMessageDelegate); 348 DISALLOW_COPY_AND_ASSIGN(FakeValidationMessageDelegate);
349 }; 349 };
350 350
351 } // namespace 351 } // namespace
352 352
353 // Test to make sure that title updates get stripped of whitespace. 353 // Test to make sure that title updates get stripped of whitespace.
354 TEST_F(WebContentsImplTest, UpdateTitle) { 354 TEST_F(WebContentsImplTest, UpdateTitle) {
355 NavigationControllerImpl& cont = 355 NavigationControllerImpl& cont =
356 static_cast<NavigationControllerImpl&>(controller()); 356 static_cast<NavigationControllerImpl&>(controller());
357 cont.LoadURL(GURL(url::kAboutBlankURL), Referrer(), ui::PAGE_TRANSITION_TYPED,
358 std::string());
359
357 FrameHostMsg_DidCommitProvisionalLoad_Params params; 360 FrameHostMsg_DidCommitProvisionalLoad_Params params;
358 InitNavigateParams(&params, 0, 0, true, GURL(url::kAboutBlankURL), 361 InitNavigateParams(&params, 0, 0, true, GURL(url::kAboutBlankURL),
359 ui::PAGE_TRANSITION_TYPED); 362 ui::PAGE_TRANSITION_TYPED);
360 363
361 LoadCommittedDetails details; 364 contents()->GetMainFrame()->SendNavigateWithParams(&params);
362 cont.RendererDidNavigate(contents()->GetMainFrame(), params, &details);
363 365
364 contents()->UpdateTitle(contents()->GetMainFrame(), 0, 366 contents()->UpdateTitle(contents()->GetMainFrame(), 0,
365 base::ASCIIToUTF16(" Lots O' Whitespace\n"), 367 base::ASCIIToUTF16(" Lots O' Whitespace\n"),
366 base::i18n::LEFT_TO_RIGHT); 368 base::i18n::LEFT_TO_RIGHT);
367 EXPECT_EQ(base::ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle()); 369 EXPECT_EQ(base::ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle());
368 } 370 }
369 371
370 TEST_F(WebContentsImplTest, UpdateTitleBeforeFirstNavigation) { 372 TEST_F(WebContentsImplTest, UpdateTitleBeforeFirstNavigation) {
371 ASSERT_TRUE(controller().IsInitialNavigation()); 373 ASSERT_TRUE(controller().IsInitialNavigation());
372 const base::string16 title = base::ASCIIToUTF16("Initial Entry Title"); 374 const base::string16 title = base::ASCIIToUTF16("Initial Entry Title");
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 416 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
415 int entry_id = cont.GetPendingEntry()->GetUniqueID(); 417 int entry_id = cont.GetPendingEntry()->GetUniqueID();
416 rvh()->GetDelegate()->RenderViewCreated(rvh()); 418 rvh()->GetDelegate()->RenderViewCreated(rvh());
417 // Did we get the expected message? 419 // Did we get the expected message?
418 EXPECT_TRUE(process()->sink().GetFirstMessageMatching( 420 EXPECT_TRUE(process()->sink().GetFirstMessageMatching(
419 ViewMsg_EnableViewSourceMode::ID)); 421 ViewMsg_EnableViewSourceMode::ID));
420 422
421 FrameHostMsg_DidCommitProvisionalLoad_Params params; 423 FrameHostMsg_DidCommitProvisionalLoad_Params params;
422 InitNavigateParams(&params, 0, entry_id, true, kGURL, 424 InitNavigateParams(&params, 0, entry_id, true, kGURL,
423 ui::PAGE_TRANSITION_TYPED); 425 ui::PAGE_TRANSITION_TYPED);
424 LoadCommittedDetails details; 426 contents()->GetMainFrame()->SendNavigateWithParams(&params);
425 cont.RendererDidNavigate(contents()->GetMainFrame(), params, &details);
426 // Also check title and url. 427 // Also check title and url.
427 EXPECT_EQ(base::ASCIIToUTF16(kUrl), contents()->GetTitle()); 428 EXPECT_EQ(base::ASCIIToUTF16(kUrl), contents()->GetTitle());
428 } 429 }
429 430
430 // Test to ensure UpdateMaxPageID is working properly. 431 // Test to ensure UpdateMaxPageID is working properly.
431 TEST_F(WebContentsImplTest, UpdateMaxPageID) { 432 TEST_F(WebContentsImplTest, UpdateMaxPageID) {
432 SiteInstance* instance1 = contents()->GetSiteInstance(); 433 SiteInstance* instance1 = contents()->GetSiteInstance();
433 scoped_refptr<SiteInstance> instance2(SiteInstance::Create(nullptr)); 434 scoped_refptr<SiteInstance> instance2(SiteInstance::Create(nullptr));
434 435
435 // Starts at -1. 436 // Starts at -1.
(...skipping 3006 matching lines...) Expand 10 before | Expand all | Expand 10 after
3442 // An automatic navigation. 3443 // An automatic navigation.
3443 contents()->GetMainFrame()->SendNavigateWithModificationCallback( 3444 contents()->GetMainFrame()->SendNavigateWithModificationCallback(
3444 2, 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); 3445 2, 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture));
3445 3446
3446 EXPECT_EQ(1u, delegate->reset_count()); 3447 EXPECT_EQ(1u, delegate->reset_count());
3447 3448
3448 contents()->SetJavaScriptDialogManagerForTesting(nullptr); 3449 contents()->SetJavaScriptDialogManagerForTesting(nullptr);
3449 } 3450 }
3450 3451
3451 } // namespace content 3452 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698