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" | |
24 #import "ios/web/public/test/fakes/test_web_view_content_view.h" | 23 #import "ios/web/public/test/fakes/test_web_view_content_view.h" |
25 #import "ios/web/public/web_state/crw_web_controller_observer.h" | 24 #import "ios/web/public/web_state/crw_web_controller_observer.h" |
26 #import "ios/web/public/web_state/ui/crw_content_view.h" | 25 #import "ios/web/public/web_state/ui/crw_content_view.h" |
27 #import "ios/web/public/web_state/ui/crw_native_content.h" | 26 #import "ios/web/public/web_state/ui/crw_native_content.h" |
28 #import "ios/web/public/web_state/ui/crw_native_content_provider.h" | 27 #import "ios/web/public/web_state/ui/crw_native_content_provider.h" |
29 #import "ios/web/public/web_state/ui/crw_web_view_content_view.h" | 28 #import "ios/web/public/web_state/ui/crw_web_view_content_view.h" |
30 #include "ios/web/public/web_state/url_verification_constants.h" | 29 #include "ios/web/public/web_state/url_verification_constants.h" |
31 #include "ios/web/public/web_state/web_state_observer.h" | 30 #include "ios/web/public/web_state/web_state_observer.h" |
32 #import "ios/web/test/web_test_with_web_controller.h" | 31 #import "ios/web/test/web_test_with_web_controller.h" |
33 #import "ios/web/test/wk_web_view_crash_utils.h" | 32 #import "ios/web/test/wk_web_view_crash_utils.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // Blocked popup info received in |webController:didBlockPopup:| call. | 68 // Blocked popup info received in |webController:didBlockPopup:| call. |
70 // nullptr if that delegate method was not called. | 69 // nullptr if that delegate method was not called. |
71 @property(nonatomic, readonly) web::BlockedPopupInfo* blockedPopupInfo; | 70 @property(nonatomic, readonly) web::BlockedPopupInfo* blockedPopupInfo; |
72 @end | 71 @end |
73 | 72 |
74 // Stub implementation for CRWWebUserInterfaceDelegate protocol. | 73 // Stub implementation for CRWWebUserInterfaceDelegate protocol. |
75 @interface CRWWebUserInterfaceDelegateStub | 74 @interface CRWWebUserInterfaceDelegateStub |
76 : OCMockComplexTypeHelper<CRWWebUserInterfaceDelegate> | 75 : OCMockComplexTypeHelper<CRWWebUserInterfaceDelegate> |
77 @end | 76 @end |
78 | 77 |
| 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 |
79 @implementation MockInteractionLoader { | 135 @implementation MockInteractionLoader { |
80 // Backs up the property with the same name. | 136 // Backs up the property with the same name. |
81 std::unique_ptr<web::BlockedPopupInfo> _blockedPopupInfo; | 137 std::unique_ptr<web::BlockedPopupInfo> _blockedPopupInfo; |
82 } | 138 } |
83 @synthesize popupURL = _popupURL; | 139 @synthesize popupURL = _popupURL; |
84 @synthesize sourceURL = _sourceURL; | 140 @synthesize sourceURL = _sourceURL; |
85 @synthesize blockPopups = _blockPopups; | 141 @synthesize blockPopups = _blockPopups; |
86 @synthesize childWebController = _childWebController; | 142 @synthesize childWebController = _childWebController; |
87 | 143 |
88 typedef void (^webPageOrderedOpenBlankBlockType)(); | 144 typedef void (^webPageOrderedOpenBlankBlockType)(); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 EXPECT_EQ(net::CERT_STATUS_INVALID, | 451 EXPECT_EQ(net::CERT_STATUS_INVALID, |
396 GetWebClient()->last_cert_error_ssl_info().cert_status); | 452 GetWebClient()->last_cert_error_ssl_info().cert_status); |
397 EXPECT_EQ(url, GetWebClient()->last_cert_error_request_url()); | 453 EXPECT_EQ(url, GetWebClient()->last_cert_error_request_url()); |
398 EXPECT_FALSE(GetWebClient()->last_cert_error_overridable()); | 454 EXPECT_FALSE(GetWebClient()->last_cert_error_overridable()); |
399 } | 455 } |
400 | 456 |
401 // Test fixture to test |setPageDialogOpenPolicy:|. | 457 // Test fixture to test |setPageDialogOpenPolicy:|. |
402 class CRWWebControllerPageDialogOpenPolicyTest | 458 class CRWWebControllerPageDialogOpenPolicyTest |
403 : public web::WebTestWithWebController { | 459 : public web::WebTestWithWebController { |
404 protected: | 460 protected: |
405 CRWWebControllerPageDialogOpenPolicyTest() | |
406 : page_url_("https://chromium.test/") {} | |
407 void SetUp() override { | 461 void SetUp() override { |
408 web::WebTestWithWebController::SetUp(); | 462 web::WebTestWithWebController::SetUp(); |
409 LoadHtml(@"<html><body></body></html>", page_url_); | 463 LoadHtml(@"<html><body></body></html>"); |
410 web_delegate_mock_.reset( | 464 web_delegate_mock_.reset( |
411 [[OCMockObject mockForProtocol:@protocol(CRWWebDelegate)] retain]); | 465 [[OCMockObject mockForProtocol:@protocol(CRWWebDelegate)] retain]); |
412 [web_controller() setDelegate:web_delegate_mock_]; | 466 [web_controller() setDelegate:web_delegate_mock_]; |
413 web_state()->SetDelegate(&test_web_delegate_); | 467 id ui_delegate_oc_mock = |
| 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()]; |
414 } | 474 } |
415 void TearDown() override { | 475 void TearDown() override { |
416 WaitForBackgroundTasks(); | 476 WaitForBackgroundTasks(); |
417 EXPECT_OCMOCK_VERIFY(web_delegate_mock_); | 477 EXPECT_OCMOCK_VERIFY(web_delegate_mock_); |
| 478 EXPECT_OCMOCK_VERIFY(ui_delegate_mock_); |
418 [web_controller() setDelegate:nil]; | 479 [web_controller() setDelegate:nil]; |
419 web_state()->SetDelegate(nullptr); | 480 [web_controller() setUIDelegate:nil]; |
420 | 481 |
421 web::WebTestWithWebController::TearDown(); | 482 web::WebTestWithWebController::TearDown(); |
422 } | 483 } |
| 484 // Returns CRWWebDelegate mock object. |
423 id web_delegate_mock() { return web_delegate_mock_; }; | 485 id web_delegate_mock() { return web_delegate_mock_; }; |
424 web::TestJavaScriptDialogPresenter* js_dialog_presenter() { | 486 // Returns CRWWebUserInterfaceDelegate mock object. |
425 return test_web_delegate_.GetTestJavaScriptDialogPresenter(); | 487 id ui_delegate_mock() { return ui_delegate_mock_; }; |
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_; } | |
431 | 488 |
432 private: | 489 private: |
433 web::TestWebStateDelegate test_web_delegate_; | 490 // Mocks CRWWebDelegate object. |
434 base::scoped_nsprotocol<id> web_delegate_mock_; | 491 base::scoped_nsprotocol<id> web_delegate_mock_; |
435 GURL page_url_; | 492 // Mocks CRWWebUserInterfaceDelegate object. |
| 493 base::scoped_nsprotocol<id> ui_delegate_mock_; |
436 }; | 494 }; |
437 | 495 |
438 // Tests that window.alert dialog is suppressed for DIALOG_POLICY_SUPPRESS. | 496 // Tests that window.alert dialog is suppressed for DIALOG_POLICY_SUPPRESS. |
439 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressAlert) { | 497 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressAlert) { |
440 [[web_delegate_mock() expect] | 498 [[web_delegate_mock() expect] |
441 webControllerDidSuppressDialog:web_controller()]; | 499 webControllerDidSuppressDialog:web_controller()]; |
442 [web_controller() setShouldSuppressDialogs:YES]; | 500 [web_controller() setShouldSuppressDialogs:YES]; |
443 ExecuteJavaScript(@"alert('test')"); | 501 ExecuteJavaScript(@"alert('test')"); |
444 }; | 502 }; |
445 | 503 |
446 // Tests that window.alert dialog is shown for DIALOG_POLICY_ALLOW. | 504 // Tests that window.alert dialog is shown for DIALOG_POLICY_ALLOW. |
447 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowAlert) { | 505 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowAlert) { |
448 ASSERT_TRUE(requested_dialogs().empty()); | 506 SEL selector = @selector(webController: |
| 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 }]; |
449 | 520 |
450 [web_controller() setShouldSuppressDialogs:NO]; | 521 [web_controller() setShouldSuppressDialogs:NO]; |
451 ExecuteJavaScript(@"alert('test')"); | 522 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); | |
460 }; | 523 }; |
461 | 524 |
462 // Tests that window.confirm dialog is suppressed for DIALOG_POLICY_SUPPRESS. | 525 // Tests that window.confirm dialog is suppressed for DIALOG_POLICY_SUPPRESS. |
463 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressConfirm) { | 526 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressConfirm) { |
464 ASSERT_TRUE(requested_dialogs().empty()); | |
465 | |
466 [[web_delegate_mock() expect] | 527 [[web_delegate_mock() expect] |
467 webControllerDidSuppressDialog:web_controller()]; | 528 webControllerDidSuppressDialog:web_controller()]; |
468 [web_controller() setShouldSuppressDialogs:YES]; | 529 [web_controller() setShouldSuppressDialogs:YES]; |
469 EXPECT_NSEQ(@NO, ExecuteJavaScript(@"confirm('test')")); | 530 EXPECT_NSEQ(@NO, ExecuteJavaScript(@"confirm('test')")); |
470 | |
471 ASSERT_TRUE(requested_dialogs().empty()); | |
472 }; | 531 }; |
473 | 532 |
474 // Tests that window.confirm dialog is shown for DIALOG_POLICY_ALLOW and | 533 // Tests that window.confirm dialog is shown for DIALOG_POLICY_ALLOW and |
475 // it's result is true. | 534 // it's result is true. |
476 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowConfirmWithTrue) { | 535 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowConfirmWithTrue) { |
477 ASSERT_TRUE(requested_dialogs().empty()); | 536 SEL selector = @selector(webController: |
478 | 537 runJavaScriptConfirmPanelWithMessage: |
479 js_dialog_presenter()->set_callback_success_argument(true); | 538 requestURL: |
| 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 }]; |
480 | 551 |
481 [web_controller() setShouldSuppressDialogs:NO]; | 552 [web_controller() setShouldSuppressDialogs:NO]; |
482 EXPECT_NSEQ(@YES, ExecuteJavaScript(@"confirm('test')")); | 553 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); | |
492 } | 554 } |
493 | 555 |
494 // Tests that window.confirm dialog is shown for DIALOG_POLICY_ALLOW and | 556 // Tests that window.confirm dialog is shown for DIALOG_POLICY_ALLOW and |
495 // it's result is false. | 557 // it's result is false. |
496 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowConfirmWithFalse) { | 558 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowConfirmWithFalse) { |
497 ASSERT_TRUE(requested_dialogs().empty()); | 559 SEL selector = @selector(webController: |
| 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 }]; |
498 | 574 |
499 [web_controller() setShouldSuppressDialogs:NO]; | 575 [web_controller() setShouldSuppressDialogs:NO]; |
500 EXPECT_NSEQ(@NO, ExecuteJavaScript(@"confirm('test')")); | 576 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); | |
510 } | 577 } |
511 | 578 |
512 // Tests that window.prompt dialog is suppressed for DIALOG_POLICY_SUPPRESS. | 579 // Tests that window.prompt dialog is suppressed for DIALOG_POLICY_SUPPRESS. |
513 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressPrompt) { | 580 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressPrompt) { |
514 ASSERT_TRUE(requested_dialogs().empty()); | |
515 | |
516 [[web_delegate_mock() expect] | 581 [[web_delegate_mock() expect] |
517 webControllerDidSuppressDialog:web_controller()]; | 582 webControllerDidSuppressDialog:web_controller()]; |
518 [web_controller() setShouldSuppressDialogs:YES]; | 583 [web_controller() setShouldSuppressDialogs:YES]; |
519 EXPECT_EQ([NSNull null], ExecuteJavaScript(@"prompt('Yes?', 'No')")); | 584 EXPECT_EQ([NSNull null], ExecuteJavaScript(@"prompt('Yes?', 'No')")); |
520 | |
521 ASSERT_TRUE(requested_dialogs().empty()); | |
522 } | 585 } |
523 | 586 |
524 // Tests that window.prompt dialog is shown for DIALOG_POLICY_ALLOW. | 587 // Tests that window.prompt dialog is shown for DIALOG_POLICY_ALLOW. |
525 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowPrompt) { | 588 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, AllowPrompt) { |
526 ASSERT_TRUE(requested_dialogs().empty()); | 589 SEL selector = @selector(webController: |
527 | 590 runJavaScriptTextInputPanelWithPrompt: |
528 js_dialog_presenter()->set_callback_user_input_argument(@"Maybe"); | 591 defaultText: |
| 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 }]; |
529 | 606 |
530 [web_controller() setShouldSuppressDialogs:NO]; | 607 [web_controller() setShouldSuppressDialogs:NO]; |
531 EXPECT_NSEQ(@"Maybe", ExecuteJavaScript(@"prompt('Yes?', 'No')")); | 608 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); | |
540 } | 609 } |
541 | 610 |
542 // Tests that geolocation dialog is suppressed for DIALOG_POLICY_SUPPRESS. | 611 // Tests that geolocation dialog is suppressed for DIALOG_POLICY_SUPPRESS. |
543 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressGeolocation) { | 612 TEST_F(CRWWebControllerPageDialogOpenPolicyTest, SuppressGeolocation) { |
544 // The geolocation APIs require HTTPS on iOS 10, which can not be simulated | 613 // The geolocation APIs require HTTPS on iOS 10, which can not be simulated |
545 // even using |loadHTMLString:baseURL:| WKWebView API. | 614 // even using |loadHTMLString:baseURL:| WKWebView API. |
546 if (base::ios::IsRunningOnIOS10OrLater()) { | 615 if (base::ios::IsRunningOnIOS10OrLater()) { |
547 return; | 616 return; |
548 } | 617 } |
549 | 618 |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 | 1099 |
1031 [web_controller() setDelegate:delegate]; | 1100 [web_controller() setDelegate:delegate]; |
1032 web::SimulateWKWebViewCrash(webView_); | 1101 web::SimulateWKWebViewCrash(webView_); |
1033 | 1102 |
1034 EXPECT_OCMOCK_VERIFY(delegate); | 1103 EXPECT_OCMOCK_VERIFY(delegate); |
1035 EXPECT_FALSE([web_controller() isViewAlive]); | 1104 EXPECT_FALSE([web_controller() isViewAlive]); |
1036 [web_controller() setDelegate:nil]; | 1105 [web_controller() setDelegate:nil]; |
1037 }; | 1106 }; |
1038 | 1107 |
1039 } // namespace | 1108 } // namespace |
OLD | NEW |