Chromium Code Reviews| 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 88feaf519e6203a7164943397bfa7a840e077303..52cc4f2a149fd0cced972562b09fc14a0ba1fe08 100644 |
| --- a/ios/web/navigation/history_state_operations_inttest.mm |
| +++ b/ios/web/navigation/history_state_operations_inttest.mm |
| @@ -262,3 +262,36 @@ NSInteger GetIndexOfNavigationItem(const web::NavigationItem* item) { |
| ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kReplaceStateID)); |
| EXPECT_TRUE(LastOperationWasNoOp()); |
| } |
| + |
| +// 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 = current_item(); |
| + ExpectPageLoad(state_operations_url()); |
| + navigation_manager()->GoBack(); |
| + WaitForPageToLoad(); |
| + ASSERT_EQ(state_operations_url(), current_item()->GetURL()); |
| + // Set up the state parameters and tap the replace state button. |
| + std::string empty_state(""); |
|
Eugene But (OOO till 7-30)
2016/12/29 17:09:48
std::string empty_state;
kkhorimoto
2017/01/24 04:40:58
Done.
|
| + std::string new_title("NEW TITLE"); |
| + GURL empty_url(""); |
|
Eugene But (OOO till 7-30)
2016/12/29 17:09:48
GURL empty_url;
kkhorimoto
2017/01/24 04:40:58
Done.
|
| + SetStateParams(empty_state, new_title, empty_url); |
| + ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kReplaceStateID)); |
| + // Verify that the title is reflected in the latest NavigationItem. |
| + __block bool title_updated = false; |
| + base::test::ios::WaitUntilCondition(^bool { |
| + title_updated = current_item()->GetTitle() == ASCIIToUTF16(new_title); |
|
Eugene But (OOO till 7-30)
2016/12/29 17:09:48
nit: |return current_item()->GetTitle() == ASCIITo
kkhorimoto
2017/01/24 04:40:58
Done.
|
| + return title_updated; |
| + }); |
| + EXPECT_TRUE(title_updated); |
|
Eugene But (OOO till 7-30)
2016/12/29 17:09:48
You don't need this. WaitUntilCondition will not s
kkhorimoto
2017/01/24 04:40:58
Done.
|
| + // Verify that the forward navigation was not pruned. |
| + EXPECT_EQ(GetIndexOfNavigationItem(current_item()) + 1, |
| + GetIndexOfNavigationItem(about_blank_item)); |
| +} |