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 #include "base/mac/scoped_nsobject.h" | 12 #include "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 #include "ios/web/navigation/crw_session_controller.h" | 15 #include "ios/web/navigation/crw_session_controller.h" |
16 #include "ios/web/navigation/crw_session_entry.h" | 16 #include "ios/web/navigation/crw_session_entry.h" |
17 #include "ios/web/navigation/navigation_item_impl.h" | 17 #include "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/test_native_content.h" | 20 #import "ios/web/public/test/test_native_content.h" |
21 #import "ios/web/public/test/test_native_content_provider.h" | 21 #import "ios/web/public/test/test_native_content_provider.h" |
22 #import "ios/web/public/test/test_web_client.h" | 22 #import "ios/web/public/test/test_web_client.h" |
23 #include "ios/web/public/test/test_web_view_content_view.h" | 23 #include "ios/web/public/test/test_web_view_content_view.h" |
24 #import "ios/web/public/web_state/crw_web_controller_observer.h" | 24 #import "ios/web/public/web_state/crw_web_controller_observer.h" |
25 #import "ios/web/public/web_state/ui/crw_content_view.h" | 25 #import "ios/web/public/web_state/ui/crw_content_view.h" |
26 #import "ios/web/public/web_state/ui/crw_native_content.h" | 26 #import "ios/web/public/web_state/ui/crw_native_content.h" |
27 #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" |
28 #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" |
29 #include "ios/web/public/web_state/url_verification_constants.h" | 29 #include "ios/web/public/web_state/url_verification_constants.h" |
30 #include "ios/web/public/web_state/web_state_observer.h" | |
30 #import "ios/web/test/web_test_with_web_controller.h" | 31 #import "ios/web/test/web_test_with_web_controller.h" |
31 #import "ios/web/test/wk_web_view_crash_utils.h" | 32 #import "ios/web/test/wk_web_view_crash_utils.h" |
32 #include "ios/web/web_state/blocked_popup_info.h" | 33 #include "ios/web/web_state/blocked_popup_info.h" |
33 #import "ios/web/web_state/ui/crw_web_controller_container_view.h" | 34 #import "ios/web/web_state/ui/crw_web_controller_container_view.h" |
34 #import "ios/web/web_state/web_state_impl.h" | 35 #import "ios/web/web_state/web_state_impl.h" |
35 #import "ios/web/web_state/wk_web_view_security_util.h" | 36 #import "ios/web/web_state/wk_web_view_security_util.h" |
36 #import "net/base/mac/url_conversions.h" | 37 #import "net/base/mac/url_conversions.h" |
37 #include "net/ssl/ssl_info.h" | 38 #include "net/ssl/ssl_info.h" |
38 #include "net/test/cert_test_util.h" | 39 #include "net/test/cert_test_util.h" |
39 #include "net/test/test_data_directory.h" | 40 #include "net/test/test_data_directory.h" |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
764 LoadHtml(@"<html><body></body></html>", GURL("http://chromium.test")); | 765 LoadHtml(@"<html><body></body></html>", GURL("http://chromium.test")); |
765 NavigationManagerImpl& nav_manager = | 766 NavigationManagerImpl& nav_manager = |
766 web_controller().webStateImpl->GetNavigationManagerImpl(); | 767 web_controller().webStateImpl->GetNavigationManagerImpl(); |
767 EXPECT_FALSE(nav_manager.GetLastCommittedItem()->GetSSL().content_status & | 768 EXPECT_FALSE(nav_manager.GetLastCommittedItem()->GetSSL().content_status & |
768 web::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); | 769 web::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); |
769 [web_controller() didShowPasswordInputOnHTTP]; | 770 [web_controller() didShowPasswordInputOnHTTP]; |
770 EXPECT_TRUE(nav_manager.GetLastCommittedItem()->GetSSL().content_status & | 771 EXPECT_TRUE(nav_manager.GetLastCommittedItem()->GetSSL().content_status & |
771 web::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); | 772 web::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); |
772 } | 773 } |
773 | 774 |
775 // Real WKWebView is required for CRWWebControllerFormActivityTest. | |
776 typedef web::WebTestWithWebController CRWWebControllerFormActivityTest; | |
777 | |
778 // Tests that keyup event correctly delivered to WebStateObserver. | |
779 TEST_F(CRWWebControllerFormActivityTest, KeyUpEvent) { | |
780 // Observes and verifies FormActivityRegistered call. | |
781 class FormActivityObserver : public web::WebStateObserver { | |
782 public: | |
783 explicit FormActivityObserver(web::WebState* web_state) | |
784 : web::WebStateObserver(web_state) {} | |
785 bool form_activity_registered() const { return form_activity_registered_; } | |
786 // WebStateObserver overrides: | |
787 void FormActivityRegistered(const std::string& form_name, | |
788 const std::string& field_name, | |
789 const std::string& type, | |
790 const std::string& value, | |
791 bool input_missing) override { | |
792 EXPECT_EQ("keyup", type); | |
793 EXPECT_FALSE(input_missing); | |
794 form_activity_registered_ = true; | |
795 } | |
796 | |
797 private: | |
798 bool form_activity_registered_ = false; | |
799 }; | |
800 FormActivityObserver form_activity_observer(web_state()); | |
801 FormActivityObserver& form_activity_observer_ref(form_activity_observer); | |
802 | |
803 LoadHtml(@"<p></p>"); | |
804 ExecuteJavaScript(@"document.dispatchEvent(new KeyboardEvent('keyup'));"); | |
Eugene But (OOO till 7-30)
2016/12/22 00:21:29
I tried to dispatch event with form input target,
| |
805 base::test::ios::WaitUntilCondition(^{ | |
806 return form_activity_observer_ref.form_activity_registered(); | |
807 }); | |
808 } | |
809 | |
774 // Real WKWebView is required for CRWWebControllerJSExecutionTest. | 810 // Real WKWebView is required for CRWWebControllerJSExecutionTest. |
775 typedef web::WebTestWithWebController CRWWebControllerJSExecutionTest; | 811 typedef web::WebTestWithWebController CRWWebControllerJSExecutionTest; |
776 | 812 |
777 // Tests that a script correctly evaluates to boolean. | 813 // Tests that a script correctly evaluates to boolean. |
778 TEST_F(CRWWebControllerJSExecutionTest, Execution) { | 814 TEST_F(CRWWebControllerJSExecutionTest, Execution) { |
779 LoadHtml(@"<p></p>"); | 815 LoadHtml(@"<p></p>"); |
780 EXPECT_NSEQ(@YES, ExecuteJavaScript(@"true")); | 816 EXPECT_NSEQ(@YES, ExecuteJavaScript(@"true")); |
781 EXPECT_NSEQ(@NO, ExecuteJavaScript(@"false")); | 817 EXPECT_NSEQ(@NO, ExecuteJavaScript(@"false")); |
782 } | 818 } |
783 | 819 |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1059 | 1095 |
1060 [web_controller() setDelegate:delegate]; | 1096 [web_controller() setDelegate:delegate]; |
1061 web::SimulateWKWebViewCrash(webView_); | 1097 web::SimulateWKWebViewCrash(webView_); |
1062 | 1098 |
1063 EXPECT_OCMOCK_VERIFY(delegate); | 1099 EXPECT_OCMOCK_VERIFY(delegate); |
1064 EXPECT_FALSE([web_controller() isViewAlive]); | 1100 EXPECT_FALSE([web_controller() isViewAlive]); |
1065 [web_controller() setDelegate:nil]; | 1101 [web_controller() setDelegate:nil]; |
1066 }; | 1102 }; |
1067 | 1103 |
1068 } // namespace | 1104 } // namespace |
OLD | NEW |