Index: ios/web/web_state/ui/crw_web_controller_unittest.mm |
diff --git a/ios/web/web_state/ui/crw_web_controller_unittest.mm b/ios/web/web_state/ui/crw_web_controller_unittest.mm |
index 1526b068e11234dfd68495d839e620524b93ed6d..c260ab6ab0335f390ca4e39c046374c0c11aefe7 100644 |
--- a/ios/web/web_state/ui/crw_web_controller_unittest.mm |
+++ b/ios/web/web_state/ui/crw_web_controller_unittest.mm |
@@ -889,6 +889,29 @@ TEST_F(CRWWebControllerNativeContentTest, NativeContentVirtualURL) { |
virtual_url); |
} |
+// Tests WebState and NavigationManager correctly return native content URL. |
+TEST_F(CRWWebControllerNativeContentTest, FallbackNativeContentURL) { |
+ GURL url_to_load(kTestURLString); |
+ GURL fallback_url(kTestAppSpecificURL); |
+ base::scoped_nsobject<TestNativeContent> content([[TestNativeContent alloc] |
+ initWithURL:fallback_url |
+ virtualURL:url_to_load]); |
+ [mock_native_provider_ setController:content forURL:fallback_url]; |
+ Load(url_to_load); |
+ web::URLVerificationTrustLevel trust_level = web::kNone; |
+ [web_controller() loadNativeContentFallback:fallback_url]; |
+ GURL gurl = [web_controller() currentURLWithTrustLevel:&trust_level]; |
+ EXPECT_EQ(web::kAbsolute, trust_level); |
+ EXPECT_EQ([web_controller() webState]->GetVisibleURL(), url_to_load); |
+ NavigationManagerImpl& navigationManager = |
+ [web_controller() webStateImpl]->GetNavigationManagerImpl(); |
+ EXPECT_EQ(navigationManager.GetVisibleItem()->GetURL(), url_to_load); |
+ EXPECT_EQ(navigationManager.GetVisibleItem()->GetVirtualURL(), url_to_load); |
+ EXPECT_EQ(navigationManager.GetLastCommittedItem()->GetURL(), url_to_load); |
+ EXPECT_EQ(navigationManager.GetLastCommittedItem()->GetVirtualURL(), |
+ url_to_load); |
+} |
+ |
// A separate test class, as none of the |CRWUIWebViewWebControllerTest| setup |
// is needed; |
typedef web::WebTestWithWebController CRWWebControllerObserversTest; |