OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |