OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "ios/web/web_state/ui/crw_web_controller.h" | 5 #import "ios/web/web_state/ui/crw_web_controller.h" |
6 | 6 |
7 #import <WebKit/WebKit.h> | 7 #import <WebKit/WebKit.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/ios/ios_util.h" | 11 #include "base/ios/ios_util.h" |
12 #import "base/mac/scoped_nsobject.h" | 12 #import "base/mac/scoped_nsobject.h" |
13 #import "base/test/ios/wait_util.h" | 13 #import "base/test/ios/wait_util.h" |
14 #import "ios/testing/ocmock_complex_type_helper.h" | 14 #import "ios/testing/ocmock_complex_type_helper.h" |
15 #import "ios/web/navigation/crw_session_controller.h" | 15 #import "ios/web/navigation/crw_session_controller.h" |
16 #import "ios/web/navigation/crw_session_entry.h" | 16 #import "ios/web/navigation/crw_session_entry.h" |
17 #import "ios/web/navigation/navigation_item_impl.h" | 17 #import "ios/web/navigation/navigation_item_impl.h" |
18 #import "ios/web/navigation/navigation_manager_impl.h" | 18 #import "ios/web/navigation/navigation_manager_impl.h" |
19 #include "ios/web/public/referrer.h" | 19 #include "ios/web/public/referrer.h" |
20 #import "ios/web/public/test/fakes/test_native_content.h" | 20 #import "ios/web/public/test/fakes/test_native_content.h" |
21 #import "ios/web/public/test/fakes/test_native_content_provider.h" | 21 #import "ios/web/public/test/fakes/test_native_content_provider.h" |
22 #import "ios/web/public/test/fakes/test_web_client.h" | 22 #import "ios/web/public/test/fakes/test_web_client.h" |
| 23 #import "ios/web/public/test/fakes/test_web_state_delegate.h" |
23 #import "ios/web/public/test/fakes/test_web_view_content_view.h" | 24 #import "ios/web/public/test/fakes/test_web_view_content_view.h" |
24 #import "ios/web/public/web_state/crw_web_controller_observer.h" | 25 #import "ios/web/public/web_state/crw_web_controller_observer.h" |
25 #import "ios/web/public/web_state/ui/crw_content_view.h" | 26 #import "ios/web/public/web_state/ui/crw_content_view.h" |
26 #import "ios/web/public/web_state/ui/crw_native_content.h" | 27 #import "ios/web/public/web_state/ui/crw_native_content.h" |
27 #import "ios/web/public/web_state/ui/crw_native_content_provider.h" | 28 #import "ios/web/public/web_state/ui/crw_native_content_provider.h" |
28 #import "ios/web/public/web_state/ui/crw_web_view_content_view.h" | 29 #import "ios/web/public/web_state/ui/crw_web_view_content_view.h" |
29 #include "ios/web/public/web_state/url_verification_constants.h" | 30 #include "ios/web/public/web_state/url_verification_constants.h" |
30 #include "ios/web/public/web_state/web_state_observer.h" | 31 #include "ios/web/public/web_state/web_state_observer.h" |
31 #import "ios/web/test/web_test_with_web_controller.h" | 32 #import "ios/web/test/web_test_with_web_controller.h" |
32 #import "ios/web/test/wk_web_view_crash_utils.h" | 33 #import "ios/web/test/wk_web_view_crash_utils.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // Blocked popup info received in |webController:didBlockPopup:| call. | 69 // Blocked popup info received in |webController:didBlockPopup:| call. |
69 // nullptr if that delegate method was not called. | 70 // nullptr if that delegate method was not called. |
70 @property(nonatomic, readonly) web::BlockedPopupInfo* blockedPopupInfo; | 71 @property(nonatomic, readonly) web::BlockedPopupInfo* blockedPopupInfo; |
71 @end | 72 @end |
72 | 73 |
73 // Stub implementation for CRWWebUserInterfaceDelegate protocol. | 74 // Stub implementation for CRWWebUserInterfaceDelegate protocol. |
74 @interface CRWWebUserInterfaceDelegateStub | 75 @interface CRWWebUserInterfaceDelegateStub |
75 : OCMockComplexTypeHelper<CRWWebUserInterfaceDelegate> | 76 : OCMockComplexTypeHelper<CRWWebUserInterfaceDelegate> |
76 @end | 77 @end |
77 | 78 |
78 @implementation CRWWebUserInterfaceDelegateStub | |
79 | |
80 - (void)webController:(CRWWebController*)webController | |
81 runJavaScriptAlertPanelWithMessage:(NSString*)message | |
82 requestURL:(const GURL&)requestURL | |
83 completionHandler:(void (^)(void))completionHandler { | |
84 void (^stubBlock)(CRWWebController*, NSString*, const GURL&, id) = | |
85 [self blockForSelector:_cmd]; | |
86 stubBlock(webController, message, requestURL, completionHandler); | |
87 } | |
88 | |
89 - (void)webController:(CRWWebController*)webController | |
90 runJavaScriptConfirmPanelWithMessage:(NSString*)message | |
91 requestURL:(const GURL&)requestURL | |
92 completionHandler:(void (^)(BOOL))completionHandler { | |
93 void (^stubBlock)(CRWWebController*, NSString*, const GURL&, id) = | |
94 [self blockForSelector:_cmd]; | |
95 stubBlock(webController, message, requestURL, completionHandler); | |
96 } | |
97 | |
98 - (void)webController:(CRWWebController*)webController | |
99 runJavaScriptTextInputPanelWithPrompt:(NSString*)message | |
100 defaultText:(NSString*)defaultText | |
101 requestURL:(const GURL&)requestURL | |
102 completionHandler: | |
103 (void (^)(NSString* input))completionHandler { | |
104 void (^stubBlock)(CRWWebController*, NSString*, NSString*, const GURL&, id) = | |
105 [self blockForSelector:_cmd]; | |
106 stubBlock(webController, message, defaultText, requestURL, completionHandler); | |
107 } | |
108 | |
109 - (BOOL)respondsToSelector:(SEL)selector { | |
110 // OCMockComplexTypeHelper DCHECKs when respondsToSelector: is called for | |
111 // expected selector. | |
112 if (selector == @selector(webController: | |
113 runJavaScriptAlertPanelWithMessage: | |
114 requestURL: | |
115 completionHandler:)) { | |
116 return YES; | |
117 } | |
118 if (selector == @selector(webController: | |
119 runJavaScriptConfirmPanelWithMessage: | |
120 requestURL: | |
121 completionHandler:)) { | |
122 return YES; | |
123 } | |
124 if (selector == @selector(webController: | |
125 runJavaScriptTextInputPanelWithPrompt: | |
126 defaultText: | |
127 requestURL: | |
128 completionHandler:)) { | |
129 return YES; | |
130 } | |
131 return [super respondsToSelector:selector]; | |
132 } | |
133 @end | |
134 | |
135 @implementation MockInteractionLoader { | 79 @implementation MockInteractionLoader { |
136 // Backs up the property with the same name. | 80 // Backs up the property with the same name. |
137 std::unique_ptr<web::BlockedPopupInfo> _blockedPopupInfo; | 81 std::unique_ptr<web::BlockedPopupInfo> _blockedPopupInfo; |
138 } | 82 } |
139 @synthesize popupURL = _popupURL; | 83 @synthesize popupURL = _popupURL; |
140 @synthesize sourceURL = _sourceURL; | 84 @synthesize sourceURL = _sourceURL; |
141 @synthesize blockPopups = _blockPopups; | 85 @synthesize blockPopups = _blockPopups; |
142 @synthesize childWebController = _childWebController; | 86 @synthesize childWebController = _childWebController; |
143 | 87 |
144 typedef void (^webPageOrderedOpenBlankBlockType)(); | 88 typedef void (^webPageOrderedOpenBlankBlockType)(); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 EXPECT_EQ(net::CERT_STATUS_INVALID, | 395 EXPECT_EQ(net::CERT_STATUS_INVALID, |
452 GetWebClient()->last_cert_error_ssl_info().cert_status); | 396 GetWebClient()->last_cert_error_ssl_info().cert_status); |
453 EXPECT_EQ(url, GetWebClient()->last_cert_error_request_url()); | 397 EXPECT_EQ(url, GetWebClient()->last_cert_error_request_url()); |
454 EXPECT_FALSE(GetWebClient()->last_cert_error_overridable()); | 398 EXPECT_FALSE(GetWebClient()->last_cert_error_overridable()); |
455 } | 399 } |
456 | 400 |
457 // Test fixture to test |setPageDialogOpenPolicy:|. | 401 // Test fixture to test |setPageDialogOpenPolicy:|. |
458 class CRWWebControllerPageDialogOpenPolicyTest | 402 class CRWWebControllerPageDialogOpenPolicyTest |
459 : public web::WebTestWithWebController { | 403 : public web::WebTestWithWebController { |
460 protected: | 404 protected: |
| 405 CRWWebControllerPageDialogOpenPolicyTest() |
| 406 : page_url_("https://chromium.test/") {} |
461 void SetUp() override { | 407 void SetUp() override { |
462 web::WebTestWithWebController::SetUp(); | 408 web::WebTestWithWebController::SetUp(); |
463 LoadHtml(@"<html><body></body></html>"); | 409 LoadHtml(@"<html><body></body></html>", page_url_); |
464 web_delegate_mock_.reset( | 410 web_delegate_mock_.reset( |
465 [[OCMockObject mockForProtocol:@protocol(CRWWebDelegate)] retain]); | 411 [[OCMockObject mockForProtocol:@protocol(CRWWebDelegate)] retain]); |
466 [web_controller() setDelegate:web_delegate_mock_]; | 412 [web_controller() setDelegate:web_delegate_mock_]; |
467 id ui_delegate_oc_mock = | 413 web_state()->SetDelegate(&test_web_delegate_); |
468 [OCMockObject mockForProtocol:@protocol(CRWWebUserInterfaceDelegate)]; | |
469 ui_delegate_mock_.reset([[CRWWebUserInterfaceDelegateStub alloc] | |
470 initWithRepresentedObject:ui_delegate_oc_mock]); | |
471 [web_controller() setUIDelegate:ui_delegate_mock_]; | |
472 // Web Controller cancels all dialogs on |close|. | |
473 [[ui_delegate_mock_ stub] cancelDialogsForWebController:web_controller()]; | |
474 } | 414 } |
475 void TearDown() override { | 415 void TearDown() override { |
476 WaitForBackgroundTasks(); | 416 WaitForBackgroundTasks(); |
477 EXPECT_OCMOCK_VERIFY(web_delegate_mock_); | 417 EXPECT_OCMOCK_VERIFY(web_delegate_mock_); |
478 EXPECT_OCMOCK_VERIFY(ui_delegate_mock_); | |
479 [web_controller() setDelegate:nil]; | 418 [web_controller() setDelegate:nil]; |
480 [web_controller() setUIDelegate:nil]; | 419 web_state()->SetDelegate(nullptr); |
481 | 420 |
482 web::WebTestWithWebController::TearDown(); | 421 web::WebTestWithWebController::TearDown(); |
483 } | 422 } |
484 // Returns CRWWebDelegate mock object. | |
485 id web_delegate_mock() { return web_delegate_mock_; }; | 423 id web_delegate_mock() { return web_delegate_mock_; }; |
486 // Returns CRWWebUserInterfaceDelegate mock object. | 424 web::TestJavaScriptDialogPresenter* js_dialog_presenter() { |
487 id ui_delegate_mock() { return ui_delegate_mock_; }; | 425 return test_web_delegate_.GetTestJavaScriptDialogPresenter(); |
| 426 } |
| 427 const std::vector<web::TestJavaScriptDialog>& requested_dialogs() { |
| 428 return js_dialog_presenter()->requested_dialogs(); |
| 429 } |
| 430 const GURL& page_url() { return page_url_; } |
488 | 431 |
489 private: | 432 private: |
490 // Mocks CRWWebDelegate object. | 433 web::TestWebStateDelegate test_web_delegate_; |
491 base::scoped_nsprotocol<id> web_delegate_mock_; | 434 base::scoped_nsprotocol<id> web_delegate_mock_; |
492 // Mocks CRWWebUserInterfaceDelegate object. | 435 GURL page_url_; |
493 base::scoped_nsprotocol<id> ui_delegate_mock_; | |
494 }; | 436 }; |
495 | 437 |
496 // Tests that window.alert dialog is suppressed for DIALOG_POLICY_SUPPRESS. | 438 // Tests that window.alert dialog is suppressed for DIALOG_POLICY_SUPPRESS. |
497 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressAlert) { | 439 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressAlert) { |
498 [[web_delegate_mock() expect] | 440 [[web_delegate_mock() expect] |
499 webControllerDidSuppressDialog:web_controller()]; | 441 webControllerDidSuppressDialog:web_controller()]; |
500 [web_controller() setShouldSuppressDialogs:YES]; | 442 [web_controller() setShouldSuppressDialogs:YES]; |
501 ExecuteJavaScript(@"alert('test')"); | 443 ExecuteJavaScript(@"alert('test')"); |
502 }; | 444 }; |
503 | 445 |
504 // Tests that window.alert dialog is shown for DIALOG_POLICY_ALLOW. | 446 // Tests that window.alert dialog is shown for DIALOG_POLICY_ALLOW. |
505 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowAlert) { | 447 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowAlert) { |
506 SEL selector = @selector(webController: | 448 ASSERT_TRUE(requested_dialogs().empty()); |
507 runJavaScriptAlertPanelWithMessage: | |
508 requestURL: | |
509 completionHandler:); | |
510 [ui_delegate_mock() onSelector:selector | |
511 callBlockExpectation:^(CRWWebController* controller, | |
512 NSString* message, const GURL& url, | |
513 ProceduralBlock completion_handler) { | |
514 EXPECT_NSEQ(web_controller(), controller); | |
515 EXPECT_NSEQ(@"test", message); | |
516 web::URLVerificationTrustLevel unused; | |
517 EXPECT_EQ([controller currentURLWithTrustLevel:&unused], url); | |
518 completion_handler(); | |
519 }]; | |
520 | 449 |
521 [web_controller() setShouldSuppressDialogs:NO]; | 450 [web_controller() setShouldSuppressDialogs:NO]; |
522 ExecuteJavaScript(@"alert('test')"); | 451 ExecuteJavaScript(@"alert('test')"); |
| 452 |
| 453 ASSERT_EQ(1U, requested_dialogs().size()); |
| 454 web::TestJavaScriptDialog dialog = requested_dialogs()[0]; |
| 455 EXPECT_EQ(web_state(), dialog.web_state); |
| 456 EXPECT_EQ(page_url(), dialog.origin_url); |
| 457 EXPECT_EQ(web::JAVASCRIPT_DIALOG_TYPE_ALERT, dialog.java_script_dialog_type); |
| 458 EXPECT_NSEQ(@"test", dialog.message_text); |
| 459 EXPECT_FALSE(dialog.default_prompt_text); |
523 }; | 460 }; |
524 | 461 |
525 // Tests that window.confirm dialog is suppressed for DIALOG_POLICY_SUPPRESS. | 462 // Tests that window.confirm dialog is suppressed for DIALOG_POLICY_SUPPRESS. |
526 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressConfirm) { | 463 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressConfirm) { |
| 464 ASSERT_TRUE(requested_dialogs().empty()); |
| 465 |
527 [[web_delegate_mock() expect] | 466 [[web_delegate_mock() expect] |
528 webControllerDidSuppressDialog:web_controller()]; | 467 webControllerDidSuppressDialog:web_controller()]; |
529 [web_controller() setShouldSuppressDialogs:YES]; | 468 [web_controller() setShouldSuppressDialogs:YES]; |
530 EXPECT_NSEQ(@NO, ExecuteJavaScript(@"confirm('test')")); | 469 EXPECT_NSEQ(@NO, ExecuteJavaScript(@"confirm('test')")); |
| 470 |
| 471 ASSERT_TRUE(requested_dialogs().empty()); |
531 }; | 472 }; |
532 | 473 |
533 // Tests that window.confirm dialog is shown for DIALOG_POLICY_ALLOW and | 474 // Tests that window.confirm dialog is shown for DIALOG_POLICY_ALLOW and |
534 // it's result is true. | 475 // it's result is true. |
535 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowConfirmWithTrue) { | 476 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowConfirmWithTrue) { |
536 SEL selector = @selector(webController: | 477 ASSERT_TRUE(requested_dialogs().empty()); |
537 runJavaScriptConfirmPanelWithMessage: | 478 |
538 requestURL: | 479 js_dialog_presenter()->set_callback_success_argument(true); |
539 completionHandler:); | |
540 [ui_delegate_mock() | |
541 onSelector:selector | |
542 callBlockExpectation:^(CRWWebController* controller, NSString* message, | |
543 const GURL& url, id completion_handler) { | |
544 EXPECT_NSEQ(web_controller(), controller); | |
545 EXPECT_NSEQ(@"test", message); | |
546 web::URLVerificationTrustLevel unused; | |
547 EXPECT_EQ([controller currentURLWithTrustLevel:&unused], url); | |
548 void (^callable_block)(BOOL) = completion_handler; | |
549 callable_block(YES); | |
550 }]; | |
551 | 480 |
552 [web_controller() setShouldSuppressDialogs:NO]; | 481 [web_controller() setShouldSuppressDialogs:NO]; |
553 EXPECT_NSEQ(@YES, ExecuteJavaScript(@"confirm('test')")); | 482 EXPECT_NSEQ(@YES, ExecuteJavaScript(@"confirm('test')")); |
| 483 |
| 484 ASSERT_EQ(1U, requested_dialogs().size()); |
| 485 web::TestJavaScriptDialog dialog = requested_dialogs()[0]; |
| 486 EXPECT_EQ(web_state(), dialog.web_state); |
| 487 EXPECT_EQ(page_url(), dialog.origin_url); |
| 488 EXPECT_EQ(web::JAVASCRIPT_DIALOG_TYPE_CONFIRM, |
| 489 dialog.java_script_dialog_type); |
| 490 EXPECT_NSEQ(@"test", dialog.message_text); |
| 491 EXPECT_FALSE(dialog.default_prompt_text); |
554 } | 492 } |
555 | 493 |
556 // Tests that window.confirm dialog is shown for DIALOG_POLICY_ALLOW and | 494 // Tests that window.confirm dialog is shown for DIALOG_POLICY_ALLOW and |
557 // it's result is false. | 495 // it's result is false. |
558 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowConfirmWithFalse) { | 496 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowConfirmWithFalse) { |
559 SEL selector = @selector(webController: | 497 ASSERT_TRUE(requested_dialogs().empty()); |
560 runJavaScriptConfirmPanelWithMessage: | |
561 requestURL: | |
562 completionHandler:); | |
563 [ui_delegate_mock() | |
564 onSelector:selector | |
565 callBlockExpectation:^(CRWWebController* controller, NSString* message, | |
566 const GURL& url, id completion_handler) { | |
567 EXPECT_NSEQ(web_controller(), controller); | |
568 EXPECT_NSEQ(@"test", message); | |
569 web::URLVerificationTrustLevel unused; | |
570 EXPECT_EQ([controller currentURLWithTrustLevel:&unused], url); | |
571 void (^callable_block)(BOOL) = completion_handler; | |
572 callable_block(NO); | |
573 }]; | |
574 | 498 |
575 [web_controller() setShouldSuppressDialogs:NO]; | 499 [web_controller() setShouldSuppressDialogs:NO]; |
576 EXPECT_NSEQ(@NO, ExecuteJavaScript(@"confirm('test')")); | 500 EXPECT_NSEQ(@NO, ExecuteJavaScript(@"confirm('test')")); |
| 501 |
| 502 ASSERT_EQ(1U, requested_dialogs().size()); |
| 503 web::TestJavaScriptDialog dialog = requested_dialogs()[0]; |
| 504 EXPECT_EQ(web_state(), dialog.web_state); |
| 505 EXPECT_EQ(page_url(), dialog.origin_url); |
| 506 EXPECT_EQ(web::JAVASCRIPT_DIALOG_TYPE_CONFIRM, |
| 507 dialog.java_script_dialog_type); |
| 508 EXPECT_NSEQ(@"test", dialog.message_text); |
| 509 EXPECT_FALSE(dialog.default_prompt_text); |
577 } | 510 } |
578 | 511 |
579 // Tests that window.prompt dialog is suppressed for DIALOG_POLICY_SUPPRESS. | 512 // Tests that window.prompt dialog is suppressed for DIALOG_POLICY_SUPPRESS. |
580 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressPrompt) { | 513 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressPrompt) { |
| 514 ASSERT_TRUE(requested_dialogs().empty()); |
| 515 |
581 [[web_delegate_mock() expect] | 516 [[web_delegate_mock() expect] |
582 webControllerDidSuppressDialog:web_controller()]; | 517 webControllerDidSuppressDialog:web_controller()]; |
583 [web_controller() setShouldSuppressDialogs:YES]; | 518 [web_controller() setShouldSuppressDialogs:YES]; |
584 EXPECT_EQ([NSNull null], ExecuteJavaScript(@"prompt('Yes?', 'No')")); | 519 EXPECT_EQ([NSNull null], ExecuteJavaScript(@"prompt('Yes?', 'No')")); |
| 520 |
| 521 ASSERT_TRUE(requested_dialogs().empty()); |
585 } | 522 } |
586 | 523 |
587 // Tests that window.prompt dialog is shown for DIALOG_POLICY_ALLOW. | 524 // Tests that window.prompt dialog is shown for DIALOG_POLICY_ALLOW. |
588 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowPrompt) { | 525 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowPrompt) { |
589 SEL selector = @selector(webController: | 526 ASSERT_TRUE(requested_dialogs().empty()); |
590 runJavaScriptTextInputPanelWithPrompt: | 527 |
591 defaultText: | 528 js_dialog_presenter()->set_callback_user_input_argument(@"Maybe"); |
592 requestURL: | |
593 completionHandler:); | |
594 [ui_delegate_mock() onSelector:selector | |
595 callBlockExpectation:^(CRWWebController* controller, | |
596 NSString* message, NSString* default_text, | |
597 const GURL& url, id completion_handler) { | |
598 EXPECT_NSEQ(web_controller(), controller); | |
599 EXPECT_NSEQ(@"Yes?", message); | |
600 EXPECT_NSEQ(@"No", default_text); | |
601 web::URLVerificationTrustLevel unused; | |
602 EXPECT_EQ([controller currentURLWithTrustLevel:&unused], url); | |
603 void (^callable_block)(NSString*) = completion_handler; | |
604 callable_block(@"Maybe"); | |
605 }]; | |
606 | 529 |
607 [web_controller() setShouldSuppressDialogs:NO]; | 530 [web_controller() setShouldSuppressDialogs:NO]; |
608 EXPECT_NSEQ(@"Maybe", ExecuteJavaScript(@"prompt('Yes?', 'No')")); | 531 EXPECT_NSEQ(@"Maybe", ExecuteJavaScript(@"prompt('Yes?', 'No')")); |
| 532 |
| 533 ASSERT_EQ(1U, requested_dialogs().size()); |
| 534 web::TestJavaScriptDialog dialog = requested_dialogs()[0]; |
| 535 EXPECT_EQ(web_state(), dialog.web_state); |
| 536 EXPECT_EQ(page_url(), dialog.origin_url); |
| 537 EXPECT_EQ(web::JAVASCRIPT_DIALOG_TYPE_PROMPT, dialog.java_script_dialog_type); |
| 538 EXPECT_NSEQ(@"Yes?", dialog.message_text); |
| 539 EXPECT_NSEQ(@"No", dialog.default_prompt_text); |
609 } | 540 } |
610 | 541 |
611 // Tests that geolocation dialog is suppressed for DIALOG_POLICY_SUPPRESS. | 542 // Tests that geolocation dialog is suppressed for DIALOG_POLICY_SUPPRESS. |
612 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressGeolocation) { | 543 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressGeolocation) { |
613 // The geolocation APIs require HTTPS on iOS 10, which can not be simulated | 544 // The geolocation APIs require HTTPS on iOS 10, which can not be simulated |
614 // even using |loadHTMLString:baseURL:| WKWebView API. | 545 // even using |loadHTMLString:baseURL:| WKWebView API. |
615 if (base::ios::IsRunningOnIOS10OrLater()) { | 546 if (base::ios::IsRunningOnIOS10OrLater()) { |
616 return; | 547 return; |
617 } | 548 } |
618 | 549 |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 | 1030 |
1100 [web_controller() setDelegate:delegate]; | 1031 [web_controller() setDelegate:delegate]; |
1101 web::SimulateWKWebViewCrash(webView_); | 1032 web::SimulateWKWebViewCrash(webView_); |
1102 | 1033 |
1103 EXPECT_OCMOCK_VERIFY(delegate); | 1034 EXPECT_OCMOCK_VERIFY(delegate); |
1104 EXPECT_FALSE([web_controller() isViewAlive]); | 1035 EXPECT_FALSE([web_controller() isViewAlive]); |
1105 [web_controller() setDelegate:nil]; | 1036 [web_controller() setDelegate:nil]; |
1106 }; | 1037 }; |
1107 | 1038 |
1108 } // namespace | 1039 } // namespace |
OLD | NEW |