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

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

Issue 2607603005: Created test verifying resetting the state object after reloading. (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 d6d98b200b214cf4926e056d96fd73d80eb50632..c5d8cefa896781bcc0ea8b56d7344bea7744dbac 100644
--- a/ios/web/navigation/history_state_operations_inttest.mm
+++ b/ios/web/navigation/history_state_operations_inttest.mm
@@ -69,6 +69,15 @@ void SetUp() override {
// The URL of the window.location test page.
const GURL& state_operations_url() { return state_operations_url_; }
+ // Reloads the page and waits for the load to finish.
+ void Reload() {
+ ExecuteBlockAndWaitForLoad(GetLastCommittedItem()->GetURL(), ^{
+ // TODO(crbug.com/677364): Use NavigationManager::Reload() once it no
+ // longer requires a web delegate.
+ web_state()->ExecuteJavaScript(ASCIIToUTF16("window.location.reload()"));
+ });
+ }
+
// Sets the parameters to use for state operations on the test page. This
// function executes a script that populates JavaScript values on the test
// page. When the "push-state" or "replace-state" buttons are tapped, these
@@ -282,3 +291,20 @@ void WaitForNoOpText() {
EXPECT_EQ(GetIndexOfNavigationItem(GetLastCommittedItem()) + 1,
GetIndexOfNavigationItem(about_blank_item));
}
+
+// Tests that the state object is reset to the correct value after reloading a
+// page whose state has been replaced.
+TEST_F(HistoryStateOperationsTest, StateReplacementReload) {
+ // 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));
+ // Reload the page and check that the state object is present.
+ Reload();
+ 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