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

Side by Side Diff: ios/web/navigation/history_state_operations_inttest.mm

Issue 2602023002: Created test verifying no hashchange event for replaceState() calls. (Closed)
Patch Set: rebase + fixes 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/memory/ptr_util.h" 5 #include "base/memory/ptr_util.h"
6 #include "base/strings/string_number_conversions.h" 6 #include "base/strings/string_number_conversions.h"
7 #include "base/strings/sys_string_conversions.h" 7 #include "base/strings/sys_string_conversions.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/test/ios/wait_util.h" 9 #include "base/test/ios/wait_util.h"
10 #import "ios/web/navigation/navigation_item_impl.h" 10 #import "ios/web/navigation/navigation_item_impl.h"
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 GURL new_url = state_operations_url().Resolve("path"); 385 GURL new_url = state_operations_url().Resolve("path");
386 SetStateParams(new_state, empty_title, new_url); 386 SetStateParams(new_state, empty_title, new_url);
387 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kReplaceStateId)); 387 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kReplaceStateId));
388 // Verify that url has been replaced. 388 // Verify that url has been replaced.
389 base::test::ios::WaitUntilCondition(^bool { 389 base::test::ios::WaitUntilCondition(^bool {
390 return GetLastCommittedItem()->GetURL() == new_url; 390 return GetLastCommittedItem()->GetURL() == new_url;
391 }); 391 });
392 // Verify that the NavigationItem no longer has POST data. 392 // Verify that the NavigationItem no longer has POST data.
393 EXPECT_FALSE(GetLastCommittedItem()->HasPostData()); 393 EXPECT_FALSE(GetLastCommittedItem()->HasPostData());
394 } 394 }
395
396 // Tests that performing a replaceState() on a page where only the URL fragment
397 // is updated does not trigger a hashchange event.
398 TEST_F(HistoryStateOperationsTest, ReplaceStateNoHashChangeEvent) {
399 // Set up the state parameters and tap the replace state button.
400 std::string empty_state;
401 std::string empty_title;
402 GURL new_url = state_operations_url().Resolve("#hash");
403 SetStateParams(empty_state, empty_title, new_url);
404 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kReplaceStateId));
405 // Verify that url has been replaced.
406 base::test::ios::WaitUntilCondition(^bool {
407 return GetLastCommittedItem()->GetURL() == new_url;
408 });
409 // Verify that the hashchange event was not fired.
410 EXPECT_FALSE(static_cast<web::NavigationItemImpl*>(GetLastCommittedItem())
411 ->IsCreatedFromHashChange());
412 }
OLDNEW
« 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