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

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

Issue 2606003002: Created test for title replacement via window.history.replaceState(). (Closed)
Patch Set: 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 #import "base/mac/bind_objc_block.h" 5 #import "base/mac/bind_objc_block.h"
6 #include "base/memory/ptr_util.h" 6 #include "base/memory/ptr_util.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.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 #include "ios/web/public/navigation_item.h" 10 #include "ios/web/public/navigation_item.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 ASSERT_TRUE(IsOnLoadTextVisible()); 255 ASSERT_TRUE(IsOnLoadTextVisible());
256 SetStateParams(empty_state, empty_title, different_origin_url); 256 SetStateParams(empty_state, empty_title, different_origin_url);
257 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kPushStateID)); 257 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kPushStateID));
258 EXPECT_TRUE(LastOperationWasNoOp()); 258 EXPECT_TRUE(LastOperationWasNoOp());
259 LoadUrl(state_operations_url()); 259 LoadUrl(state_operations_url());
260 ASSERT_TRUE(IsOnLoadTextVisible()); 260 ASSERT_TRUE(IsOnLoadTextVisible());
261 SetStateParams(empty_state, empty_title, different_origin_url); 261 SetStateParams(empty_state, empty_title, different_origin_url);
262 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kReplaceStateID)); 262 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kReplaceStateID));
263 EXPECT_TRUE(LastOperationWasNoOp()); 263 EXPECT_TRUE(LastOperationWasNoOp());
264 } 264 }
265
266 // Tests that calling window.history.replaceState() with only a new title
267 // successfully replaces the current NavigationItem's title.
268 // TODO(crbug.com/677356): Enable this test once the NavigationItem's title is
269 // updated from within the web layer.
270 TEST_F(HistoryStateOperationsTest, DISABLED_TitleReplacement) {
271 // Navigate to about:blank then navigate back to the test page. The created
272 // NavigationItem can be used later to verify that the title is replaced
273 // rather than pushed.
274 GURL about_blank("about:blank");
275 LoadUrl(about_blank);
276 web::NavigationItem* about_blank_item = current_item();
277 ExpectPageLoad(state_operations_url());
278 navigation_manager()->GoBack();
279 WaitForPageToLoad();
280 ASSERT_EQ(state_operations_url(), current_item()->GetURL());
281 // Set up the state parameters and tap the replace state button.
282 std::string empty_state("");
Eugene But (OOO till 7-30) 2016/12/29 17:09:48 std::string empty_state;
kkhorimoto 2017/01/24 04:40:58 Done.
283 std::string new_title("NEW TITLE");
284 GURL empty_url("");
Eugene But (OOO till 7-30) 2016/12/29 17:09:48 GURL empty_url;
kkhorimoto 2017/01/24 04:40:58 Done.
285 SetStateParams(empty_state, new_title, empty_url);
286 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), kReplaceStateID));
287 // Verify that the title is reflected in the latest NavigationItem.
288 __block bool title_updated = false;
289 base::test::ios::WaitUntilCondition(^bool {
290 title_updated = current_item()->GetTitle() == ASCIIToUTF16(new_title);
Eugene But (OOO till 7-30) 2016/12/29 17:09:48 nit: |return current_item()->GetTitle() == ASCIITo
kkhorimoto 2017/01/24 04:40:58 Done.
291 return title_updated;
292 });
293 EXPECT_TRUE(title_updated);
Eugene But (OOO till 7-30) 2016/12/29 17:09:48 You don't need this. WaitUntilCondition will not s
kkhorimoto 2017/01/24 04:40:58 Done.
294 // Verify that the forward navigation was not pruned.
295 EXPECT_EQ(GetIndexOfNavigationItem(current_item()) + 1,
296 GetIndexOfNavigationItem(about_blank_item));
297 }
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