Chromium Code Reviews| Index: ios/web/navigation/crw_session_controller_unittest.mm |
| diff --git a/ios/web/navigation/crw_session_controller_unittest.mm b/ios/web/navigation/crw_session_controller_unittest.mm |
| index b23a26b5f028a90b09e4f5c02ba2d44d5adf758d..029213e9d33a1838b50f7129bd5135ca6021a596 100644 |
| --- a/ios/web/navigation/crw_session_controller_unittest.mm |
| +++ b/ios/web/navigation/crw_session_controller_unittest.mm |
| @@ -1236,4 +1236,57 @@ TEST_F(CRWSessionControllerTest, BackwardItemsForAllRedirects) { |
| EXPECT_EQ(0U, [session_controller_ backwardItems].size()); |
| } |
| +// Tests that |-backwardItems| returns all committed items if there is an |
| +// uncommitted pending item. This can happend if the pending page loading is |
| +// intercepted by safe browsing. See crbug.com/691311. |
| +TEST_F(CRWSessionControllerTest, |
| + BackwardItemsShouldContainAllCommittedIfCurrentIsPending) { |
| + [session_controller_ |
| + addPendingItem:GURL("http://www.example.com/0") |
| + referrer:MakeReferrer("http://www.example.com/a") |
| + transition:ui::PAGE_TRANSITION_LINK |
| + initiationType:web::NavigationInitiationType::USER_INITIATED |
| + userAgentOverrideOption:UserAgentOverrideOption::INHERIT]; |
| + [session_controller_ commitPendingItem]; |
| + [session_controller_ |
| + addPendingItem:GURL("http://www.example.com/1") |
| + referrer:MakeReferrer("http://www.example.com/b") |
| + transition:ui::PAGE_TRANSITION_LINK |
| + initiationType:web::NavigationInitiationType::USER_INITIATED |
| + userAgentOverrideOption:UserAgentOverrideOption::INHERIT]; |
| + |
| + EXPECT_EQ(0, session_controller_.get().lastCommittedItemIndex); |
| + EXPECT_TRUE([session_controller_ pendingItem]); |
| + EXPECT_EQ(-1, [session_controller_ pendingItemIndex]); |
| + EXPECT_EQ(GURL("http://www.example.com/1"), [session_controller_ currentURL]); |
| + |
| + web::NavigationItemList backItems = [session_controller_ backwardItems]; |
|
Eugene But (OOO till 7-30)
2017/04/25 05:49:01
s/backItems/back_items
https://chromium.googlesou
danyao
2017/04/25 16:31:20
Done.
danyao
2017/04/25 16:31:20
Oops sorry confused Objective C and JavaScript sty
|
| + EXPECT_EQ(1U, backItems.size()); |
|
Eugene But (OOO till 7-30)
2017/04/25 05:49:01
s/EXPECT_EQ/ASSERT_EQ, otherwise line 1265 may cra
danyao
2017/04/25 16:31:20
Done.
danyao
2017/04/25 16:31:20
Done.
|
| + EXPECT_EQ("http://www.example.com/0", backItems[0]->GetURL().spec()); |
| +} |
| + |
| +// Tests that |-backwardItems| returns all committed items if there is a |
| +// transient item. This can happen if an intersitial was loaded for safe |
| +// browsing. See crbug.com/691311. |
| +TEST_F(CRWSessionControllerTest, |
| + BackwardItemsShouldContainAllCommittedIfCurrentIsTransient) { |
| + [session_controller_ |
| + addPendingItem:GURL("http://www.example.com/0") |
| + referrer:MakeReferrer("http://www.example.com/a") |
| + transition:ui::PAGE_TRANSITION_LINK |
| + initiationType:web::NavigationInitiationType::USER_INITIATED |
| + userAgentOverrideOption:UserAgentOverrideOption::INHERIT]; |
| + [session_controller_ commitPendingItem]; |
| + [session_controller_ |
| + addTransientItemWithURL:GURL("http://www.example.com/1")]; |
| + |
| + EXPECT_EQ(0, session_controller_.get().lastCommittedItemIndex); |
| + EXPECT_TRUE([session_controller_ transientItem]); |
| + EXPECT_EQ(GURL("http://www.example.com/1"), [session_controller_ currentURL]); |
| + |
| + web::NavigationItemList backItems = [session_controller_ backwardItems]; |
| + EXPECT_EQ(1U, backItems.size()); |
| + EXPECT_EQ("http://www.example.com/0", backItems[0]->GetURL().spec()); |
| +} |
| + |
| } // anonymous namespace |