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

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

Issue 2607603005: Created test verifying resetting the state object after reloading. (Closed)
Patch Set: Created 4 years 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 8c0af0b77cbcaec5afecd7b21f3a904665cf85ef..d6e790bdc46580b257fb360e304530e19b0065cf 100644
--- a/ios/web/navigation/history_state_operations_inttest.mm
+++ b/ios/web/navigation/history_state_operations_inttest.mm
@@ -142,6 +142,15 @@ void LoadUrl(const GURL& url) {
WaitForPageToLoad();
}
+ // Reloads the page and waits for the load to finish.
+ void Reload() {
+ ExpectPageLoad(current_item()->GetURL());
+ // TODO(crbug.com/677364): Use NavigationManager::Reload() once it no longer
+ // requires a web delegate.
+ web_state()->ExecuteJavaScript(ASCIIToUTF16("window.location.reload()"));
+ WaitForPageToLoad();
+ }
+
// Set the parameters to use for state operations on the test page.
void SetStateParams(const std::string& state_object,
const std::string& title,
@@ -333,3 +342,33 @@ NSInteger GetIndexOfNavigationItem(const web::NavigationItem* item) {
EXPECT_EQ(GetIndexOfNavigationItem(current_item()) + 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("");
Eugene But (OOO till 7-30) 2016/12/29 17:15:27 std::string empty_title;
kkhorimoto 2017/01/24 05:15:36 Done.
+ GURL empty_url("");
Eugene But (OOO till 7-30) 2016/12/29 17:15:27 GURL empty_url;
kkhorimoto 2017/01/24 05:15:36 Done.
+ 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());
+ __block bool state_object_present = false;
+ base::string16 state_object_script = ASCIIToUTF16("window.history.state");
+ base::test::ios::TimeUntilCondition(
+ ^{
+ web_state()->ExecuteJavaScript(
Eugene But (OOO till 7-30) 2016/12/29 17:15:27 Could you please use synchronous API for this.
kkhorimoto 2017/01/24 05:15:36 Done.
+ state_object_script, base::BindBlock(^(const base::Value* result) {
+ std::string state;
+ result->GetAsString(&state);
+ state_object_present = state == new_state;
+ }));
+ },
+ ^bool {
+ return state_object_present;
+ },
+ false, base::TimeDelta::FromSeconds(10.0));
+ EXPECT_TRUE(state_object_present);
Eugene But (OOO till 7-30) 2016/12/29 17:15:27 No need for this check.
kkhorimoto 2017/01/24 05:15:36 Done.
+}
« 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