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

Unified Diff: ios/web/navigation/window_location_inttest.mm

Issue 2598133002: Created test for window.location.replace(). (Closed)
Patch Set: rebase Created 3 years, 11 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/navigation/window_location_inttest.mm
diff --git a/ios/web/navigation/window_location_inttest.mm b/ios/web/navigation/window_location_inttest.mm
index fb945a0a211df07752529f9fdba1805dfcbe689f..4e91f776861af486943e0b7012180303fd2da6e2 100644
--- a/ios/web/navigation/window_location_inttest.mm
+++ b/ios/web/navigation/window_location_inttest.mm
@@ -37,6 +37,7 @@
// Button IDs used in the window.location test page.
const char kWindowLocationAssignID[] = "location-assign";
+const char kWindowLocationReplaceID[] = "location-replace";
// JavaScript functions on the window.location test page.
NSString* const kUpdateURLScriptFormat = @"updateUrlToLoadText('%s')";
@@ -119,3 +120,35 @@ bool IsOnLoadTextVisible() {
EXPECT_EQ(sample_url, navigation_manager()->GetLastCommittedItem()->GetURL());
EXPECT_EQ(NSNotFound, GetIndexOfNavigationItem(about_blank_item));
}
+
+// Tests that calling window.location.replace() doesn't create a new
+// NavigationItem.
+// TODO(crbug.com/307072): Enable test when location.replace is fixed.
+TEST_F(WindowLocationTest, DISABLED_Replace) {
+ // Navigate to about:blank so there is a forward entry.
+ GURL about_blank("about:blank");
+ LoadUrl(about_blank);
+ web::NavigationItem* about_blank_item =
+ navigation_manager()->GetLastCommittedItem();
+
+ // Navigate back to the window.location test page.
+ ExecuteBlockAndWaitForLoad(window_location_url(), ^{
+ navigation_manager()->GoBack();
+ });
+
+ // Set the window.location test URL and tap the window.location.replace()
+ // button.
+ GURL sample_url = web::test::HttpServer::MakeUrl(kSampleFileBasedURL);
+ SetWindowLocationUrl(sample_url);
+ ExecuteBlockAndWaitForLoad(sample_url, ^{
+ ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(),
+ kWindowLocationReplaceID));
+ });
+
+ // Verify that |sample_url| was loaded and that |about_blank_item| was pruned.
+ web::NavigationItem* current_item =
+ navigation_manager()->GetLastCommittedItem();
+ EXPECT_EQ(sample_url, current_item->GetURL());
+ EXPECT_EQ(GetIndexOfNavigationItem(current_item) + 1,
+ GetIndexOfNavigationItem(about_blank_item));
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698