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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 // Verify that the url with the path is pushed. | 363 // Verify that the url with the path is pushed. |
364 base::test::ios::WaitUntilCondition(^bool { | 364 base::test::ios::WaitUntilCondition(^bool { |
365 return GetLastCommittedItem()->GetURL() == new_url; | 365 return GetLastCommittedItem()->GetURL() == new_url; |
366 }); | 366 }); |
367 // Verify that a new NavigationItem was created and that the forward item was | 367 // Verify that a new NavigationItem was created and that the forward item was |
368 // pruned. | 368 // pruned. |
369 EXPECT_EQ(GetIndexOfNavigationItem(non_pushed_item) + 1, | 369 EXPECT_EQ(GetIndexOfNavigationItem(non_pushed_item) + 1, |
370 GetIndexOfNavigationItem(GetLastCommittedItem())); | 370 GetIndexOfNavigationItem(GetLastCommittedItem())); |
371 EXPECT_EQ(NSNotFound, GetIndexOfNavigationItem(about_blank_item)); | 371 EXPECT_EQ(NSNotFound, GetIndexOfNavigationItem(about_blank_item)); |
372 } | 372 } |
| 373 |
| 374 // Tests that performing a replaceState() on a page created with a POST request |
| 375 // resets the page to a GET request. |
| 376 TEST_F(HistoryStateOperationsTest, ReplaceStatePostRequest) { |
| 377 // Add POST data to the current NavigationItem. |
| 378 base::scoped_nsobject<NSData> post_data([NSData data]); |
| 379 static_cast<web::NavigationItemImpl*>(GetLastCommittedItem()) |
| 380 ->SetPostData(post_data); |
| 381 ASSERT_TRUE(GetLastCommittedItem()->HasPostData()); |
| 382 // Set up the state parameters and tap the replace state button. |
| 383 std::string new_state("STATE OBJECT"); |
| 384 std::string empty_title; |
| 385 GURL new_url = state_operations_url().Resolve("path"); |
| 386 SetStateParams(new_state, empty_title, new_url); |
| 387 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kReplaceStateId)); |
| 388 // Verify that url has been replaced. |
| 389 base::test::ios::WaitUntilCondition(^bool { |
| 390 return GetLastCommittedItem()->GetURL() == new_url; |
| 391 }); |
| 392 // Verify that the NavigationItem no longer has POST data. |
| 393 EXPECT_FALSE(GetLastCommittedItem()->HasPostData()); |
| 394 } |
OLD | NEW |