diff options
22 files changed, 182 insertions, 36 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index f45efdc..06a0ddf 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -1378,13 +1378,13 @@ void AutomationProvider::CloseBrowserAsync(int browser_handle) { } void AutomationProvider::NavigateInExternalTab( - int handle, const GURL& url, + int handle, const GURL& url, const GURL& referrer, AutomationMsg_NavigationResponseValues* status) { *status = AUTOMATION_MSG_NAVIGATION_ERROR; if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); - tab->LoadURL(url, GURL(), PageTransition::TYPED); + tab->LoadURL(url, referrer, PageTransition::TYPED); *status = AUTOMATION_MSG_NAVIGATION_SUCCESS; } } diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 4ebe00e..60bb2f8 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -303,7 +303,7 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, void OnSetPageFontSize(int tab_handle, int font_size); void NavigateInExternalTab( - int handle, const GURL& url, + int handle, const GURL& url, const GURL& referrer, AutomationMsg_NavigationResponseValues* status); void NavigateExternalTabAtIndex( int handle, int index, AutomationMsg_NavigationResponseValues* status); diff --git a/chrome/browser/extensions/extension_uitest.cc b/chrome/browser/extensions/extension_uitest.cc index 8518dad..5972f9e 100644 --- a/chrome/browser/extensions/extension_uitest.cc +++ b/chrome/browser/extensions/extension_uitest.cc @@ -71,7 +71,7 @@ class ExtensionUITest : public ParentTestType { // so that the test can control when it gets loaded, and so that we test // the intended behavior that tabs should be able to show extension pages // (useful for development etc.) - tab->NavigateInExternalTab(url); + tab->NavigateInExternalTab(url, GURL()); EXPECT_TRUE(proxy->WaitForMessage(action_max_timeout_ms())); proxy->DestroyHostWindow(); diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index bcd9dbe..4da768f 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -264,7 +264,8 @@ void ExternalTabContainer::OpenURLFromTab(TabContents* source, case SAVE_TO_DISK: if (automation_) { automation_->Send(new AutomationMsg_OpenURL(0, tab_handle_, - url, disposition)); + url, referrer, + disposition)); } break; default: diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 474229f..42302bf 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -1852,7 +1852,8 @@ WebNavigationPolicy RenderView::decidePolicyForNavigation( GURL frame_origin = GURL(frame->url()).GetOrigin(); if (url.GetOrigin() != frame_origin || url.ref().empty()) { last_top_level_navigation_page_id_ = page_id_; - OpenURL(url, GURL(), default_policy); + GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); + OpenURL(url, referrer, default_policy); return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. } } diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index c270ce4a..24261d4 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -433,9 +433,13 @@ IPC_BEGIN_MESSAGES(Automation) // This message notifies the AutomationProvider to navigate to a specified // url in the external tab with given handle. The first parameter is the // handle to the tab resource. The second parameter is the target url. + // The third parameter is the referrer. // The return value contains a status code which is nonnegative on success. // see AutomationMsg_NavigationResponseValues for the navigation response. - IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_NavigateInExternalTab, int, GURL, + IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_NavigateInExternalTab, + int, + GURL, + GURL, AutomationMsg_NavigationResponseValues) // This message is an outgoing message from Chrome to an external host. @@ -552,11 +556,12 @@ IPC_BEGIN_MESSAGES(Automation) // Request: // -int: Tab handle // -GURL: The URL to open + // -GURL: The referrer // -int: The WindowOpenDisposition that specifies where the URL should // be opened (new tab, new window etc). // Response: // None expected - IPC_MESSAGE_ROUTED3(AutomationMsg_OpenURL, int, GURL, int) + IPC_MESSAGE_ROUTED4(AutomationMsg_OpenURL, int, GURL, GURL, int) // This message requests the provider to wait until the specified tab has // finished restoring after session restore. diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index 333ce95..a8d29b0 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -888,7 +888,7 @@ TEST_F(ExternalTabTestType, CreateExternalTab2) { if (tab != NULL) { // Wait for navigation - tab->NavigateInExternalTab(simple_data_url); + tab->NavigateInExternalTab(simple_data_url, GURL()); EXPECT_TRUE(proxy->WaitForNavigation(action_max_timeout_ms())); // Now destroy the external tab diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index 76965e5..1852375 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -108,12 +108,13 @@ AutomationMsg_NavigationResponseValues TabProxy::NavigateToURLWithTimeout( } AutomationMsg_NavigationResponseValues TabProxy::NavigateInExternalTab( - const GURL& url) { + const GURL& url, const GURL& referrer) { if (!is_valid()) return AUTOMATION_MSG_NAVIGATION_ERROR; AutomationMsg_NavigationResponseValues rv = AUTOMATION_MSG_NAVIGATION_ERROR; - sender_->Send(new AutomationMsg_NavigateInExternalTab(0, handle_, url, &rv)); + sender_->Send(new AutomationMsg_NavigateInExternalTab(0, handle_, url, + referrer, &rv)); return rv; } diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h index b990d2e..1eaabea 100644 --- a/chrome/test/automation/tab_proxy.h +++ b/chrome/test/automation/tab_proxy.h @@ -108,7 +108,9 @@ class TabProxy : public AutomationResourceProxy { // This method accepts the same kinds of URL input that // can be passed to Chrome on the command line. This is a synchronous call and // hence blocks until the navigation completes. - AutomationMsg_NavigationResponseValues NavigateInExternalTab(const GURL& url); + AutomationMsg_NavigationResponseValues NavigateInExternalTab( + const GURL& url, const GURL& referrer); + AutomationMsg_NavigationResponseValues NavigateExternalTabAtIndex(int index); // Navigates to a url. This is an asynchronous version of NavigateToURL. diff --git a/chrome_frame/bho.cc b/chrome_frame/bho.cc index e83c8ba..f18cc3e 100644 --- a/chrome_frame/bho.cc +++ b/chrome_frame/bho.cc @@ -18,10 +18,14 @@ #include "chrome_frame/protocol_sink_wrap.h" #include "chrome_frame/utils.h" #include "chrome_frame/vtable_patch_manager.h" +#include "net/http/http_util.h" const wchar_t kPatchProtocols[] = L"PatchProtocols"; static const int kIBrowserServiceOnHttpEquivIndex = 30; +base::LazyInstance<base::ThreadLocalPointer<Bho> > + Bho::bho_current_thread_instance_(base::LINKER_INITIALIZED); + PatchHelper g_patch_helper; BEGIN_VTABLE_PATCHES(IBrowserService) @@ -64,6 +68,14 @@ STDMETHODIMP Bho::SetSite(IUnknown* site) { << " Site: " << site << " Error: " << hr; } } + // Save away our BHO instance in TLS which enables it to be referenced by + // our active document/activex instances to query referrer and other + // information for a URL. + AddRef(); + bho_current_thread_instance_.Pointer()->Set(this); + } else { + bho_current_thread_instance_.Pointer()->Set(NULL); + Release(); } return IObjectWithSiteImpl<Bho>::SetSite(site); @@ -113,6 +125,25 @@ STDMETHODIMP Bho::BeforeNavigate2(IDispatch* dispatch, VARIANT* url, } } } + + referrer_.clear(); + + // Save away the referrer in case our active document needs it to initiate + // navigation in chrome. + if (headers && V_VT(headers) == VT_BSTR && headers->bstrVal != NULL) { + std::string raw_headers_utf8 = WideToUTF8(headers->bstrVal); + std::string http_headers = + net::HttpUtil::AssembleRawHeaders(raw_headers_utf8.c_str(), + raw_headers_utf8.length()); + net::HttpUtil::HeadersIterator it(http_headers.begin(), http_headers.end(), + "\r\n"); + while (it.GetNext()) { + if (LowerCaseEqualsASCII(it.name(), "referer")) { + referrer_ = it.values(); + break; + } + } + } return S_OK; } @@ -211,6 +242,11 @@ HRESULT Bho::SwitchRenderer(IWebBrowser2* web_browser2, return S_OK; } +Bho* Bho::GetCurrentThreadBhoInstance() { + DCHECK(bho_current_thread_instance_.Pointer()->Get() != NULL); + return bho_current_thread_instance_.Pointer()->Get(); +} + void PatchHelper::InitializeAndPatchProtocolsIfNeeded() { if (state_ != UNKNOWN) return; diff --git a/chrome_frame/bho.h b/chrome_frame/bho.h index ea9fe43..b5b6ec5 100644 --- a/chrome_frame/bho.h +++ b/chrome_frame/bho.h @@ -14,6 +14,8 @@ #include <mshtml.h> #include <shdeprecated.h> +#include "base/lazy_instance.h" +#include "base/thread_local.h" #include "chrome_tab.h" // NOLINT #include "chrome_frame/resource.h" #include "grit/chrome_frame_resources.h" @@ -85,13 +87,24 @@ END_SINK_MAP() IBrowserService* browser, IShellView* shell_view, BOOL done, VARIANT* in_arg, VARIANT* out_arg); + std::string referrer() const { + return referrer_; + } + + // Returns the Bho instance for the current thread. This is returned from + // TLS. + static Bho* GetCurrentThreadBhoInstance(); + protected: bool PatchProtocolHandler(const CLSID& handler_clsid); static bool HasSubFrames(IWebBrowser2* web_browser2); static HRESULT SwitchRenderer(IWebBrowser2* web_browser2, IBrowserService* browser, IShellView* shell_view, const wchar_t* meta_tag); + std::string referrer_; + static base::LazyInstance<base::ThreadLocalPointer<Bho> > + bho_current_thread_instance_; static _ATL_FUNC_INFO kBeforeNavigate2Info; }; diff --git a/chrome_frame/chrome_active_document.cc b/chrome_frame/chrome_active_document.cc index 1f7515d..d0de8dd 100644 --- a/chrome_frame/chrome_active_document.cc +++ b/chrome_frame/chrome_active_document.cc @@ -33,6 +33,7 @@ #include "chrome/common/navigation_types.h" #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" +#include "chrome_frame/bho.h" #include "chrome_frame/utils.h" const wchar_t kChromeAttachExternalTabPrefix[] = L"attach_external_tab"; @@ -521,7 +522,7 @@ void ChromeActiveDocument::OnViewSource() { DCHECK(navigation_info_.url.is_valid()); std::string url_to_open = "view-source:"; url_to_open += navigation_info_.url.spec(); - OnOpenURL(0, GURL(url_to_open), NEW_WINDOW); + OnOpenURL(0, GURL(url_to_open), GURL(), NEW_WINDOW); } void ChromeActiveDocument::OnDetermineSecurityZone(const GUID* cmd_group_guid, @@ -535,7 +536,9 @@ void ChromeActiveDocument::OnDetermineSecurityZone(const GUID* cmd_group_guid, } } -void ChromeActiveDocument::OnOpenURL(int tab_handle, const GURL& url_to_open, +void ChromeActiveDocument::OnOpenURL(int tab_handle, + const GURL& url_to_open, + const GURL& referrer, int open_disposition) { // If the disposition indicates that we should be opening the URL in the // current tab, then we can reuse the ChromeFrameAutomationClient instance @@ -548,7 +551,7 @@ void ChromeActiveDocument::OnOpenURL(int tab_handle, const GURL& url_to_open, g_active_doc_cache.Set(this); } - Base::OnOpenURL(tab_handle, url_to_open, open_disposition); + Base::OnOpenURL(tab_handle, url_to_open, referrer, open_disposition); } void ChromeActiveDocument::OnLoad(int tab_handle, const GURL& url) { @@ -723,7 +726,16 @@ bool ChromeActiveDocument::LaunchUrl(const std::wstring& url, if (url_.Length()) { std::string utf8_url; WideToUTF8(url_, url_.Length(), &utf8_url); - if (!automation_client_->InitiateNavigation(utf8_url, is_privileged_)) { + + std::string referrer; + Bho* chrome_frame_bho = Bho::GetCurrentThreadBhoInstance(); + DCHECK(chrome_frame_bho != NULL); + if (chrome_frame_bho) { + referrer = chrome_frame_bho->referrer(); + } + if (!automation_client_->InitiateNavigation(utf8_url, + referrer, + is_privileged_)) { DLOG(ERROR) << "Invalid URL: " << url; Error(L"Invalid URL"); url_.Reset(); diff --git a/chrome_frame/chrome_active_document.h b/chrome_frame/chrome_active_document.h index 072bc00..fa6a271 100644 --- a/chrome_frame/chrome_active_document.h +++ b/chrome_frame/chrome_active_document.h @@ -215,7 +215,7 @@ END_EXEC_COMMAND_MAP() protected: // ChromeFrameActivexBase overrides virtual void OnOpenURL(int tab_handle, const GURL& url_to_open, - int open_disposition); + const GURL& referrer, int open_disposition); virtual void OnLoad(int tab_handle, const GURL& url); virtual void OnGoToHistoryEntryOffset(int tab_handle, int offset); diff --git a/chrome_frame/chrome_frame_activex_base.h b/chrome_frame/chrome_frame_activex_base.h index 70366d1..b8106aa 100644 --- a/chrome_frame/chrome_frame_activex_base.h +++ b/chrome_frame/chrome_frame_activex_base.h @@ -275,7 +275,7 @@ END_MSG_MAP() bool HandleContextMenuCommand(UINT cmd) { if (cmd == IDC_ABOUT_CHROME_FRAME) { int tab_handle = automation_client_->tab()->handle(); - OnOpenURL(tab_handle, GURL("about:version"), NEW_WINDOW); + OnOpenURL(tab_handle, GURL("about:version"), GURL(), NEW_WINDOW); return true; } @@ -307,7 +307,7 @@ END_MSG_MAP() } virtual void OnOpenURL(int tab_handle, const GURL& url_to_open, - int open_disposition) { + const GURL& referrer, int open_disposition) { ScopedComPtr<IWebBrowser2> web_browser2; DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive()); DCHECK(web_browser2); @@ -379,7 +379,17 @@ END_MSG_MAP() // } // End of MSHTML-like logic VARIANT empty = ScopedVariant::kEmptyVariant; - web_browser2->Navigate2(url.AsInput(), &flags, &empty, &empty, &empty); + ScopedVariant http_headers; + + if (referrer.is_valid()) { + std::wstring referrer_header = L"Referer: "; + referrer_header += UTF8ToWide(referrer.spec()); + referrer_header += L"\r\n\r\n"; + http_headers.Set(referrer_header.c_str()); + } + + web_browser2->Navigate2(url.AsInput(), &flags, &empty, &empty, + http_headers.AsInput()); web_browser2->put_Visible(VARIANT_TRUE); } @@ -442,7 +452,7 @@ END_MSG_MAP() std::string url; url = StringPrintf("cf:attach_external_tab&%d&%d", cookie, disposition); - OnOpenURL(tab_handle, GURL(url), disposition); + OnOpenURL(tab_handle, GURL(url), GURL(), disposition); } LRESULT OnCreate(UINT message, WPARAM wparam, LPARAM lparam, @@ -509,7 +519,9 @@ END_MSG_MAP() // We can initiate navigation here even if ready_state is not complete. // We do not have to set proxy, and AutomationClient will take care // of navigation just after CreateExternalTab is done. - if (!automation_client_->InitiateNavigation(full_url, is_privileged_)) { + if (!automation_client_->InitiateNavigation(full_url, + GetDocumentUrl(), + is_privileged_)) { // TODO(robertshield): Make InitiateNavigation return more useful // error information. return E_INVALIDARG; diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc index 104f2c3..7793f1a 100644 --- a/chrome_frame/chrome_frame_automation.cc +++ b/chrome_frame/chrome_frame_automation.cc @@ -483,8 +483,8 @@ void ChromeFrameAutomationClient::Uninitialize() { init_state_ = UNINITIALIZED; } -bool ChromeFrameAutomationClient::InitiateNavigation(const std::string& url, - bool is_privileged) { +bool ChromeFrameAutomationClient::InitiateNavigation( + const std::string& url, const std::string& referrer, bool is_privileged) { if (url.empty()) return false; @@ -498,7 +498,7 @@ bool ChromeFrameAutomationClient::InitiateNavigation(const std::string& url, } if (is_initialized()) { - BeginNavigate(GURL(url)); + BeginNavigate(GURL(url), GURL(referrer)); } return true; @@ -538,7 +538,8 @@ bool ChromeFrameAutomationClient::SetProxySettings( return true; } -void ChromeFrameAutomationClient::BeginNavigate(const GURL& url) { +void ChromeFrameAutomationClient::BeginNavigate(const GURL& url, + const GURL& referrer) { // Could be NULL if we failed to launch Chrome in LaunchAutomationServer() if (!automation_server_ || !tab_.get()) { DLOG(WARNING) << "BeginNavigate - can't navigate."; @@ -554,7 +555,8 @@ void ChromeFrameAutomationClient::BeginNavigate(const GURL& url) { } IPC::SyncMessage* msg = - new AutomationMsg_NavigateInExternalTab(0, tab_->handle(), url, NULL); + new AutomationMsg_NavigateInExternalTab(0, tab_->handle(), url, + referrer, NULL); automation_server_->SendAsAsync(msg, NewCallback(this, &ChromeFrameAutomationClient::BeginNavigateCompleted), this); diff --git a/chrome_frame/chrome_frame_automation.h b/chrome_frame/chrome_frame_automation.h index 0d647eb..31acc97 100644 --- a/chrome_frame/chrome_frame_automation.h +++ b/chrome_frame/chrome_frame_automation.h @@ -190,7 +190,9 @@ class ChromeFrameAutomationClient bool incognito); void Uninitialize(); - virtual bool InitiateNavigation(const std::string& url, bool is_privileged); + virtual bool InitiateNavigation(const std::string& url, + const std::string& referrer, + bool is_privileged); virtual bool NavigateToIndex(int index); bool ForwardMessageFromExternalHost(const std::string& message, const std::string& origin, @@ -308,7 +310,7 @@ class ChromeFrameAutomationClient void CallDelegateImpl(Task* delegate_task); HWND chrome_window() const { return chrome_window_; } - void BeginNavigate(const GURL& url); + void BeginNavigate(const GURL& url, const GURL& referrer); void BeginNavigateCompleted(AutomationMsg_NavigationResponseValues result); // Helpers diff --git a/chrome_frame/chrome_frame_delegate.h b/chrome_frame/chrome_frame_delegate.h index 2c8acd9..a886229 100644 --- a/chrome_frame/chrome_frame_delegate.h +++ b/chrome_frame/chrome_frame_delegate.h @@ -69,7 +69,7 @@ class ChromeFrameDelegateImpl : public ChromeFrameDelegate { virtual void OnAcceleratorPressed(int tab_handle, const MSG& accel_message) {} virtual void OnTabbedOut(int tab_handle, bool reverse) {} virtual void OnOpenURL(int tab_handle, const GURL& url, - int open_disposition) {} + const GURL& referrer, int open_disposition) {} virtual void OnDidNavigate(int tab_handle, const IPC::NavigationInfo& navigation_info) {} virtual void OnNavigationFailed(int tab_handle, int error_code, diff --git a/chrome_frame/chrome_frame_npapi.cc b/chrome_frame/chrome_frame_npapi.cc index f558fdd..e1c5548 100644 --- a/chrome_frame/chrome_frame_npapi.cc +++ b/chrome_frame/chrome_frame_npapi.cc @@ -1041,7 +1041,9 @@ void ChromeFrameNPAPI::OnAutomationServerReady() { } if (!src_.empty()) { - if (!automation_client_->InitiateNavigation(src_, is_privileged_)) { + if (!automation_client_->InitiateNavigation(src_, + GetDocumentUrl(), + is_privileged_)) { DLOG(ERROR) << "Failed to navigate to: " << src_; src_.clear(); } @@ -1309,7 +1311,9 @@ bool ChromeFrameNPAPI::NavigateToURL(const NPVariant* args, uint32_t arg_count, src_ = full_url; // Navigate only if we completed initialization i.e. proxy is set etc. if (ready_state_ == READYSTATE_COMPLETE) { - if (!automation_client_->InitiateNavigation(full_url, is_privileged_)) { + if (!automation_client_->InitiateNavigation(full_url, + GetDocumentUrl(), + is_privileged_)) { // TODO(tommi): call NPN_SetException. src_.clear(); return false; diff --git a/chrome_frame/test/chrome_frame_automation_mock.h b/chrome_frame/test/chrome_frame_automation_mock.h index 7678282..c77f41f 100644 --- a/chrome_frame/test/chrome_frame_automation_mock.h +++ b/chrome_frame/test/chrome_frame_automation_mock.h @@ -41,7 +41,7 @@ class AutomationMockDelegate // Navigate external tab to the specified url through automation bool Navigate(const std::string& url) { url_ = GURL(url); - return automation_client_->InitiateNavigation(url, false); + return automation_client_->InitiateNavigation(url, std::string(), false); } // Navigate the external to a 'file://' url for unit test files diff --git a/chrome_frame/test/chrome_frame_unittests.cc b/chrome_frame/test/chrome_frame_unittests.cc index ed8f71d..1675820 100644 --- a/chrome_frame/test/chrome_frame_unittests.cc +++ b/chrome_frame/test/chrome_frame_unittests.cc @@ -1101,7 +1101,7 @@ TEST(CFACWithChrome, NavigateOk) { EXPECT_CALL(cfd, OnAutomationServerReady()) .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( client.get(), &ChromeFrameAutomationClient::InitiateNavigation, - url, false)))); + url, std::string(), false)))); // cfd.SetOnNavigationStateChanged(); EXPECT_CALL(cfd, @@ -1141,7 +1141,7 @@ TEST(CFACWithChrome, DISABLED_NavigateFailed) { EXPECT_CALL(cfd, OnAutomationServerReady()) .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( client.get(), &ChromeFrameAutomationClient::InitiateNavigation, - url, false)))); + url, std::string(), false)))); EXPECT_CALL(cfd, OnNavigationStateChanged(testing::_, testing::_)) @@ -1199,7 +1199,7 @@ TEST(CFACWithChrome, UseHostNetworkStack) { EXPECT_CALL(cfd, OnAutomationServerReady()) .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( client.get(), &ChromeFrameAutomationClient::InitiateNavigation, - url, false)))); + url, std::string(), false)))); EXPECT_CALL(cfd, OnNavigationStateChanged(testing::_, testing::_)) .Times(testing::AnyNumber()); @@ -1436,6 +1436,11 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_NavigateOut) { SimpleBrowserTest(IE, kNavigateOutPage, L"navigate_out"); } +const wchar_t kReferrerMainTest[] = L"files/referrer_main.html"; +TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_ReferrerTest) { + SimpleBrowserTest(IE, kReferrerMainTest, L"FullTab_ReferrerTest"); +} + HRESULT LaunchIEAsComServer(IWebBrowser2** web_browser) { if (!web_browser) return E_INVALIDARG; diff --git a/chrome_frame/test/data/referrer_frame.html b/chrome_frame/test/data/referrer_frame.html new file mode 100644 index 0000000..c987a3f --- /dev/null +++ b/chrome_frame/test/data/referrer_frame.html @@ -0,0 +1,25 @@ +<html> + <head> + <meta http-equiv="x-ua-compatible" content="chrome=1" /> + <title>ChromeFrame referrer frame</title> + <script type="text/javascript" + src="chrome_frame_tester_helpers.js"></script> + + <script type="text/javascript"> + function onLoad() { + var referrer_search = /referrer_main.html/; + var referrer_pos = document.referrer.search(referrer_search); + + if (referrer_pos != -1) { + onSuccess("FullTab_ReferrerTest", 1); + } else { + onFailure("FullTab_ReferrerTest", 1, "Failed to find referrer"); + } + } + </script> + </head> + + <body onLoad="onLoad()"> + ChromeFrame full tab mode referrer test + </body> +</html> diff --git a/chrome_frame/test/data/referrer_main.html b/chrome_frame/test/data/referrer_main.html new file mode 100644 index 0000000..ef32143 --- /dev/null +++ b/chrome_frame/test/data/referrer_main.html @@ -0,0 +1,25 @@ +<html> + <head> + <meta http-equiv="x-ua-compatible" content="chrome=1" /> + <title>ChromeFrame referrer test main</title> + <script type="text/javascript" + src="chrome_frame_tester_helpers.js"></script> + + <a href="referrer_frame.html">self-link</a> + + <script type="text/javascript"> + function OpenReferrerFrame() { + if (isRunningInMSIE()) { + onFailure("FullTab_ReferrerTest", 1, "Failed"); + } else { + document.location.href = "referrer_frame.html"; + } + } + </script> + </head> + + <body onLoad="setTimeout(OpenReferrerFrame, 100);"> + ChromeFrame full tab mode referrer test. Verifies that the referrer header + is set correctly in navigations initiated by ChromeFrame. + </body> +</html> |