diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-12 19:48:06 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-12 19:48:06 +0000 |
commit | 0aa22e2feda12ca6a9e9f26a084a2307acfcc080 (patch) | |
tree | 22442de31cd390091fb7bc338f3ade0b5f689d3a /chrome_frame/test | |
parent | 591948964e3088901b3d66fee2837446700d9083 (diff) | |
download | chromium_src-0aa22e2feda12ca6a9e9f26a084a2307acfcc080.zip chromium_src-0aa22e2feda12ca6a9e9f26a084a2307acfcc080.tar.gz chromium_src-0aa22e2feda12ca6a9e9f26a084a2307acfcc080.tar.bz2 |
When ChromeFrame switches to IE on receiving the OnHttpEquiv notification indicating the presence of a meta
tag indicating that the page is to be rendered in Chrome, we check if the notification is received for a
site rendered in an IFrame to ensure that we don't switch in this case. This code is not reliable and we end
up assuming that a top level navigation is actually an embedded frame.
To work around this we now maintain a pending navigation count in BeforeNavigate2, which is decremented in
NavigateComplete2 and NavigateError. We perform the check for an embedded document only if the pending navigation
count is greater than 1.
This fixes http://code.google.com/p/chromium/issues/detail?id=36825
The other change made is to add a delay of 100ms in SendString between each character to better reflect actual
timing for real user input.
Bug=36825
Review URL: http://codereview.chromium.org/837008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41463 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test')
-rw-r--r-- | chrome_frame/test/data/host_browser.html | 8 | ||||
-rw-r--r-- | chrome_frame/test/test_mock_with_web_server.cc | 62 |
2 files changed, 69 insertions, 1 deletions
diff --git a/chrome_frame/test/data/host_browser.html b/chrome_frame/test/data/host_browser.html new file mode 100644 index 0000000..cfd21f4 --- /dev/null +++ b/chrome_frame/test/data/host_browser.html @@ -0,0 +1,8 @@ +<html> + <head><title>Initial Page in host browser</title> + </head> + <body onLoad="test();"> + <h2>Initial page in host browser!</h2> + <p>This page should have loaded in the host browser.</p> + </body> +</html> diff --git a/chrome_frame/test/test_mock_with_web_server.cc b/chrome_frame/test/test_mock_with_web_server.cc index dd02150..83522aa 100644 --- a/chrome_frame/test/test_mock_with_web_server.cc +++ b/chrome_frame/test/test_mock_with_web_server.cc @@ -220,6 +220,19 @@ ACTION(DoCloseWindow) { ::PostMessage(arg0, WM_SYSCOMMAND, SC_CLOSE, 0); } +ACTION_P2(TypeUrlInAddressBar, loop, url) { + loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( + simulate_input::SendCharA, 'd', simulate_input::ALT), + 1500); + + loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( + simulate_input::SendStringW, url), 2000); + + loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( + simulate_input::SendCharA, VK_RETURN, simulate_input::NONE), + 2000); +} + TEST(ChromeFrameTest, FullTabModeIE_DisallowedUrls) { CloseIeAtEndOfScope last_resort_close_ie; chrome_frame_test::TimedMsgLoop loop; @@ -735,7 +748,7 @@ const wchar_t kBeforeUnloadMain[] = L"http://localhost:1337/files/fulltab_before_unload_event_main.html"; // http://code.google.com/p/chromium/issues/detail?id=37231 -TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_UnloadEventTest) { +TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_UnloadEventTest) { CloseIeAtEndOfScope last_resort_close_ie; chrome_frame_test::TimedMsgLoop loop; ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; @@ -1128,3 +1141,50 @@ TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_MenuSaveAs) { ASSERT_TRUE(DeleteFile(kSaveFileName)); } +const wchar_t kHostBrowserUrl[] = + L"http://localhost:1337/files/host_browser.html"; + +TEST_F(ChromeFrameTestWithWebServer, + FullTabMode_SwitchFromIEToChromeFrame) { + CloseIeAtEndOfScope last_resort_close_ie; + chrome_frame_test::TimedMsgLoop loop; + ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; + + EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _)) + .Times(testing::AnyNumber()); + + ::testing::InSequence sequence; // Everything in sequence + + // This test performs the following steps. + // 1. Launches IE and navigates to + // http://localhost:1337/files/back_to_ie.html, which should render in IE. + // 2. It then navigates to + // http://localhost:1337/files/sub_frame1.html which should render in + // ChromeFrame + EXPECT_CALL(mock, OnBeforeNavigate2(_, + testing::Field(&VARIANT::bstrVal, + testing::StrCaseEq(kHostBrowserUrl)), _, _, _, _, _)); + + // When we receive a navigate complete notification for the initial URL + // initiate a navigation to a url which should be rendered in ChromeFrame. + EXPECT_CALL(mock, OnNavigateComplete2(_, + testing::Field(&VARIANT::bstrVal, + testing::StrCaseEq(kHostBrowserUrl)))) + .Times(1) + .WillOnce(TypeUrlInAddressBar(&loop, kSubFrameUrl1)); + + mock.ExpectNavigationAndSwitch(kSubFrameUrl1); + EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl1))) + .WillOnce(CloseBrowserMock(&mock)); + + EXPECT_CALL(mock, OnQuit()).WillOnce(QUIT_LOOP(loop)); + + HRESULT hr = mock.LaunchIEAndNavigate(kHostBrowserUrl); + ASSERT_HRESULT_SUCCEEDED(hr); + if (hr == S_FALSE) + return; + + ASSERT_TRUE(mock.web_browser2() != NULL); + loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds * 2); +} + |