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

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

Issue 2601503003: Created test for window.location.replace() with unresolvable URLs. (Closed)
Patch Set: rebase 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/mac/foundation_util.h" 6 #include "base/mac/foundation_util.h"
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #import "base/strings/sys_string_conversions.h" 8 #import "base/strings/sys_string_conversions.h"
9 #include "base/test/ios/wait_util.h" 9 #include "base/test/ios/wait_util.h"
10 #import "ios/web/public/navigation_item.h" 10 #import "ios/web/public/navigation_item.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 kWindowLocationReplaceID)); 162 kWindowLocationReplaceID));
163 }); 163 });
164 164
165 // Verify that |sample_url| was loaded and that |about_blank_item| was pruned. 165 // Verify that |sample_url| was loaded and that |about_blank_item| was pruned.
166 web::NavigationItem* current_item = 166 web::NavigationItem* current_item =
167 navigation_manager()->GetLastCommittedItem(); 167 navigation_manager()->GetLastCommittedItem();
168 EXPECT_EQ(sample_url, current_item->GetURL()); 168 EXPECT_EQ(sample_url, current_item->GetURL());
169 EXPECT_EQ(GetIndexOfNavigationItem(current_item) + 1, 169 EXPECT_EQ(GetIndexOfNavigationItem(current_item) + 1,
170 GetIndexOfNavigationItem(about_blank_item)); 170 GetIndexOfNavigationItem(about_blank_item));
171 } 171 }
172
173 // Tests that calling window.location.replace() with an unresolvable URL loads
174 // about:blank.
175 TEST_F(WindowLocationTest, WindowLocationReplaceUnresolvable) {
176 // Attempt to call window.location.assign() using an unresolvable URL.
177 GURL about_blank("about:blank");
178 GURL unresolvable_url("http:https:not a url");
179 SetWindowLocationUrl(unresolvable_url);
180 ExecuteBlockAndWaitForLoad(about_blank, ^{
181 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(),
182 kWindowLocationReplaceID));
183 });
184
185 // Verify that about:blank was actually loaded.
186 EXPECT_EQ(about_blank,
187 navigation_manager()->GetLastCommittedItem()->GetURL());
188 }
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