| 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 c368279bfdcbf0f8b8eb0d22a61a4af159233e3a..f125b10b58dec6f304c08122802eaa72a7283be3 100644
|
| --- a/ios/web/web_state/ui/crw_web_controller_unittest.mm
|
| +++ b/ios/web/web_state/ui/crw_web_controller_unittest.mm
|
| @@ -28,7 +28,7 @@
|
| #import "ios/web/public/web_state/ui/crw_content_view.h"
|
| #import "ios/web/public/web_state/ui/crw_web_view_content_view.h"
|
| #include "ios/web/public/web_state/url_verification_constants.h"
|
| -#import "ios/web/test/web_test.h"
|
| +#import "ios/web/test/web_test_with_web_controller.h"
|
| #import "ios/web/test/wk_web_view_crash_utils.h"
|
| #include "ios/web/web_state/blocked_popup_info.h"
|
| #import "ios/web/web_state/js/crw_js_invoke_parameter_queue.h"
|
| @@ -309,14 +309,14 @@ class CRWWebControllerTest : public web::WebTestWithWebController {
|
| [OCMockObject niceMockForProtocol:@protocol(CRWWebDelegate)];
|
| mockDelegate_.reset([[MockInteractionLoader alloc]
|
| initWithRepresentedObject:originalMockDelegate]);
|
| - [webController_ setDelegate:mockDelegate_];
|
| + [web_controller() setDelegate:mockDelegate_];
|
| base::scoped_nsobject<TestWebViewContentView> webViewContentView(
|
| [[TestWebViewContentView alloc] initWithMockWebView:mockWebView_
|
| scrollView:mockScrollView_]);
|
| - [webController_ injectWebViewContentView:webViewContentView];
|
| + [web_controller() injectWebViewContentView:webViewContentView];
|
|
|
| NavigationManagerImpl& navigationManager =
|
| - [webController_ webStateImpl]->GetNavigationManagerImpl();
|
| + [web_controller() webStateImpl]->GetNavigationManagerImpl();
|
| navigationManager.InitializeSession(@"name", nil, NO, 0);
|
| [navigationManager.GetSessionController()
|
| addPendingEntry:GURL("http://www.google.com/?q=foo#bar")
|
| @@ -327,10 +327,10 @@ class CRWWebControllerTest : public web::WebTestWithWebController {
|
|
|
| void TearDown() override {
|
| EXPECT_OCMOCK_VERIFY(mockDelegate_);
|
| - EXPECT_OCMOCK_VERIFY(mockChildWebController_.get());
|
| + EXPECT_OCMOCK_VERIFY(mockChildWebController_);
|
| EXPECT_OCMOCK_VERIFY(mockWebView_);
|
| - [webController_ resetInjectedWebViewContentView];
|
| - [webController_ setDelegate:nil];
|
| + [web_controller() resetInjectedWebViewContentView];
|
| + [web_controller() setDelegate:nil];
|
| web::WebTestWithWebController::TearDown();
|
| }
|
|
|
| @@ -343,7 +343,7 @@ class CRWWebControllerTest : public web::WebTestWithWebController {
|
| }
|
|
|
| // Creates WebView mock.
|
| - UIView* CreateMockWebView() const {
|
| + UIView* CreateMockWebView() {
|
| id result = [[OCMockObject mockForClass:[WKWebView class]] retain];
|
|
|
| // Called by resetInjectedWebView
|
| @@ -353,7 +353,7 @@ class CRWWebControllerTest : public web::WebTestWithWebController {
|
| [[result stub] setNavigationDelegate:OCMOCK_ANY];
|
| [[result stub] setUIDelegate:OCMOCK_ANY];
|
| [[result stub] setFrame:ExpectedWebViewFrame()];
|
| - [[result stub] addObserver:webController_
|
| + [[result stub] addObserver:web_controller()
|
| forKeyPath:OCMOCK_ANY
|
| options:0
|
| context:nullptr];
|
| @@ -362,7 +362,7 @@ class CRWWebControllerTest : public web::WebTestWithWebController {
|
| options:0
|
| context:nullptr];
|
|
|
| - [[result stub] removeObserver:webController_ forKeyPath:OCMOCK_ANY];
|
| + [[result stub] removeObserver:web_controller() forKeyPath:OCMOCK_ANY];
|
| [[result stub] removeObserver:OCMOCK_ANY
|
| forKeyPath:@"scrollView.backgroundColor"];
|
|
|
| @@ -405,8 +405,8 @@ TEST_F(CRWWebControllerTest, UrlForHistoryNavigation) {
|
| fromItem.SetURL(MAKE_URL(start));
|
| toItem.SetURL(MAKE_URL(end));
|
| EXPECT_EQ(MAKE_URL(end),
|
| - [webController_ URLForHistoryNavigationFromItem:&fromItem
|
| - toItem:&toItem]);
|
| + [web_controller() URLForHistoryNavigationFromItem:&fromItem
|
| + toItem:&toItem]);
|
| }
|
| }
|
| // Both contain fragments: the end url is never changed.
|
| @@ -415,8 +415,8 @@ TEST_F(CRWWebControllerTest, UrlForHistoryNavigation) {
|
| fromItem.SetURL(MAKE_URL(start));
|
| toItem.SetURL(MAKE_URL(end));
|
| EXPECT_EQ(MAKE_URL(end),
|
| - [webController_ URLForHistoryNavigationFromItem:&fromItem
|
| - toItem:&toItem]);
|
| + [web_controller() URLForHistoryNavigationFromItem:&fromItem
|
| + toItem:&toItem]);
|
| }
|
| }
|
| for (unsigned start_index = 0; start_index < [urlsWithFragments count];
|
| @@ -430,16 +430,16 @@ TEST_F(CRWWebControllerTest, UrlForHistoryNavigation) {
|
| fromItem.SetURL(MAKE_URL(start));
|
| toItem.SetURL(MAKE_URL(end));
|
| EXPECT_EQ(MAKE_URL(end),
|
| - [webController_ URLForHistoryNavigationFromItem:&fromItem
|
| - toItem:&toItem]);
|
| + [web_controller() URLForHistoryNavigationFromItem:&fromItem
|
| + toItem:&toItem]);
|
| } else {
|
| // Start contains a fragment and matches end: An empty fragment is
|
| // added.
|
| fromItem.SetURL(MAKE_URL(start));
|
| toItem.SetURL(MAKE_URL(end));
|
| EXPECT_EQ(MAKE_URL([end stringByAppendingString:@"#"]),
|
| - [webController_ URLForHistoryNavigationFromItem:&fromItem
|
| - toItem:&toItem]);
|
| + [web_controller() URLForHistoryNavigationFromItem:&fromItem
|
| + toItem:&toItem]);
|
| }
|
| }
|
| }
|
| @@ -463,14 +463,14 @@ TEST_F(CRWWebControllerTest, SslCertErrorDeprecatedApi) {
|
| }];
|
|
|
| CRWWebControllerContainerView* containerView =
|
| - static_cast<CRWWebControllerContainerView*>([webController_ view]);
|
| + static_cast<CRWWebControllerContainerView*>([web_controller() view]);
|
| WKWebView* webView =
|
| static_cast<WKWebView*>(containerView.webViewContentView.webView);
|
| base::scoped_nsobject<NSObject> navigation([[NSObject alloc] init]);
|
| - [static_cast<id<WKNavigationDelegate>>(webController_.get())
|
| + [static_cast<id<WKNavigationDelegate>>(web_controller())
|
| webView:webView
|
| didStartProvisionalNavigation:static_cast<WKNavigation*>(navigation)];
|
| - [static_cast<id<WKNavigationDelegate>>(webController_.get())
|
| + [static_cast<id<WKNavigationDelegate>>(web_controller())
|
| webView:webView
|
| didFailProvisionalNavigation:static_cast<WKNavigation*>(navigation)
|
| withError:error];
|
| @@ -489,7 +489,7 @@ TEST_F(CRWWebControllerTest, SslCertErrorDeprecatedApi) {
|
| // WKWebView fails to load a page with bad SSL cert.
|
| TEST_F(CRWWebControllerTest, SslCertError) {
|
| // TODO(crbug.com/602298): Remove this call.
|
| - [webController_ setDelegate:nil];
|
| + [web_controller() setDelegate:nil];
|
|
|
| // Last arguments passed to AllowCertificateError must be in default state.
|
| ASSERT_FALSE(GetWebClient()->last_cert_error_code());
|
| @@ -511,14 +511,14 @@ TEST_F(CRWWebControllerTest, SslCertError) {
|
| web::kNSErrorFailingURLKey : net::NSURLWithGURL(url),
|
| }];
|
| CRWWebControllerContainerView* containerView =
|
| - static_cast<CRWWebControllerContainerView*>([webController_ view]);
|
| + static_cast<CRWWebControllerContainerView*>([web_controller() view]);
|
| WKWebView* webView =
|
| static_cast<WKWebView*>(containerView.webViewContentView.webView);
|
| base::scoped_nsobject<NSObject> navigation([[NSObject alloc] init]);
|
| - [static_cast<id<WKNavigationDelegate>>(webController_.get())
|
| + [static_cast<id<WKNavigationDelegate>>(web_controller())
|
| webView:webView
|
| didStartProvisionalNavigation:static_cast<WKNavigation*>(navigation)];
|
| - [static_cast<id<WKNavigationDelegate>>(webController_.get())
|
| + [static_cast<id<WKNavigationDelegate>>(web_controller())
|
| webView:webView
|
| didFailProvisionalNavigation:static_cast<WKNavigation*>(navigation)
|
| withError:error];
|
| @@ -541,21 +541,21 @@ class CRWWebControllerPageDialogOpenPolicyTest
|
| LoadHtml(@"<html><body></body></html>");
|
| web_delegate_mock_.reset(
|
| [[OCMockObject mockForProtocol:@protocol(CRWWebDelegate)] retain]);
|
| - [webController_ setDelegate:web_delegate_mock_];
|
| + [web_controller() setDelegate:web_delegate_mock_];
|
| id ui_delegate_oc_mock =
|
| [OCMockObject mockForProtocol:@protocol(CRWWebUserInterfaceDelegate)];
|
| ui_delegate_mock_.reset([[CRWWebUserInterfaceDelegateStub alloc]
|
| initWithRepresentedObject:ui_delegate_oc_mock]);
|
| - [webController_ setUIDelegate:ui_delegate_mock_];
|
| + [web_controller() setUIDelegate:ui_delegate_mock_];
|
| // Web Controller cancels all dialogs on |close|.
|
| - [[ui_delegate_mock_ stub] cancelDialogsForWebController:webController_];
|
| + [[ui_delegate_mock_ stub] cancelDialogsForWebController:web_controller()];
|
| }
|
| void TearDown() override {
|
| WaitForBackgroundTasks();
|
| EXPECT_OCMOCK_VERIFY(web_delegate_mock_);
|
| EXPECT_OCMOCK_VERIFY(ui_delegate_mock_);
|
| - [webController_ setDelegate:nil];
|
| - [webController_ setUIDelegate:nil];
|
| + [web_controller() setDelegate:nil];
|
| + [web_controller() setUIDelegate:nil];
|
|
|
| web::WebTestWithWebController::TearDown();
|
| }
|
| @@ -573,8 +573,9 @@ class CRWWebControllerPageDialogOpenPolicyTest
|
|
|
| // Tests that window.alert dialog is suppressed for DIALOG_POLICY_SUPPRESS.
|
| TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressAlert) {
|
| - [[web_delegate_mock() expect] webControllerDidSuppressDialog:webController_];
|
| - [webController_ setShouldSuppressDialogs:YES];
|
| + [[web_delegate_mock() expect]
|
| + webControllerDidSuppressDialog:web_controller()];
|
| + [web_controller() setShouldSuppressDialogs:YES];
|
| EvaluateJavaScriptAsString(@"alert('test')");
|
| };
|
|
|
| @@ -585,24 +586,25 @@ TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowAlert) {
|
| requestURL:
|
| completionHandler:);
|
| [ui_delegate_mock() onSelector:selector
|
| - callBlockExpectation:^(CRWWebController* web_controller,
|
| + callBlockExpectation:^(CRWWebController* controller,
|
| NSString* message, const GURL& url,
|
| ProceduralBlock completion_handler) {
|
| - EXPECT_NSEQ(webController_, web_controller);
|
| + EXPECT_NSEQ(web_controller(), controller);
|
| EXPECT_NSEQ(@"test", message);
|
| web::URLVerificationTrustLevel unused;
|
| - EXPECT_EQ([web_controller currentURLWithTrustLevel:&unused], url);
|
| + EXPECT_EQ([controller currentURLWithTrustLevel:&unused], url);
|
| completion_handler();
|
| }];
|
|
|
| - [webController_ setShouldSuppressDialogs:NO];
|
| + [web_controller() setShouldSuppressDialogs:NO];
|
| EvaluateJavaScriptAsString(@"alert('test')");
|
| };
|
|
|
| // Tests that window.confirm dialog is suppressed for DIALOG_POLICY_SUPPRESS.
|
| TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressConfirm) {
|
| - [[web_delegate_mock() expect] webControllerDidSuppressDialog:webController_];
|
| - [webController_ setShouldSuppressDialogs:YES];
|
| + [[web_delegate_mock() expect]
|
| + webControllerDidSuppressDialog:web_controller()];
|
| + [web_controller() setShouldSuppressDialogs:YES];
|
| EXPECT_NSEQ(@"false", EvaluateJavaScriptAsString(@"confirm('test')"));
|
| };
|
|
|
| @@ -613,19 +615,19 @@ TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowConfirmWithTrue) {
|
| runJavaScriptConfirmPanelWithMessage:
|
| requestURL:
|
| completionHandler:);
|
| - [ui_delegate_mock() onSelector:selector
|
| - callBlockExpectation:^(CRWWebController* web_controller,
|
| - NSString* message, const GURL& url,
|
| - id completion_handler) {
|
| - EXPECT_NSEQ(webController_, web_controller);
|
| - EXPECT_NSEQ(@"test", message);
|
| - web::URLVerificationTrustLevel unused;
|
| - EXPECT_EQ([web_controller currentURLWithTrustLevel:&unused], url);
|
| - void (^callable_block)(BOOL) = completion_handler;
|
| - callable_block(YES);
|
| - }];
|
| + [ui_delegate_mock()
|
| + onSelector:selector
|
| + callBlockExpectation:^(CRWWebController* controller, NSString* message,
|
| + const GURL& url, id completion_handler) {
|
| + EXPECT_NSEQ(web_controller(), controller);
|
| + EXPECT_NSEQ(@"test", message);
|
| + web::URLVerificationTrustLevel unused;
|
| + EXPECT_EQ([controller currentURLWithTrustLevel:&unused], url);
|
| + void (^callable_block)(BOOL) = completion_handler;
|
| + callable_block(YES);
|
| + }];
|
|
|
| - [webController_ setShouldSuppressDialogs:NO];
|
| + [web_controller() setShouldSuppressDialogs:NO];
|
| EXPECT_NSEQ(@"true", EvaluateJavaScriptAsString(@"confirm('test')"));
|
| }
|
|
|
| @@ -636,26 +638,27 @@ TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowConfirmWithFalse) {
|
| runJavaScriptConfirmPanelWithMessage:
|
| requestURL:
|
| completionHandler:);
|
| - [ui_delegate_mock() onSelector:selector
|
| - callBlockExpectation:^(CRWWebController* web_controller,
|
| - NSString* message, const GURL& url,
|
| - id completion_handler) {
|
| - EXPECT_NSEQ(webController_, web_controller);
|
| - EXPECT_NSEQ(@"test", message);
|
| - web::URLVerificationTrustLevel unused;
|
| - EXPECT_EQ([web_controller currentURLWithTrustLevel:&unused], url);
|
| - void (^callable_block)(BOOL) = completion_handler;
|
| - callable_block(NO);
|
| - }];
|
| + [ui_delegate_mock()
|
| + onSelector:selector
|
| + callBlockExpectation:^(CRWWebController* controller, NSString* message,
|
| + const GURL& url, id completion_handler) {
|
| + EXPECT_NSEQ(web_controller(), controller);
|
| + EXPECT_NSEQ(@"test", message);
|
| + web::URLVerificationTrustLevel unused;
|
| + EXPECT_EQ([controller currentURLWithTrustLevel:&unused], url);
|
| + void (^callable_block)(BOOL) = completion_handler;
|
| + callable_block(NO);
|
| + }];
|
|
|
| - [webController_ setShouldSuppressDialogs:NO];
|
| + [web_controller() setShouldSuppressDialogs:NO];
|
| EXPECT_NSEQ(@"false", EvaluateJavaScriptAsString(@"confirm('test')"));
|
| }
|
|
|
| // Tests that window.prompt dialog is suppressed for DIALOG_POLICY_SUPPRESS.
|
| TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressPrompt) {
|
| - [[web_delegate_mock() expect] webControllerDidSuppressDialog:webController_];
|
| - [webController_ setShouldSuppressDialogs:YES];
|
| + [[web_delegate_mock() expect]
|
| + webControllerDidSuppressDialog:web_controller()];
|
| + [web_controller() setShouldSuppressDialogs:YES];
|
| EXPECT_NSEQ(@"", EvaluateJavaScriptAsString(@"prompt('Yes?', 'No')"));
|
| }
|
|
|
| @@ -667,33 +670,35 @@ TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowPrompt) {
|
| requestURL:
|
| completionHandler:);
|
| [ui_delegate_mock() onSelector:selector
|
| - callBlockExpectation:^(CRWWebController* web_controller,
|
| + callBlockExpectation:^(CRWWebController* controller,
|
| NSString* message, NSString* default_text,
|
| const GURL& url, id completion_handler) {
|
| - EXPECT_NSEQ(webController_, web_controller);
|
| + EXPECT_NSEQ(web_controller(), controller);
|
| EXPECT_NSEQ(@"Yes?", message);
|
| EXPECT_NSEQ(@"No", default_text);
|
| web::URLVerificationTrustLevel unused;
|
| - EXPECT_EQ([web_controller currentURLWithTrustLevel:&unused], url);
|
| + EXPECT_EQ([controller currentURLWithTrustLevel:&unused], url);
|
| void (^callable_block)(NSString*) = completion_handler;
|
| callable_block(@"Maybe");
|
| }];
|
|
|
| - [webController_ setShouldSuppressDialogs:NO];
|
| + [web_controller() setShouldSuppressDialogs:NO];
|
| EXPECT_NSEQ(@"Maybe", EvaluateJavaScriptAsString(@"prompt('Yes?', 'No')"));
|
| }
|
|
|
| // Tests that geolocation dialog is suppressed for DIALOG_POLICY_SUPPRESS.
|
| TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressGeolocation) {
|
| - [[web_delegate_mock() expect] webControllerDidSuppressDialog:webController_];
|
| - [webController_ setShouldSuppressDialogs:YES];
|
| + [[web_delegate_mock() expect]
|
| + webControllerDidSuppressDialog:web_controller()];
|
| + [web_controller() setShouldSuppressDialogs:YES];
|
| EvaluateJavaScriptAsString(@"navigator.geolocation.getCurrentPosition()");
|
| }
|
|
|
| // Tests that window.open is suppressed for DIALOG_POLICY_SUPPRESS.
|
| TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressWindowOpen) {
|
| - [[web_delegate_mock() expect] webControllerDidSuppressDialog:webController_];
|
| - [webController_ setShouldSuppressDialogs:YES];
|
| + [[web_delegate_mock() expect]
|
| + webControllerDidSuppressDialog:web_controller()];
|
| + [web_controller() setShouldSuppressDialogs:YES];
|
| EvaluateJavaScriptAsString(@"window.open('')");
|
| }
|
|
|
| @@ -726,27 +731,27 @@ TEST_F(CRWWebControllerPageScrollStateTest,
|
| #endif
|
| web::PageZoomState zoom_state(1.0, 5.0, 1.0);
|
| LoadHtml(GetHTMLForZoomState(zoom_state, PAGE_SCALABILITY_DISABLED));
|
| - CRWWebController* web_controller = webController_.get();
|
| - WaitForZoomRendering(web_controller, zoom_state);
|
| + WaitForZoomRendering(web_controller(), zoom_state);
|
| web::PageZoomState original_zoom_state =
|
| - web_controller.pageDisplayState.zoom_state();
|
| + web_controller().pageDisplayState.zoom_state();
|
|
|
| web::NavigationManager* nagivation_manager =
|
| - web_controller.webState->GetNavigationManager();
|
| + web_state()->GetNavigationManager();
|
| nagivation_manager->GetLastCommittedItem()->SetPageDisplayState(
|
| CreateTestPageDisplayState(CGPointMake(1.0, 1.0), // scroll offset
|
| 3.0, // relative zoom scale
|
| 1.0, // original minimum zoom scale
|
| 5.0, // original maximum zoom scale
|
| 1.0)); // original zoom scale
|
| - [web_controller restoreStateFromHistory];
|
| + [web_controller() restoreStateFromHistory];
|
|
|
| // |-restoreStateFromHistory| is async; wait for its completion.
|
| base::test::ios::WaitUntilCondition(^bool() {
|
| - return web_controller.pageDisplayState.scroll_state().offset_x() == 1.0;
|
| + return web_controller().pageDisplayState.scroll_state().offset_x() == 1.0;
|
| });
|
|
|
| - ASSERT_EQ(original_zoom_state, web_controller.pageDisplayState.zoom_state());
|
| + ASSERT_EQ(original_zoom_state,
|
| + web_controller().pageDisplayState.zoom_state());
|
| };
|
|
|
| // TODO(iOS): Flaky on the bots. crbug/493427
|
| @@ -754,26 +759,25 @@ TEST_F(CRWWebControllerPageScrollStateTest,
|
| FLAKY_SetPageDisplayStateWithUserScalableEnabled) {
|
| web::PageZoomState zoom_state(1.0, 10.0, 1.0);
|
| LoadHtml(GetHTMLForZoomState(zoom_state, PAGE_SCALABILITY_ENABLED));
|
| - CRWWebController* web_controller = webController_.get();
|
| - WaitForZoomRendering(web_controller, zoom_state);
|
| + WaitForZoomRendering(web_controller(), zoom_state);
|
|
|
| web::NavigationManager* nagivation_manager =
|
| - web_controller.webState->GetNavigationManager();
|
| + web_state()->GetNavigationManager();
|
| nagivation_manager->GetLastCommittedItem()->SetPageDisplayState(
|
| CreateTestPageDisplayState(CGPointMake(1.0, 1.0), // scroll offset
|
| 3.0, // relative zoom scale
|
| 1.0, // original minimum zoom scale
|
| 10.0, // original maximum zoom scale
|
| 1.0)); // original zoom scale
|
| - [web_controller restoreStateFromHistory];
|
| + [web_controller() restoreStateFromHistory];
|
|
|
| // |-restoreStateFromHistory| is async; wait for its completion.
|
| base::test::ios::WaitUntilCondition(^bool() {
|
| - return web_controller.pageDisplayState.scroll_state().offset_x() == 1.0;
|
| + return web_controller().pageDisplayState.scroll_state().offset_x() == 1.0;
|
| });
|
|
|
| web::PageZoomState final_zoom_state =
|
| - web_controller.pageDisplayState.zoom_state();
|
| + web_controller().pageDisplayState.zoom_state();
|
| EXPECT_FLOAT_EQ(3, final_zoom_state.zoom_scale() /
|
| final_zoom_state.minimum_zoom_scale());
|
| };
|
| @@ -786,26 +790,25 @@ TEST_F(CRWWebControllerPageScrollStateTest, FLAKY_AtTop) {
|
|
|
| web::PageZoomState zoom_state = web::PageZoomState(1.0, 5.0, 1.0);
|
| LoadHtml(GetHTMLForZoomState(zoom_state, PAGE_SCALABILITY_ENABLED));
|
| - CRWWebController* web_controller = webController_.get();
|
| - WaitForZoomRendering(web_controller, zoom_state);
|
| - ASSERT_TRUE(web_controller.atTop);
|
| + WaitForZoomRendering(web_controller(), zoom_state);
|
| + ASSERT_TRUE(web_controller().atTop);
|
|
|
| web::NavigationManager* nagivation_manager =
|
| - web_controller.webState->GetNavigationManager();
|
| + web_state()->GetNavigationManager();
|
| nagivation_manager->GetLastCommittedItem()->SetPageDisplayState(
|
| CreateTestPageDisplayState(CGPointMake(0.0, 30.0), // scroll offset
|
| 5.0, // relative zoom scale
|
| 1.0, // original minimum zoom scale
|
| 5.0, // original maximum zoom scale
|
| 1.0)); // original zoom scale
|
| - [web_controller restoreStateFromHistory];
|
| + [web_controller() restoreStateFromHistory];
|
|
|
| // |-restoreStateFromHistory| is async; wait for its completion.
|
| base::test::ios::WaitUntilCondition(^bool() {
|
| - return web_controller.pageDisplayState.scroll_state().offset_y() == 30.0;
|
| + return web_controller().pageDisplayState.scroll_state().offset_y() == 30.0;
|
| });
|
|
|
| - ASSERT_FALSE(web_controller.atTop);
|
| + ASSERT_FALSE(web_controller().atTop);
|
| };
|
|
|
| // Real WKWebView is required for CRWWebControllerJSExecutionTest.
|
| @@ -864,14 +867,14 @@ TEST_F(CRWWebControllerTest, WebUrlWithTrustLevel) {
|
| completionHandler:OCMOCK_ANY];
|
|
|
| // Simulate registering load request to avoid failing page load simulation.
|
| - [webController_ simulateLoadRequestWithURL:GURL([kTestURLString UTF8String])];
|
| + [web_controller()
|
| + simulateLoadRequestWithURL:GURL([kTestURLString UTF8String])];
|
| // Simulate a page load to trigger a URL update.
|
| - [static_cast<id<WKNavigationDelegate>>(webController_.get())
|
| - webView:mockWebView_
|
| - didCommitNavigation:nil];
|
| + [static_cast<id<WKNavigationDelegate>>(web_controller()) webView:mockWebView_
|
| + didCommitNavigation:nil];
|
|
|
| web::URLVerificationTrustLevel trust_level = web::kNone;
|
| - GURL gurl = [webController_ currentURLWithTrustLevel:&trust_level];
|
| + GURL gurl = [web_controller() currentURLWithTrustLevel:&trust_level];
|
|
|
| EXPECT_EQ(gurl, GURL(base::SysNSStringToUTF8(kTestURLString)));
|
| EXPECT_EQ(web::kAbsolute, trust_level);
|
| @@ -885,30 +888,29 @@ typedef web::WebTestWithWebController CRWWebControllerObserversTest;
|
| TEST_F(CRWWebControllerObserversTest, Observers) {
|
| base::scoped_nsobject<CountingObserver> observer(
|
| [[CountingObserver alloc] init]);
|
| - CRWWebController* web_controller = webController_;
|
| - EXPECT_EQ(0u, [web_controller observerCount]);
|
| - [web_controller addObserver:observer];
|
| - EXPECT_EQ(1u, [web_controller observerCount]);
|
| + EXPECT_EQ(0u, [web_controller() observerCount]);
|
| + [web_controller() addObserver:observer];
|
| + EXPECT_EQ(1u, [web_controller() observerCount]);
|
|
|
| EXPECT_EQ(0, [observer pageLoadedCount]);
|
| - [web_controller webStateImpl]->OnPageLoaded(GURL("http://test"), false);
|
| + [web_controller() webStateImpl]->OnPageLoaded(GURL("http://test"), false);
|
| EXPECT_EQ(0, [observer pageLoadedCount]);
|
| - [web_controller webStateImpl]->OnPageLoaded(GURL("http://test"), true);
|
| + [web_controller() webStateImpl]->OnPageLoaded(GURL("http://test"), true);
|
| EXPECT_EQ(1, [observer pageLoadedCount]);
|
|
|
| EXPECT_EQ(0, [observer messageCount]);
|
| // Non-matching prefix.
|
| - EXPECT_FALSE([web_controller webStateImpl]->OnScriptCommandReceived(
|
| + EXPECT_FALSE([web_controller() webStateImpl]->OnScriptCommandReceived(
|
| "a", base::DictionaryValue(), GURL("http://test"), true));
|
| EXPECT_EQ(0, [observer messageCount]);
|
| // Matching prefix.
|
| - EXPECT_TRUE([web_controller webStateImpl]->OnScriptCommandReceived(
|
| + EXPECT_TRUE([web_controller() webStateImpl]->OnScriptCommandReceived(
|
| base::SysNSStringToUTF8([observer commandPrefix]) + ".foo",
|
| base::DictionaryValue(), GURL("http://test"), true));
|
| EXPECT_EQ(1, [observer messageCount]);
|
|
|
| - [web_controller removeObserver:observer];
|
| - EXPECT_EQ(0u, [web_controller observerCount]);
|
| + [web_controller() removeObserver:observer];
|
| + EXPECT_EQ(0u, [web_controller() observerCount]);
|
| };
|
|
|
| // Test fixture for window.open tests.
|
| @@ -922,7 +924,7 @@ class CRWWebControllerWindowOpenTest : public web::WebTestWithWebController {
|
| initWithRepresentedObject:
|
| [OCMockObject niceMockForProtocol:@protocol(CRWWebDelegate)]]);
|
| ASSERT_TRUE([delegate_ blockPopups]);
|
| - [webController_ setDelegate:delegate_];
|
| + [web_controller() setDelegate:delegate_];
|
|
|
| // Configure child web state.
|
| child_web_state_.reset(new web::WebStateImpl(GetBrowserState()));
|
| @@ -941,7 +943,7 @@ class CRWWebControllerWindowOpenTest : public web::WebTestWithWebController {
|
| }
|
| void TearDown() override {
|
| EXPECT_OCMOCK_VERIFY(delegate_);
|
| - [webController_ setDelegate:nil];
|
| + [web_controller() setDelegate:nil];
|
|
|
| web::WebTestWithWebController::TearDown();
|
| }
|
| @@ -963,7 +965,7 @@ class CRWWebControllerWindowOpenTest : public web::WebTestWithWebController {
|
|
|
| // Tests that absence of web delegate is handled gracefully.
|
| TEST_F(CRWWebControllerWindowOpenTest, NoDelegate) {
|
| - [webController_ setDelegate:nil];
|
| + [web_controller() setDelegate:nil];
|
|
|
| EXPECT_NSEQ(@"", OpenWindowByDOM());
|
|
|
| @@ -978,7 +980,7 @@ TEST_F(CRWWebControllerWindowOpenTest, OpenWithUserGesture) {
|
| callBlockExpectation:^(){
|
| }];
|
|
|
| - [webController_ touched:YES];
|
| + [web_controller() touched:YES];
|
| EXPECT_NSEQ(@"[object Window]", OpenWindowByDOM());
|
| EXPECT_FALSE([delegate_ blockedPopupInfo]);
|
| }
|
| @@ -998,7 +1000,7 @@ TEST_F(CRWWebControllerWindowOpenTest, AllowPopup) {
|
| EXPECT_FALSE(in_background);
|
| }];
|
|
|
| - ASSERT_FALSE([webController_ userIsInteracting]);
|
| + ASSERT_FALSE([web_controller() userIsInteracting]);
|
| EXPECT_NSEQ(@"", OpenWindowByDOM());
|
| base::test::ios::WaitUntilCondition(^bool() {
|
| return [delegate_ blockedPopupInfo];
|
| @@ -1029,7 +1031,7 @@ TEST_F(CRWWebControllerWindowOpenTest, DontBlockPopup) {
|
|
|
| // Tests that window.open executed w/o user gesture does not open a new window.
|
| TEST_F(CRWWebControllerWindowOpenTest, BlockPopup) {
|
| - ASSERT_FALSE([webController_ userIsInteracting]);
|
| + ASSERT_FALSE([web_controller() userIsInteracting]);
|
| EXPECT_NSEQ(@"", OpenWindowByDOM());
|
| base::test::ios::WaitUntilCondition(^bool() {
|
| return [delegate_ blockedPopupInfo];
|
| @@ -1049,7 +1051,7 @@ class CRWWebControllerWebProcessTest : public web::WebTestWithWebController {
|
| [[TestWebViewContentView alloc]
|
| initWithMockWebView:webView_
|
| scrollView:[webView_ scrollView]]);
|
| - [webController_ injectWebViewContentView:webViewContentView];
|
| + [web_controller() injectWebViewContentView:webViewContentView];
|
| }
|
| base::scoped_nsobject<WKWebView> webView_;
|
| };
|
| @@ -1058,14 +1060,14 @@ class CRWWebControllerWebProcessTest : public web::WebTestWithWebController {
|
| // when WKWebView web process has crashed.
|
| TEST_F(CRWWebControllerWebProcessTest, Crash) {
|
| id delegate = [OCMockObject niceMockForProtocol:@protocol(CRWWebDelegate)];
|
| - [[delegate expect] webControllerWebProcessDidCrash:webController_];
|
| + [[delegate expect] webControllerWebProcessDidCrash:web_controller()];
|
|
|
| - [webController_ setDelegate:delegate];
|
| + [web_controller() setDelegate:delegate];
|
| web::SimulateWKWebViewCrash(webView_);
|
|
|
| EXPECT_OCMOCK_VERIFY(delegate);
|
| - EXPECT_FALSE([webController_ isViewAlive]);
|
| - [webController_ setDelegate:nil];
|
| + EXPECT_FALSE([web_controller() isViewAlive]);
|
| + [web_controller() setDelegate:nil];
|
| };
|
|
|
| } // namespace
|
|
|