Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import "ios/web/navigation/crw_session_controller.h" | 5 #import "ios/web/navigation/crw_session_controller.h" |
| 6 | 6 |
| 7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1229 [session_controller_ | 1229 [session_controller_ |
| 1230 addPendingItem:GURL("http://www.example.com/0") | 1230 addPendingItem:GURL("http://www.example.com/0") |
| 1231 referrer:MakeReferrer("http://www.example.com/b") | 1231 referrer:MakeReferrer("http://www.example.com/b") |
| 1232 transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT | 1232 transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT |
| 1233 initiationType:web::NavigationInitiationType::RENDERER_INITIATED | 1233 initiationType:web::NavigationInitiationType::RENDERER_INITIATED |
| 1234 userAgentOverrideOption:UserAgentOverrideOption::INHERIT]; | 1234 userAgentOverrideOption:UserAgentOverrideOption::INHERIT]; |
| 1235 [session_controller_ commitPendingItem]; | 1235 [session_controller_ commitPendingItem]; |
| 1236 EXPECT_EQ(0U, [session_controller_ backwardItems].size()); | 1236 EXPECT_EQ(0U, [session_controller_ backwardItems].size()); |
| 1237 } | 1237 } |
| 1238 | 1238 |
| 1239 // Tests that |-backwardItems| returns all committed items if there is an | |
| 1240 // uncommitted pending item. This can happend if the pending page loading is | |
| 1241 // intercepted by safe browsing. See crbug.com/691311. | |
| 1242 TEST_F(CRWSessionControllerTest, | |
| 1243 BackwardItemsShouldContainAllCommittedIfCurrentIsPending) { | |
| 1244 [session_controller_ | |
| 1245 addPendingItem:GURL("http://www.example.com/0") | |
| 1246 referrer:MakeReferrer("http://www.example.com/a") | |
| 1247 transition:ui::PAGE_TRANSITION_LINK | |
| 1248 initiationType:web::NavigationInitiationType::USER_INITIATED | |
| 1249 userAgentOverrideOption:UserAgentOverrideOption::INHERIT]; | |
| 1250 [session_controller_ commitPendingItem]; | |
| 1251 [session_controller_ | |
| 1252 addPendingItem:GURL("http://www.example.com/1") | |
| 1253 referrer:MakeReferrer("http://www.example.com/b") | |
| 1254 transition:ui::PAGE_TRANSITION_LINK | |
| 1255 initiationType:web::NavigationInitiationType::USER_INITIATED | |
| 1256 userAgentOverrideOption:UserAgentOverrideOption::INHERIT]; | |
| 1257 | |
| 1258 EXPECT_EQ(0, session_controller_.get().lastCommittedItemIndex); | |
| 1259 EXPECT_TRUE([session_controller_ pendingItem]); | |
| 1260 EXPECT_EQ(-1, [session_controller_ pendingItemIndex]); | |
| 1261 EXPECT_EQ(GURL("http://www.example.com/1"), [session_controller_ currentURL]); | |
| 1262 | |
| 1263 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
| |
| 1264 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.
| |
| 1265 EXPECT_EQ("http://www.example.com/0", backItems[0]->GetURL().spec()); | |
| 1266 } | |
| 1267 | |
| 1268 // Tests that |-backwardItems| returns all committed items if there is a | |
| 1269 // transient item. This can happen if an intersitial was loaded for safe | |
| 1270 // browsing. See crbug.com/691311. | |
| 1271 TEST_F(CRWSessionControllerTest, | |
| 1272 BackwardItemsShouldContainAllCommittedIfCurrentIsTransient) { | |
| 1273 [session_controller_ | |
| 1274 addPendingItem:GURL("http://www.example.com/0") | |
| 1275 referrer:MakeReferrer("http://www.example.com/a") | |
| 1276 transition:ui::PAGE_TRANSITION_LINK | |
| 1277 initiationType:web::NavigationInitiationType::USER_INITIATED | |
| 1278 userAgentOverrideOption:UserAgentOverrideOption::INHERIT]; | |
| 1279 [session_controller_ commitPendingItem]; | |
| 1280 [session_controller_ | |
| 1281 addTransientItemWithURL:GURL("http://www.example.com/1")]; | |
| 1282 | |
| 1283 EXPECT_EQ(0, session_controller_.get().lastCommittedItemIndex); | |
| 1284 EXPECT_TRUE([session_controller_ transientItem]); | |
| 1285 EXPECT_EQ(GURL("http://www.example.com/1"), [session_controller_ currentURL]); | |
| 1286 | |
| 1287 web::NavigationItemList backItems = [session_controller_ backwardItems]; | |
| 1288 EXPECT_EQ(1U, backItems.size()); | |
| 1289 EXPECT_EQ("http://www.example.com/0", backItems[0]->GetURL().spec()); | |
| 1290 } | |
| 1291 | |
| 1239 } // anonymous namespace | 1292 } // anonymous namespace |
| OLD | NEW |