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

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

Issue 2606003002: Created test for title replacement via window.history.replaceState(). (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 9d01423902c93db8ddfc184fe73751b653e59541..2889de6453b4cc0239f8c47745597307617d9ffa 100644
--- a/ios/web/navigation/history_state_operations_inttest.mm
+++ b/ios/web/navigation/history_state_operations_inttest.mm
@@ -4,6 +4,7 @@
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/test/ios/wait_util.h"
#import "ios/web/public/navigation_item.h"
#import "ios/web/public/navigation_manager.h"
@@ -16,6 +17,8 @@
#include "testing/gtest_mac.h"
#include "url/url_canon.h"
+using base::ASCIIToUTF16;
+
namespace {
// URL for the test window.location test file. The page at this URL contains
@@ -205,3 +208,33 @@ void WaitForNoOpText() {
ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kReplaceStateId));
WaitForNoOpText();
}
+
+// Tests that calling window.history.replaceState() with only a new title
+// successfully replaces the current NavigationItem's title.
+// TODO(crbug.com/677356): Enable this test once the NavigationItem's title is
+// updated from within the web layer.
+TEST_F(HistoryStateOperationsTest, DISABLED_TitleReplacement) {
+ // Navigate to about:blank then navigate back to the test page. The created
+ // NavigationItem can be used later to verify that the title is replaced
+ // rather than pushed.
+ GURL about_blank("about:blank");
+ LoadUrl(about_blank);
+ web::NavigationItem* about_blank_item = GetLastCommittedItem();
+ ExecuteBlockAndWaitForLoad(state_operations_url(), ^{
+ navigation_manager()->GoBack();
+ });
+ EXPECT_EQ(state_operations_url(), GetLastCommittedItem()->GetURL());
+ // Set up the state parameters and tap the replace state button.
+ std::string empty_state;
+ std::string new_title("NEW TITLE");
+ GURL empty_url;
+ SetStateParams(empty_state, new_title, empty_url);
+ ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kReplaceStateId));
+ // Wait for the title to be reflected in the NavigationItem.
+ base::test::ios::WaitUntilCondition(^bool {
+ return GetLastCommittedItem()->GetTitle() == ASCIIToUTF16(new_title);
+ });
+ // Verify that the forward navigation was not pruned.
+ EXPECT_EQ(GetIndexOfNavigationItem(GetLastCommittedItem()) + 1,
+ 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