| 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));
|
| +}
|
|
|