summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-03 01:14:45 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-03 01:14:45 +0000
commitc9555c02cfaa69a50eff610edad10bbab938976a (patch)
treea58159189529a195f808da586683dfe8a95893e8 /chrome_frame
parentaca3e9b6ab27f5606b8b4ad6fcc27f0f0bc91f6e (diff)
downloadchromium_src-c9555c02cfaa69a50eff610edad10bbab938976a.zip
chromium_src-c9555c02cfaa69a50eff610edad10bbab938976a.tar.gz
chromium_src-c9555c02cfaa69a50eff610edad10bbab938976a.tar.bz2
Don't switch to CF's active document for frames or iframes.This fixes an issue where a page that uses CF would be loaded in an IFRAME on Google Images.Instead of attempting to load CF (not supported), we now defer to the host browser. Previously a blank page was displayed.TEST=Run new unit tests: FullTabModeIE_SubIFrame and FullTabModeIE_SubFrameBUG=22989
Review URL: http://codereview.chromium.org/343086 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30782 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/protocol_sink_wrap.cc59
-rw-r--r--chrome_frame/protocol_sink_wrap.h2
-rw-r--r--chrome_frame/test/chrome_frame_unittests.cc19
-rw-r--r--chrome_frame/test/data/chrome_frame_tester_helpers.js13
-rw-r--r--chrome_frame/test/data/full_tab_sub_frame1.html26
-rw-r--r--chrome_frame/test/data/full_tab_sub_frame2.html21
-rw-r--r--chrome_frame/test/data/full_tab_sub_frame_main.html6
-rw-r--r--chrome_frame/test/data/full_tab_sub_iframe_main.html30
8 files changed, 147 insertions, 29 deletions
diff --git a/chrome_frame/protocol_sink_wrap.cc b/chrome_frame/protocol_sink_wrap.cc
index 287cd36..9888209 100644
--- a/chrome_frame/protocol_sink_wrap.cc
+++ b/chrome_frame/protocol_sink_wrap.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <htiframe.h>
+#include <mshtml.h>
#include "chrome_frame/protocol_sink_wrap.h"
@@ -609,31 +610,51 @@ scoped_refptr<ProtocolSinkWrap> ProtocolSinkWrap::InstanceFromProtocol(
return instance;
}
-HRESULT ProtocolSinkWrap::WebBrowserFromProtocolSink(
- IInternetProtocolSink* sink, IWebBrowser2** web_browser) {
- // TODO(tommi): GUID_NULL doesn't work when loading from history.
- // asking for IID_IHttpNegotiate as the service id works, but
- // getting the IWebBrowser2 interface still doesn't work.
- ScopedComPtr<IHttpNegotiate> http_negotiate;
- HRESULT hr = DoQueryService(GUID_NULL, sink, http_negotiate.Receive());
- if (http_negotiate)
- hr = DoQueryService(IID_ITargetFrame2, http_negotiate, web_browser);
-
- return hr;
-}
-
ScopedComPtr<IInternetProtocolSink> ProtocolSinkWrap::MaybeWrapSink(
IInternetProtocol* protocol, IInternetProtocolSink* prot_sink,
const wchar_t* url) {
ScopedComPtr<IInternetProtocolSink> sink_to_use(prot_sink);
ScopedComPtr<IWebBrowser2> web_browser;
- WebBrowserFromProtocolSink(prot_sink, web_browser.Receive());
+
+ // FYI: GUID_NULL doesn't work when the URL is being loaded from history.
+ // asking for IID_IHttpNegotiate as the service id works, but
+ // getting the IWebBrowser2 interface still doesn't work.
+ ScopedComPtr<IHttpNegotiate> http_negotiate;
+ HRESULT hr = DoQueryService(GUID_NULL, prot_sink, http_negotiate.Receive());
+ if (http_negotiate) {
+ hr = DoQueryService(IID_ITargetFrame2, http_negotiate,
+ web_browser.Receive());
+ }
+
if (web_browser) {
- CComObject<ProtocolSinkWrap>* wrap = NULL;
- CComObject<ProtocolSinkWrap>::CreateInstance(&wrap);
- DCHECK(wrap);
- if (wrap->Initialize(protocol, prot_sink, url)) {
- sink_to_use = wrap;
+ // Do one more check to make sure we don't wrap requests that are
+ // targeted to sub frames.
+ // For a use case, see FullTabModeIE_SubIFrame and FullTabModeIE_SubFrame
+ // unit tests.
+
+ // Default should_wrap to true in case no window is available.
+ // In that case this request is a top level request.
+ bool should_wrap = true;
+
+ ScopedComPtr<IHTMLWindow2> current_frame, parent_frame;
+ hr = DoQueryService(IID_IHTMLWindow2, http_negotiate,
+ current_frame.Receive());
+ if (current_frame) {
+ // Only the top level window will return self when get_parent is called.
+ current_frame->get_parent(parent_frame.Receive());
+ if (parent_frame != current_frame) {
+ DLOG(INFO) << "Sub frame detected";
+ should_wrap = false;
+ }
+ }
+
+ if (should_wrap) {
+ CComObject<ProtocolSinkWrap>* wrap = NULL;
+ CComObject<ProtocolSinkWrap>::CreateInstance(&wrap);
+ DCHECK(wrap);
+ if (wrap->Initialize(protocol, prot_sink, url)) {
+ sink_to_use = wrap;
+ }
}
}
diff --git a/chrome_frame/protocol_sink_wrap.h b/chrome_frame/protocol_sink_wrap.h
index 4152be0..e8a7665 100644
--- a/chrome_frame/protocol_sink_wrap.h
+++ b/chrome_frame/protocol_sink_wrap.h
@@ -168,8 +168,6 @@ END_COM_MAP()
static scoped_refptr<ProtocolSinkWrap> InstanceFromProtocol(
IInternetProtocol* protocol);
- static HRESULT WebBrowserFromProtocolSink(IInternetProtocolSink* sink,
- IWebBrowser2** web_browser);
static ScopedComPtr<IInternetProtocolSink> MaybeWrapSink(
IInternetProtocol* protocol, IInternetProtocolSink* prot_sink,
const wchar_t* url);
diff --git a/chrome_frame/test/chrome_frame_unittests.cc b/chrome_frame/test/chrome_frame_unittests.cc
index 3b3035f..0964796 100644
--- a/chrome_frame/test/chrome_frame_unittests.cc
+++ b/chrome_frame/test/chrome_frame_unittests.cc
@@ -1281,6 +1281,16 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_ReferrerTest) {
SimpleBrowserTest(IE, kReferrerMainTest, L"FullTab_ReferrerTest");
}
+const wchar_t kSubFrameTestPage[] = L"files/full_tab_sub_frame_main.html";
+TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_SubFrame) {
+ SimpleBrowserTest(IE, kSubFrameTestPage, L"sub_frame");
+}
+
+const wchar_t kSubIFrameTestPage[] = L"files/full_tab_sub_iframe_main.html";
+TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_SubIFrame) {
+ SimpleBrowserTest(IE, kSubIFrameTestPage, L"sub_frame");
+}
+
HRESULT LaunchIEAsComServer(IWebBrowser2** web_browser) {
if (!web_browser)
return E_INVALIDARG;
@@ -1340,7 +1350,7 @@ class MockWebBrowserEventSink : public WebBrowserEventSink {
}
MOCK_METHOD7_WITH_CALLTYPE(__stdcall, OnBeforeNavigate2,
- HRESULT (IDispatch* dispatch,
+ HRESULT (IDispatch* dispatch, // NOLINT
VARIANT* url,
VARIANT* flags,
VARIANT* target_frame_name,
@@ -1349,17 +1359,18 @@ class MockWebBrowserEventSink : public WebBrowserEventSink {
VARIANT_BOOL* cancel));
MOCK_METHOD2_WITH_CALLTYPE(__stdcall, OnNavigateComplete2,
- void (IDispatch* dispatch, VARIANT* url));
+ void (IDispatch* dispatch, // NOLINT
+ VARIANT* url));
MOCK_METHOD5_WITH_CALLTYPE(__stdcall, OnNewWindow3,
- void (IDispatch** dispatch,
+ void (IDispatch** dispatch, // NOLINT
VARIANT_BOOL* Cancel,
DWORD flags,
BSTR url_context,
BSTR url));
MOCK_METHOD5_WITH_CALLTYPE(__stdcall, OnNavigateError,
- void (IDispatch* dispatch,
+ void (IDispatch* dispatch, // NOLINT
VARIANT* url,
VARIANT* frame_name,
VARIANT* status_code,
diff --git a/chrome_frame/test/data/chrome_frame_tester_helpers.js b/chrome_frame/test/data/chrome_frame_tester_helpers.js
index 67df52a..e18ab87 100644
--- a/chrome_frame/test/data/chrome_frame_tester_helpers.js
+++ b/chrome_frame/test/data/chrome_frame_tester_helpers.js
@@ -17,10 +17,10 @@ function getXHRObject(){
http = new XMLHttpRequest();
} catch(e) {
}
-
+
if (http)
return http;
-
+
for (var i = 0; i < 3; ++i) {
var progid = XMLHTTP_PROGIDS[i];
try {
@@ -140,11 +140,16 @@ function reloadUsingCFProtocol() {
window.location = redirect_location;
}
-function TestIfRunningInChrome() {
+function isRunningInChrome() {
var is_chrome = /chrome/.test(navigator.userAgent.toLowerCase());
+ return is_chrome;
+}
+
+function TestIfRunningInChrome() {
+ var is_chrome = isRunningInChrome();
if (!is_chrome) {
onFailure("ChromeFrameWindowOpen", "Window Open failed :-(",
- "User agent = " + navigator.userAgent.toLowerCase());
+ "User agent = " + navigator.userAgent.toLowerCase());
}
return is_chrome;
}
diff --git a/chrome_frame/test/data/full_tab_sub_frame1.html b/chrome_frame/test/data/full_tab_sub_frame1.html
new file mode 100644
index 0000000..7deb946
--- /dev/null
+++ b/chrome_frame/test/data/full_tab_sub_frame1.html
@@ -0,0 +1,26 @@
+<html>
+ <head>
+ <meta http-equiv="x-ua-compatible" content="chrome=1" />
+ <!-- the http-equiv tag should be ignored since we're in a sub frame -->
+ <title>ChromeFrame Sub Frame test</title>
+ <script type="text/javascript"
+ src="chrome_frame_tester_helpers.js"></script>
+
+ <script type="text/javascript">
+ function OnLoad() {
+ if (isRunningInChrome()) {
+ onFailure("sub_frame", 1, 'Failed');
+ } else {
+ onSuccess("sub_frame", 1);
+ }
+ }
+ </script>
+ </head>
+
+ <body onLoad="OnLoad();">
+ ChromeFrame full tab mode sub frame test. Verifies that frame pages are
+ not opened in CF even though they have the meta tag.<br>
+ This frame has the x-ua-compatible http-equiv tag, but should not be
+ loaded in CF since it's inside a frame.
+ </body>
+</html>
diff --git a/chrome_frame/test/data/full_tab_sub_frame2.html b/chrome_frame/test/data/full_tab_sub_frame2.html
new file mode 100644
index 0000000..a288f2f
--- /dev/null
+++ b/chrome_frame/test/data/full_tab_sub_frame2.html
@@ -0,0 +1,21 @@
+<html>
+ <head>
+ <!-- no meta tag here -->
+ <title>ChromeFrame Sub Frame test</title>
+ <script type="text/javascript"
+ src="chrome_frame_tester_helpers.js"></script>
+
+ <script type="text/javascript">
+ function OnLoad() {
+ if (isRunningInChrome()) {
+ onFailure("sub_frame", 1, "Failed");
+ }
+ }
+ </script>
+ </head>
+
+ <body onLoad="OnLoad();">
+ ChromeFrame full tab mode sub frame test.<br>
+ This is a regular frame (no meta tag).
+ </body>
+</html>
diff --git a/chrome_frame/test/data/full_tab_sub_frame_main.html b/chrome_frame/test/data/full_tab_sub_frame_main.html
new file mode 100644
index 0000000..6cf0102
--- /dev/null
+++ b/chrome_frame/test/data/full_tab_sub_frame_main.html
@@ -0,0 +1,6 @@
+<html>
+<frameset cols="50%,*">
+ <frame src="full_tab_sub_frame1.html" />
+ <frame src="full_tab_sub_frame2.html" />
+</frameset>
+</html> \ No newline at end of file
diff --git a/chrome_frame/test/data/full_tab_sub_iframe_main.html b/chrome_frame/test/data/full_tab_sub_iframe_main.html
new file mode 100644
index 0000000..20050db
--- /dev/null
+++ b/chrome_frame/test/data/full_tab_sub_iframe_main.html
@@ -0,0 +1,30 @@
+<html>
+ <head>
+ <title>ChromeFrame full tab IFRAME test main</title>
+ </head>
+<body>
+<table height="100%" width="100%">
+ <tr height="1%">
+ <td style="top:0;width:100%">
+ <table width="100%">
+ <tr>
+ <td>
+ Placeholder text.
+ <td align=right valign=bottom>
+ I slappa da bass!
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <iframe scrolling=auto src="full_tab_sub_frame1.html"
+ frameborder=1 allowtransparency=true
+ style="width:100%;height:100%">
+ </iframe>
+ </td>
+ </tr>
+</table>
+</body>
+</html>