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

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

Issue 2602023002: Created test verifying no hashchange event for replaceState() calls. (Closed)
Patch Set: rebase + fixes 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/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 d823e70b61b9e497f9cf2ccad7d9b57df776d3e0..88cf460e25434131019335143948add5a4aad046 100644
--- a/ios/web/navigation/history_state_operations_inttest.mm
+++ b/ios/web/navigation/history_state_operations_inttest.mm
@@ -392,3 +392,21 @@ void WaitForNoOpText() {
// Verify that the NavigationItem no longer has POST data.
EXPECT_FALSE(GetLastCommittedItem()->HasPostData());
}
+
+// Tests that performing a replaceState() on a page where only the URL fragment
+// is updated does not trigger a hashchange event.
+TEST_F(HistoryStateOperationsTest, ReplaceStateNoHashChangeEvent) {
+ // Set up the state parameters and tap the replace state button.
+ std::string empty_state;
+ std::string empty_title;
+ GURL new_url = state_operations_url().Resolve("#hash");
+ SetStateParams(empty_state, empty_title, new_url);
+ ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kReplaceStateId));
+ // Verify that url has been replaced.
+ base::test::ios::WaitUntilCondition(^bool {
+ return GetLastCommittedItem()->GetURL() == new_url;
+ });
+ // Verify that the hashchange event was not fired.
+ EXPECT_FALSE(static_cast<web::NavigationItemImpl*>(GetLastCommittedItem())
+ ->IsCreatedFromHashChange());
+}
« 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