| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 kWindowLocationReloadID)); | 215 kWindowLocationReloadID)); |
| 216 }); | 216 }); |
| 217 | 217 |
| 218 // Verify that |kOnLoadText| is displayed and that no additional | 218 // Verify that |kOnLoadText| is displayed and that no additional |
| 219 // NavigationItems are added. | 219 // NavigationItems are added. |
| 220 EXPECT_TRUE(IsOnLoadTextVisible()); | 220 EXPECT_TRUE(IsOnLoadTextVisible()); |
| 221 EXPECT_EQ(1, navigation_manager()->GetItemCount()); | 221 EXPECT_EQ(1, navigation_manager()->GetItemCount()); |
| 222 } | 222 } |
| 223 | 223 |
| 224 // Tests that calling window.location.assign() creates a new NavigationItem. | 224 // Tests that calling window.location.assign() creates a new NavigationItem. |
| 225 TEST_F(WindowLocationTest, WindowLocationSetToDOMString) { | 225 #if TARGET_IPHONE_SIMULATOR |
| 226 #define MAYBE_WindowLocationSetToDOMString WindowLocationSetToDOMString |
| 227 #else |
| 228 #define MAYBE_WindowLocationSetToDOMString DISABLED_WindowLocationSetToDOMString |
| 229 #endif |
| 230 // TODO(crbug.com/731740): This test is disabled because it occasionally times |
| 231 // out on device. |
| 232 TEST_F(WindowLocationTest, MAYBE_WindowLocationSetToDOMString) { |
| 226 // Navigate to about:blank so there is a forward entry to prune. | 233 // Navigate to about:blank so there is a forward entry to prune. |
| 227 GURL about_blank("about:blank"); | 234 GURL about_blank("about:blank"); |
| 228 LoadUrl(about_blank); | 235 LoadUrl(about_blank); |
| 229 web::NavigationItem* about_blank_item = | 236 web::NavigationItem* about_blank_item = |
| 230 navigation_manager()->GetLastCommittedItem(); | 237 navigation_manager()->GetLastCommittedItem(); |
| 231 | 238 |
| 232 // Navigate back to the window.location test page. | 239 // Navigate back to the window.location test page. |
| 233 ExecuteBlockAndWaitForLoad(window_location_url(), ^{ | 240 ExecuteBlockAndWaitForLoad(window_location_url(), ^{ |
| 234 navigation_manager()->GoBack(); | 241 navigation_manager()->GoBack(); |
| 235 }); | 242 }); |
| 236 | 243 |
| 237 // Set the window.location test URL and tap the window.location.assign() | 244 // Set the window.location test URL and tap the window.location.assign() |
| 238 // button. | 245 // button. |
| 239 GURL sample_url = web::test::HttpServer::MakeUrl(kSampleFileBasedURL); | 246 GURL sample_url = web::test::HttpServer::MakeUrl(kSampleFileBasedURL); |
| 240 SetWindowLocationUrl(sample_url); | 247 SetWindowLocationUrl(sample_url); |
| 241 ExecuteBlockAndWaitForLoad(sample_url, ^{ | 248 ExecuteBlockAndWaitForLoad(sample_url, ^{ |
| 242 ASSERT_TRUE(web::test::TapWebViewElementWithId( | 249 ASSERT_TRUE(web::test::TapWebViewElementWithId( |
| 243 web_state(), kWindowLocationSetToDOMStringID)); | 250 web_state(), kWindowLocationSetToDOMStringID)); |
| 244 }); | 251 }); |
| 245 | 252 |
| 246 // Verify that |sample_url| was loaded and that |about_blank_item| was pruned. | 253 // Verify that |sample_url| was loaded and that |about_blank_item| was pruned. |
| 247 EXPECT_EQ(sample_url, navigation_manager()->GetLastCommittedItem()->GetURL()); | 254 EXPECT_EQ(sample_url, navigation_manager()->GetLastCommittedItem()->GetURL()); |
| 248 EXPECT_EQ(NSNotFound, GetIndexOfNavigationItem(about_blank_item)); | 255 EXPECT_EQ(NSNotFound, GetIndexOfNavigationItem(about_blank_item)); |
| 249 } | 256 } |
| OLD | NEW |