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

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: Move fix to another CL (now cleanup only) 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()->PrepareForCommit();
362 cont.RendererDidNavigate(contents()->GetMainFrame(), params, &details); 365 contents()->GetMainFrame()->SendNavigateWithParams(&params);
363 366
364 contents()->UpdateTitle(contents()->GetMainFrame(), 0, 367 contents()->UpdateTitle(contents()->GetMainFrame(), 0,
365 base::ASCIIToUTF16(" Lots O' Whitespace\n"), 368 base::ASCIIToUTF16(" Lots O' Whitespace\n"),
366 base::i18n::LEFT_TO_RIGHT); 369 base::i18n::LEFT_TO_RIGHT);
367 EXPECT_EQ(base::ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle()); 370 EXPECT_EQ(base::ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle());
368 } 371 }
369 372
370 TEST_F(WebContentsImplTest, UpdateTitleBeforeFirstNavigation) { 373 TEST_F(WebContentsImplTest, UpdateTitleBeforeFirstNavigation) {
371 ASSERT_TRUE(controller().IsInitialNavigation()); 374 ASSERT_TRUE(controller().IsInitialNavigation());
372 const base::string16 title = base::ASCIIToUTF16("Initial Entry Title"); 375 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()); 417 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
415 int entry_id = cont.GetPendingEntry()->GetUniqueID(); 418 int entry_id = cont.GetPendingEntry()->GetUniqueID();
416 rvh()->GetDelegate()->RenderViewCreated(rvh()); 419 rvh()->GetDelegate()->RenderViewCreated(rvh());
417 // Did we get the expected message? 420 // Did we get the expected message?
418 EXPECT_TRUE(process()->sink().GetFirstMessageMatching( 421 EXPECT_TRUE(process()->sink().GetFirstMessageMatching(
419 ViewMsg_EnableViewSourceMode::ID)); 422 ViewMsg_EnableViewSourceMode::ID));
420 423
421 FrameHostMsg_DidCommitProvisionalLoad_Params params; 424 FrameHostMsg_DidCommitProvisionalLoad_Params params;
422 InitNavigateParams(&params, 0, entry_id, true, kGURL, 425 InitNavigateParams(&params, 0, entry_id, true, kGURL,
423 ui::PAGE_TRANSITION_TYPED); 426 ui::PAGE_TRANSITION_TYPED);
424 LoadCommittedDetails details; 427 contents()->GetMainFrame()->PrepareForCommit();
425 cont.RendererDidNavigate(contents()->GetMainFrame(), params, &details); 428 contents()->GetMainFrame()->SendNavigateWithParams(&params);
426 // Also check title and url. 429 // Also check title and url.
427 EXPECT_EQ(base::ASCIIToUTF16(kUrl), contents()->GetTitle()); 430 EXPECT_EQ(base::ASCIIToUTF16(kUrl), contents()->GetTitle());
428 } 431 }
429 432
430 // Test to ensure UpdateMaxPageID is working properly. 433 // Test to ensure UpdateMaxPageID is working properly.
431 TEST_F(WebContentsImplTest, UpdateMaxPageID) { 434 TEST_F(WebContentsImplTest, UpdateMaxPageID) {
432 SiteInstance* instance1 = contents()->GetSiteInstance(); 435 SiteInstance* instance1 = contents()->GetSiteInstance();
433 scoped_refptr<SiteInstance> instance2(SiteInstance::Create(nullptr)); 436 scoped_refptr<SiteInstance> instance2(SiteInstance::Create(nullptr));
434 437
435 // Starts at -1. 438 // Starts at -1.
(...skipping 3006 matching lines...) Expand 10 before | Expand all | Expand 10 after
3442 // An automatic navigation. 3445 // An automatic navigation.
3443 contents()->GetMainFrame()->SendNavigateWithModificationCallback( 3446 contents()->GetMainFrame()->SendNavigateWithModificationCallback(
3444 2, 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); 3447 2, 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture));
3445 3448
3446 EXPECT_EQ(1u, delegate->reset_count()); 3449 EXPECT_EQ(1u, delegate->reset_count());
3447 3450
3448 contents()->SetJavaScriptDialogManagerForTesting(nullptr); 3451 contents()->SetJavaScriptDialogManagerForTesting(nullptr);
3449 } 3452 }
3450 3453
3451 } // namespace content 3454 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698