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

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

Issue 2594363003: Created a test for assigning a string to window.location. (Closed)
Patch Set: rebase 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/window_location_inttest.mm
diff --git a/ios/web/navigation/window_location_inttest.mm b/ios/web/navigation/window_location_inttest.mm
index b3e31d534be0f7bf7ad498715064de86463e9614..fcfe4f712870f6c6e22df398a2ca13c7281195fd 100644
--- a/ios/web/navigation/window_location_inttest.mm
+++ b/ios/web/navigation/window_location_inttest.mm
@@ -39,6 +39,7 @@
const char kWindowLocationAssignID[] = "location-assign";
const char kWindowLocationReplaceID[] = "location-replace";
const char kWindowLocationReloadID[] = "location-reload";
+const char kWindowLocationSetToDOMStringID[] = "set-location-to-dom-string";
// JavaScript functions on the window.location test page.
NSString* const kUpdateURLScriptFormat = @"updateUrlToLoadText('%s')";
@@ -201,3 +202,30 @@ bool IsOnLoadTextVisible() {
EXPECT_TRUE(IsOnLoadTextVisible());
EXPECT_EQ(1, navigation_manager()->GetItemCount());
}
+
+// Tests that calling window.location.assign() creates a new NavigationItem.
+TEST_F(WindowLocationTest, WindowLocationSetToDOMString) {
+ // Navigate to about:blank so there is a forward entry to prune.
+ GURL about_blank("about:blank");
+ LoadUrl(about_blank);
+ web::NavigationItem* about_blank_item =
+ navigation_manager()->GetLastCommittedItem();
+
+ // Navigate back to the window.location test page.
+ ExecuteBlockAndWaitForLoad(window_location_url(), ^{
+ navigation_manager()->GoBack();
+ });
+
+ // Set the window.location test URL and tap the window.location.assign()
+ // button.
+ GURL sample_url = web::test::HttpServer::MakeUrl(kSampleFileBasedURL);
+ SetWindowLocationUrl(sample_url);
+ ExecuteBlockAndWaitForLoad(sample_url, ^{
+ ASSERT_TRUE(web::test::TapWebViewElementWithId(
+ web_state(), kWindowLocationSetToDOMStringID));
+ });
+
+ // Verify that |sample_url| was loaded and that |about_blank_item| was pruned.
+ EXPECT_EQ(sample_url, navigation_manager()->GetLastCommittedItem()->GetURL());
+ EXPECT_EQ(NSNotFound, GetIndexOfNavigationItem(about_blank_item));
+}
« 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