| Index: ios/web/navigation/history_state_operations_inttest.mm
|
| diff --git a/ios/web/navigation/history_state_operations_inttest.mm b/ios/web/navigation/history_state_operations_inttest.mm
|
| index 9d01423902c93db8ddfc184fe73751b653e59541..2889de6453b4cc0239f8c47745597307617d9ffa 100644
|
| --- a/ios/web/navigation/history_state_operations_inttest.mm
|
| +++ b/ios/web/navigation/history_state_operations_inttest.mm
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "base/memory/ptr_util.h"
|
| #include "base/strings/string_number_conversions.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| #include "base/test/ios/wait_util.h"
|
| #import "ios/web/public/navigation_item.h"
|
| #import "ios/web/public/navigation_manager.h"
|
| @@ -16,6 +17,8 @@
|
| #include "testing/gtest_mac.h"
|
| #include "url/url_canon.h"
|
|
|
| +using base::ASCIIToUTF16;
|
| +
|
| namespace {
|
|
|
| // URL for the test window.location test file. The page at this URL contains
|
| @@ -205,3 +208,33 @@ void WaitForNoOpText() {
|
| ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kReplaceStateId));
|
| WaitForNoOpText();
|
| }
|
| +
|
| +// Tests that calling window.history.replaceState() with only a new title
|
| +// successfully replaces the current NavigationItem's title.
|
| +// TODO(crbug.com/677356): Enable this test once the NavigationItem's title is
|
| +// updated from within the web layer.
|
| +TEST_F(HistoryStateOperationsTest, DISABLED_TitleReplacement) {
|
| + // Navigate to about:blank then navigate back to the test page. The created
|
| + // NavigationItem can be used later to verify that the title is replaced
|
| + // rather than pushed.
|
| + GURL about_blank("about:blank");
|
| + LoadUrl(about_blank);
|
| + web::NavigationItem* about_blank_item = GetLastCommittedItem();
|
| + ExecuteBlockAndWaitForLoad(state_operations_url(), ^{
|
| + navigation_manager()->GoBack();
|
| + });
|
| + EXPECT_EQ(state_operations_url(), GetLastCommittedItem()->GetURL());
|
| + // Set up the state parameters and tap the replace state button.
|
| + std::string empty_state;
|
| + std::string new_title("NEW TITLE");
|
| + GURL empty_url;
|
| + SetStateParams(empty_state, new_title, empty_url);
|
| + ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kReplaceStateId));
|
| + // Wait for the title to be reflected in the NavigationItem.
|
| + base::test::ios::WaitUntilCondition(^bool {
|
| + return GetLastCommittedItem()->GetTitle() == ASCIIToUTF16(new_title);
|
| + });
|
| + // Verify that the forward navigation was not pruned.
|
| + EXPECT_EQ(GetIndexOfNavigationItem(GetLastCommittedItem()) + 1,
|
| + GetIndexOfNavigationItem(about_blank_item));
|
| +}
|
|
|