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