OLD | NEW |
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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 #include "chrome_frame/test/test_with_web_server.h" | 4 #include "chrome_frame/test/test_with_web_server.h" |
5 | 5 |
6 #include "base/file_version_info.h" | 6 #include "base/file_version_info.h" |
7 #include "chrome/common/chrome_switches.h" | 7 #include "chrome/common/chrome_switches.h" |
8 #include "chrome/installer/util/install_util.h" | 8 #include "chrome/installer/util/install_util.h" |
9 #include "chrome/installer/util/helper.h" | 9 #include "chrome/installer/util/helper.h" |
10 #include "chrome_frame/utils.h" | 10 #include "chrome_frame/utils.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 if (!::GetExitCodeProcess(browser_handle_, &exit_code) || | 113 if (!::GetExitCodeProcess(browser_handle_, &exit_code) || |
114 exit_code == STILL_ACTIVE) { | 114 exit_code == STILL_ACTIVE) { |
115 LOG(ERROR) << L"Forcefully killing browser process. Exit:" << exit_code; | 115 LOG(ERROR) << L"Forcefully killing browser process. Exit:" << exit_code; |
116 base::KillProcess(browser_handle_, 0, true); | 116 base::KillProcess(browser_handle_, 0, true); |
117 } | 117 } |
118 browser_handle_.Close(); | 118 browser_handle_.Close(); |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 bool ChromeFrameTestWithWebServer::BringBrowserToTop() { | 122 bool ChromeFrameTestWithWebServer::BringBrowserToTop() { |
123 return chrome_frame_test::EnsureProcessInForeground( | 123 return simulate_input::EnsureProcessInForeground( |
124 GetProcessId(browser_handle_)); | 124 GetProcessId(browser_handle_)); |
125 } | 125 } |
126 | 126 |
127 bool ChromeFrameTestWithWebServer::WaitForTestToComplete(int milliseconds) { | 127 bool ChromeFrameTestWithWebServer::WaitForTestToComplete(int milliseconds) { |
128 return server_.WaitToFinish(milliseconds); | 128 return server_.WaitToFinish(milliseconds); |
129 } | 129 } |
130 | 130 |
131 bool ChromeFrameTestWithWebServer::WaitForOnLoad(int milliseconds) { | 131 bool ChromeFrameTestWithWebServer::WaitForOnLoad(int milliseconds) { |
132 DWORD start = ::GetTickCount(); | 132 DWORD start = ::GetTickCount(); |
133 std::string data; | 133 std::string data; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 } else { | 307 } else { |
308 ASSERT_TRUE(WaitForOnLoad(kLongWaitTimeout)); | 308 ASSERT_TRUE(WaitForOnLoad(kLongWaitTimeout)); |
309 BringBrowserToTop(); | 309 BringBrowserToTop(); |
310 // Tab through a couple of times. Once should be enough in theory | 310 // Tab through a couple of times. Once should be enough in theory |
311 // but in practice activating the browser can take a few milliseconds more. | 311 // but in practice activating the browser can take a few milliseconds more. |
312 bool ok; | 312 bool ok; |
313 for (int i = 0; | 313 for (int i = 0; |
314 i < 5 && (ok = CheckResultFile(L"ObjectFocus", "OK")) == false; | 314 i < 5 && (ok = CheckResultFile(L"ObjectFocus", "OK")) == false; |
315 ++i) { | 315 ++i) { |
316 Sleep(300); | 316 Sleep(300); |
317 chrome_frame_test::SendMnemonic(VK_TAB, false, false, false); | 317 simulate_input::SendMnemonic(VK_TAB, false, false, false, false, false); |
318 } | 318 } |
319 ASSERT_TRUE(ok); | 319 ASSERT_TRUE(ok); |
320 } | 320 } |
321 } | 321 } |
322 | 322 |
323 const wchar_t kiframeBasicPage[] = L"files/iframe_basic_host.html"; | 323 const wchar_t kiframeBasicPage[] = L"files/iframe_basic_host.html"; |
324 | 324 |
325 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_iframeBasic) { | 325 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_iframeBasic) { |
326 SimpleBrowserTest(IE, kiframeBasicPage, L"PostMessage"); | 326 SimpleBrowserTest(IE, kiframeBasicPage, L"PostMessage"); |
327 } | 327 } |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 const wchar_t kSubFrameTestPage[] = L"files/full_tab_sub_frame_main.html"; | 691 const wchar_t kSubFrameTestPage[] = L"files/full_tab_sub_frame_main.html"; |
692 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_SubFrame) { | 692 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_SubFrame) { |
693 SimpleBrowserTest(IE, kSubFrameTestPage, L"sub_frame"); | 693 SimpleBrowserTest(IE, kSubFrameTestPage, L"sub_frame"); |
694 } | 694 } |
695 | 695 |
696 const wchar_t kSubIFrameTestPage[] = L"files/full_tab_sub_iframe_main.html"; | 696 const wchar_t kSubIFrameTestPage[] = L"files/full_tab_sub_iframe_main.html"; |
697 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_SubIFrame) { | 697 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_SubIFrame) { |
698 SimpleBrowserTest(IE, kSubIFrameTestPage, L"sub_frame"); | 698 SimpleBrowserTest(IE, kSubIFrameTestPage, L"sub_frame"); |
699 } | 699 } |
700 | 700 |
701 const wchar_t kChromeFrameFullTabModeKeyEventUrl[] = L"files/keyevent.html"; | 701 const wchar_t kXMLHttpRequestTestUrl[] = |
| 702 L"files/xmlhttprequest_test.html"; |
702 | 703 |
703 // Marking this test FLAKY as it fails at times on the buildbot. | 704 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_XHRTest) { |
704 // http://code.google.com/p/chromium/issues/detail?id=26549 | |
705 TEST_F(ChromeFrameTestWithWebServer, | |
706 FLAKY_FullTabModeIE_ChromeFrameKeyboardTest) { | |
707 chrome_frame_test::TimedMsgLoop loop; | 705 chrome_frame_test::TimedMsgLoop loop; |
708 | 706 ASSERT_TRUE(LaunchBrowser(IE, kXMLHttpRequestTestUrl)); |
709 ASSERT_TRUE(LaunchBrowser(IE, kChromeFrameFullTabModeKeyEventUrl)); | |
710 | |
711 // Allow some time for chrome to be launched. | |
712 loop.RunFor(kChromeFrameLaunchDelay); | |
713 | |
714 HWND renderer_window = chrome_frame_test::GetChromeRendererWindow(); | |
715 EXPECT_TRUE(IsWindow(renderer_window)); | |
716 | |
717 chrome_frame_test::SetKeyboardFocusToWindow(renderer_window, 1, 1); | |
718 chrome_frame_test::SendInputToWindow(renderer_window, "Chrome"); | |
719 | 707 |
720 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 708 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
721 | 709 |
722 chrome_frame_test::CloseAllIEWindows(); | 710 chrome_frame_test::CloseAllIEWindows(); |
723 ASSERT_TRUE(CheckResultFile(L"FullTab_KeyboardTest", "OK")); | |
724 } | |
725 | |
726 const wchar_t kChromeFrameAboutBlankUrl[] = L"gcf:about:blank"; | |
727 | |
728 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_ChromeFrameFocusTest) { | |
729 chrome_frame_test::TimedMsgLoop loop; | |
730 | |
731 ASSERT_TRUE(LaunchBrowser(IE, kChromeFrameAboutBlankUrl)); | |
732 | |
733 // Allow some time for chrome to be launched. | |
734 loop.RunFor(kChromeFrameLaunchDelay); | |
735 | |
736 HWND renderer_window = chrome_frame_test::GetChromeRendererWindow(); | |
737 EXPECT_TRUE(IsWindow(renderer_window)); | |
738 | |
739 DWORD renderer_thread_id = 0; | |
740 DWORD renderer_process_id = 0; | |
741 renderer_thread_id = GetWindowThreadProcessId(renderer_window, | |
742 &renderer_process_id); | |
743 | |
744 AttachThreadInput(GetCurrentThreadId(), renderer_thread_id, TRUE); | |
745 HWND focus_window = GetFocus(); | |
746 EXPECT_TRUE(focus_window == renderer_window); | |
747 AttachThreadInput(GetCurrentThreadId(), renderer_thread_id, FALSE); | |
748 | |
749 chrome_frame_test::CloseAllIEWindows(); | |
750 } | |
751 | |
752 const wchar_t kChromeFrameFullTabModeXMLHttpRequestTestUrl[] = | |
753 L"files/xmlhttprequest_test.html"; | |
754 | |
755 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_ChromeFrameXHRTest) { | |
756 chrome_frame_test::TimedMsgLoop loop; | |
757 | |
758 ASSERT_TRUE(LaunchBrowser(IE, kChromeFrameFullTabModeXMLHttpRequestTestUrl)); | |
759 | |
760 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
761 | |
762 chrome_frame_test::CloseAllIEWindows(); | |
763 ASSERT_TRUE(CheckResultFile(L"FullTab_XMLHttpRequestTest", "OK")); | 711 ASSERT_TRUE(CheckResultFile(L"FullTab_XMLHttpRequestTest", "OK")); |
764 } | 712 } |
765 | 713 |
766 const wchar_t kMultipleCFInstancesTestUrl[] = | 714 const wchar_t kMultipleCFInstancesTestUrl[] = |
767 L"files/multiple_cf_instances_main.html"; | 715 L"files/multiple_cf_instances_main.html"; |
768 | 716 |
769 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_MultipleCFInstances) { | 717 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_MultipleCFInstances) { |
770 SimpleBrowserTest(IE, kMultipleCFInstancesTestUrl, | 718 SimpleBrowserTest(IE, kMultipleCFInstancesTestUrl, |
771 L"WidgetMode_MultipleInstancesTest"); | 719 L"WidgetMode_MultipleInstancesTest"); |
772 } | 720 } |
773 | 721 |
774 // TODO(ananta) | 722 // TODO(ananta) |
775 // Disabled until I figure out why this does not work on Firefox. | 723 // Disabled until I figure out why this does not work on Firefox. |
776 TEST_F(ChromeFrameTestWithWebServer, | 724 TEST_F(ChromeFrameTestWithWebServer, |
777 DISABLED_WidgetModeFF_MultipleCFInstances) { | 725 DISABLED_WidgetModeFF_MultipleCFInstances) { |
778 SimpleBrowserTest(FIREFOX, kMultipleCFInstancesTestUrl, | 726 SimpleBrowserTest(FIREFOX, kMultipleCFInstancesTestUrl, |
779 L"WidgetMode_MultipleInstancesTest"); | 727 L"WidgetMode_MultipleInstancesTest"); |
780 } | 728 } |
781 | 729 |
782 const wchar_t kChromeFrameFullTabModeXMLHttpRequestAuthHeaderTestUrl[] = | 730 const wchar_t kXHRAuthHeaderTestUrl[] = |
783 L"files/xmlhttprequest_authorization_header_test.html"; | 731 L"files/xmlhttprequest_authorization_header_test.html"; |
784 | 732 |
785 TEST_F(ChromeFrameTestWithWebServer, | 733 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_XHRAuthHeaderTest) { |
786 FullTabModeIE_ChromeFrameXHRAuthHeaderTest) { | |
787 chrome_frame_test::TimedMsgLoop loop; | 734 chrome_frame_test::TimedMsgLoop loop; |
788 | 735 ASSERT_TRUE(LaunchBrowser(IE, kXHRAuthHeaderTestUrl)); |
789 ASSERT_TRUE(LaunchBrowser( | |
790 IE, kChromeFrameFullTabModeXMLHttpRequestAuthHeaderTestUrl)); | |
791 | 736 |
792 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 737 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
793 | 738 |
794 chrome_frame_test::CloseAllIEWindows(); | 739 chrome_frame_test::CloseAllIEWindows(); |
795 ASSERT_TRUE( | 740 ASSERT_TRUE(CheckResultFile(L"FullTabModeIE_XHRAuthHeaderTest", "OK")); |
796 CheckResultFile(L"FullTab_XMLHttpRequestAuthorizationHeaderTest", "OK")); | |
797 } | 741 } |
798 | 742 |
799 const wchar_t kChromeFrameFullTabModeDeleteCookieTest[] = | 743 const wchar_t kDeleteCookieTest[] = |
800 L"files/fulltab_delete_cookie_test.html"; | 744 L"files/fulltab_delete_cookie_test.html"; |
801 | 745 |
802 TEST_F(ChromeFrameTestWithWebServer, | 746 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_DeleteCookieTest) { |
803 FullTabModeIE_ChromeFrameDeleteCookieTest) { | |
804 chrome_frame_test::TimedMsgLoop loop; | 747 chrome_frame_test::TimedMsgLoop loop; |
805 | 748 ASSERT_TRUE(LaunchBrowser(IE, kDeleteCookieTest)); |
806 ASSERT_TRUE(LaunchBrowser(IE, kChromeFrameFullTabModeDeleteCookieTest)); | |
807 | 749 |
808 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 750 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
809 | 751 |
810 chrome_frame_test::CloseAllIEWindows(); | 752 chrome_frame_test::CloseAllIEWindows(); |
811 ASSERT_TRUE(CheckResultFile(L"FullTab_DeleteCookieTest", "OK")); | 753 ASSERT_TRUE(CheckResultFile(L"FullTab_DeleteCookieTest", "OK")); |
812 } | 754 } |
813 | 755 |
814 const wchar_t kChromeFrameFullTabModeAnchorUrlNavigate[] = | 756 const wchar_t kAnchorUrlNavigate[] = |
815 L"files/fulltab_anchor_url_navigate.html#chrome_frame"; | 757 L"files/fulltab_anchor_url_navigate.html#chrome_frame"; |
816 | 758 |
| 759 // http://code.google.com/p/chromium/issues/detail?id=35341 |
817 TEST_F(ChromeFrameTestWithWebServer, | 760 TEST_F(ChromeFrameTestWithWebServer, |
818 FullTabModeIE_ChromeFrameAnchorUrlNavigateTest) { | 761 FLAKY_FullTabModeIE_AnchorUrlNavigateTest) { |
819 chrome_frame_test::TimedMsgLoop loop; | 762 chrome_frame_test::TimedMsgLoop loop; |
820 | 763 ASSERT_TRUE(LaunchBrowser(IE, kAnchorUrlNavigate)); |
821 ASSERT_TRUE(LaunchBrowser(IE, kChromeFrameFullTabModeAnchorUrlNavigate)); | |
822 | 764 |
823 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 765 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
824 | 766 |
825 chrome_frame_test::CloseAllIEWindows(); | 767 chrome_frame_test::CloseAllIEWindows(); |
826 ASSERT_TRUE(CheckResultFile(L"FullTab_AnchorURLNavigateTest", "OK")); | 768 ASSERT_TRUE(CheckResultFile(L"FullTab_AnchorURLNavigateTest", "OK")); |
827 } | 769 } |
828 | 770 |
829 // DISABLED as it currently fails for both approaches for switching | 771 // DISABLED as it currently fails for both approaches for switching |
830 // renderers (httpequiv and IInternetProtocol). | 772 // renderers (httpequiv and IInternetProtocol). |
831 // TODO(tommi): Enable this test once the issue has been fixed. | 773 // TODO(tommi): Enable this test once the issue has been fixed. |
832 TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_TestPostReissue) { | 774 TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_TestPostReissue) { |
833 // Test whether POST-ing a form from an mshtml page to a CF page will cause | 775 // Test whether POST-ing a form from an mshtml page to a CF page will cause |
834 // the request to get reissued. It should not. | 776 // the request to get reissued. It should not. |
835 | |
836 | |
837 FilePath source_path; | 777 FilePath source_path; |
838 PathService::Get(base::DIR_SOURCE_ROOT, &source_path); | 778 PathService::Get(base::DIR_SOURCE_ROOT, &source_path); |
839 source_path = source_path.Append(FILE_PATH_LITERAL("chrome_frame")) | 779 source_path = source_path.Append(FILE_PATH_LITERAL("chrome_frame")) |
840 .Append(FILE_PATH_LITERAL("test")) | 780 .Append(FILE_PATH_LITERAL("test")) |
841 .Append(FILE_PATH_LITERAL("data")); | 781 .Append(FILE_PATH_LITERAL("data")); |
842 | 782 |
843 // The order of pages in this array is assumed to be mshtml, cf, script. | 783 // The order of pages in this array is assumed to be mshtml, cf, script. |
844 const wchar_t* kPages[] = { | 784 const wchar_t* kPages[] = { |
845 L"full_tab_post_mshtml.html", | 785 L"full_tab_post_mshtml.html", |
846 L"full_tab_post_target_cf.html", | 786 L"full_tab_post_target_cf.html", |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 const test_server::Request& r = c->request(); | 818 const test_server::Request& r = c->request(); |
879 if (ASCIIToWide(r.path().substr(1)).compare(kPages[1]) == 0) { | 819 if (ASCIIToWide(r.path().substr(1)).compare(kPages[1]) == 0) { |
880 EXPECT_EQ("POST", r.method()); | 820 EXPECT_EQ("POST", r.method()); |
881 requests_for_cf_page++; | 821 requests_for_cf_page++; |
882 } | 822 } |
883 } | 823 } |
884 EXPECT_EQ(1, requests_for_cf_page); | 824 EXPECT_EQ(1, requests_for_cf_page); |
885 } | 825 } |
886 } | 826 } |
887 | 827 |
OLD | NEW |