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

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

Issue 2604123002: Created test for window.history.pushState(). (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 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 navigation_manager()->GoForward(); 332 navigation_manager()->GoForward();
333 }); 333 });
334 ExecuteBlockAndWaitForLoad(state_operations_url(), ^{ 334 ExecuteBlockAndWaitForLoad(state_operations_url(), ^{
335 navigation_manager()->GoBack(); 335 navigation_manager()->GoBack();
336 }); 336 });
337 ASSERT_TRUE(IsOnLoadTextVisible()); 337 ASSERT_TRUE(IsOnLoadTextVisible());
338 base::test::ios::WaitUntilCondition(^bool { 338 base::test::ios::WaitUntilCondition(^bool {
339 return GetJavaScriptState() == new_state; 339 return GetJavaScriptState() == new_state;
340 }); 340 });
341 } 341 }
342
343 // Tests that calling window.history.pushState() creates a new NavigationItem
344 // and prunes trailing items.
345 TEST_F(HistoryStateOperationsTest, PushState) {
346 // Navigate to about:blank then navigate back to the test page. The created
347 // NavigationItem can be used later to verify that the state is replaced
348 // rather than pushed.
349 GURL about_blank("about:blank");
350 LoadUrl(about_blank);
351 web::NavigationItem* about_blank_item = GetLastCommittedItem();
352 ExecuteBlockAndWaitForLoad(state_operations_url(), ^{
Eugene But (OOO till 7-30) 2017/01/24 19:26:37 Not related to this CL, but ExecuteBlockAndWaitFor
353 navigation_manager()->GoBack();
354 });
355 ASSERT_EQ(state_operations_url(), GetLastCommittedItem()->GetURL());
356 web::NavigationItem* non_pushed_item = GetLastCommittedItem();
357 // Set up the state parameters and tap the replace state button.
358 std::string empty_state;
359 std::string empty_title;
360 GURL new_url = state_operations_url().Resolve("path");
361 SetStateParams(empty_state, empty_title, new_url);
362 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kPushStateId));
363 // Verify that the url with the path is pushed.
364 base::test::ios::WaitUntilCondition(^bool {
365 return GetLastCommittedItem()->GetURL() == new_url;
366 });
367 // Verify that a new NavigationItem was created and that the forward item was
368 // pruned.
369 EXPECT_EQ(GetIndexOfNavigationItem(non_pushed_item) + 1,
370 GetIndexOfNavigationItem(GetLastCommittedItem()));
371 EXPECT_EQ(NSNotFound, GetIndexOfNavigationItem(about_blank_item));
372 }
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