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

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

Issue 2604103002: Created test for restoring state object after back/forward navigation. (Closed)
Patch Set: rebase + eugene's comments 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 c5d8cefa896781bcc0ea8b56d7344bea7744dbac..afd2c86dc0991329f1fbade03b40acf4a56aee24 100644
--- a/ios/web/navigation/history_state_operations_inttest.mm
+++ b/ios/web/navigation/history_state_operations_inttest.mm
@@ -308,3 +308,34 @@ void WaitForNoOpText() {
return GetJavaScriptState() == new_state;
});
}
+
+// Tests that the state object is correctly set for a page after a back/forward
+// navigation.
+TEST_F(HistoryStateOperationsTest, StateReplacementBackForward) {
+ // Navigate to about:blank then navigate back to the test page. The created
+ // NavigationItem can be used later to verify that the state is replaced
+ // rather than pushed.
+ GURL about_blank("about:blank");
+ LoadUrl(about_blank);
+ ExecuteBlockAndWaitForLoad(state_operations_url(), ^{
+ navigation_manager()->GoBack();
+ });
+ ASSERT_EQ(state_operations_url(), GetLastCommittedItem()->GetURL());
+ // Set up the state parameters and tap the replace state button.
+ std::string new_state("STATE OBJECT");
+ std::string empty_title("");
+ GURL empty_url("");
+ SetStateParams(new_state, empty_title, empty_url);
+ ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kReplaceStateId));
+ // Go forward and back, then check that the state object is present.
+ ExecuteBlockAndWaitForLoad(about_blank, ^{
+ navigation_manager()->GoForward();
+ });
+ ExecuteBlockAndWaitForLoad(state_operations_url(), ^{
+ navigation_manager()->GoBack();
+ });
+ ASSERT_TRUE(IsOnLoadTextVisible());
+ base::test::ios::WaitUntilCondition(^bool {
+ return GetJavaScriptState() == new_state;
+ });
+}
« 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