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

Unified Diff: ios/web/web_state/ui/crw_web_controller_unittest.mm

Issue 2757043002: Fix NavigationItem use-after-free crash in |-goToItemAtIndex:| (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/ui/crw_web_controller_unittest.mm
diff --git a/ios/web/web_state/ui/crw_web_controller_unittest.mm b/ios/web/web_state/ui/crw_web_controller_unittest.mm
index eba3aebc218e582d3b4abdf75098d617ab49057a..70497eda82d98ee7663a797ab588aad8a46ffd83 100644
--- a/ios/web/web_state/ui/crw_web_controller_unittest.mm
+++ b/ios/web/web_state/ui/crw_web_controller_unittest.mm
@@ -50,8 +50,8 @@
@interface CRWWebController (PrivateAPI)
@property(nonatomic, readwrite) web::PageDisplayState pageDisplayState;
-- (GURL)URLForHistoryNavigationFromItem:(web::NavigationItem*)fromItem
- toItem:(web::NavigationItem*)toItem;
+- (GURL)URLForHistoryNavigationToItem:(web::NavigationItem*)toItem
+ previousURL:(const GURL&)previousURL;
@end
// Used to mock CRWWebDelegate methods with C++ params.
@@ -276,27 +276,28 @@ CGRect ExpectedWebViewFrame() const {
[urlsWithFragments addObject:[url stringByAppendingString:fragment]];
}
}
- web::NavigationItemImpl fromItem;
+
+ GURL previous_url;
web::NavigationItemImpl toItem;
// No start fragment: the end url is never changed.
for (NSString* start in urlsNoFragments) {
for (NSString* end in urlsWithFragments) {
- fromItem.SetURL(MAKE_URL(start));
+ previous_url = MAKE_URL(start);
toItem.SetURL(MAKE_URL(end));
EXPECT_EQ(MAKE_URL(end),
- [web_controller() URLForHistoryNavigationFromItem:&fromItem
- toItem:&toItem]);
+ [web_controller() URLForHistoryNavigationToItem:&toItem
+ previousURL:previous_url]);
}
}
// Both contain fragments: the end url is never changed.
for (NSString* start in urlsWithFragments) {
for (NSString* end in urlsWithFragments) {
- fromItem.SetURL(MAKE_URL(start));
+ previous_url = MAKE_URL(start);
toItem.SetURL(MAKE_URL(end));
EXPECT_EQ(MAKE_URL(end),
- [web_controller() URLForHistoryNavigationFromItem:&fromItem
- toItem:&toItem]);
+ [web_controller() URLForHistoryNavigationToItem:&toItem
+ previousURL:previous_url]);
}
}
for (unsigned start_index = 0; start_index < [urlsWithFragments count];
@@ -305,21 +306,22 @@ CGRect ExpectedWebViewFrame() const {
for (unsigned end_index = 0; end_index < [urlsNoFragments count];
++end_index) {
NSString* end = urlsNoFragments[end_index];
+ previous_url = MAKE_URL(start);
if (start_index / 2 != end_index) {
// The URLs have nothing in common, they are left untouched.
- fromItem.SetURL(MAKE_URL(start));
toItem.SetURL(MAKE_URL(end));
- EXPECT_EQ(MAKE_URL(end),
- [web_controller() URLForHistoryNavigationFromItem:&fromItem
- toItem:&toItem]);
+ EXPECT_EQ(
+ MAKE_URL(end),
+ [web_controller() URLForHistoryNavigationToItem:&toItem
+ previousURL:previous_url]);
} else {
// Start contains a fragment and matches end: An empty fragment is
// added.
- fromItem.SetURL(MAKE_URL(start));
toItem.SetURL(MAKE_URL(end));
- EXPECT_EQ(MAKE_URL([end stringByAppendingString:@"#"]),
- [web_controller() URLForHistoryNavigationFromItem:&fromItem
- toItem:&toItem]);
+ EXPECT_EQ(
+ MAKE_URL([end stringByAppendingString:@"#"]),
+ [web_controller() URLForHistoryNavigationToItem:&toItem
+ previousURL:previous_url]);
}
}
}
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698