Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(722)

Unified Diff: chrome/browser/tab_contents/render_view_context_menu_browsertest.cc

Issue 12569007: Remove URL fragment from referrer HTTP header when opening link using "Open Link in New Tab" option. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address pauljensen's review comments Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/tab_contents/render_view_context_menu_browsertest.cc
diff --git a/chrome/browser/tab_contents/render_view_context_menu_browsertest.cc b/chrome/browser/tab_contents/render_view_context_menu_browsertest.cc
index a3db8e8c27572fdc49f78e87fb71ebb5b75eb62e..52ecc3069d9447ee855430e0a53403114b99b9ca 100644
--- a/chrome/browser/tab_contents/render_view_context_menu_browsertest.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu_browsertest.cc
@@ -166,4 +166,47 @@ IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, CopyLinkFromIncognito) {
ui::Clipboard::GetPlainTextFormatType(), ui::Clipboard::BUFFER_STANDARD));
}
+// Verify that "Open Link in New Tab" doesn't send URL fragment as referrer.
+IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, OpenInNewTabReferrer) {
+ ui_test_utils::WindowedTabAddedNotificationObserver tab_observer(
+ content::NotificationService::AllSources());
+
+ ASSERT_TRUE(test_server()->Start());
+ GURL echoheader(test_server()->GetURL("echoheader?Referer"));
+
+ // Go to a |page| with a link to echoheader URL.
+ GURL page("data:text/html,<a href='" + echoheader.spec() + "'>link</a>");
+ ui_test_utils::NavigateToURL(browser(), page);
+
+ // Set up referrer URL with fragment.
+ GURL referrer_with_fragment("http://foo.com/test#fragment");
+ std::string correct_referrer("http://foo.com/test");
+
+ // Set up menu with link URL.
+ content::ContextMenuParams context_menu_params;
+ context_menu_params.page_url = referrer_with_fragment;
+ context_menu_params.link_url = echoheader;
+
+ // Select "Open Link in New Tab" and wait for the new tab to be added.
+ TestRenderViewContextMenu menu(
+ browser()->tab_strip_model()->GetActiveWebContents(),
+ context_menu_params);
+ menu.Init();
+ menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 0);
+
+ tab_observer.Wait();
+ content::WebContents* tab = tab_observer.GetTab();
+ content::WaitForLoadStop(tab);
+
+ // Verify that it's the correct tab.
+ ASSERT_EQ(echoheader, tab->GetURL());
+ // Verify that the text on the page matches |correct_referrer|.
+ std::string actual_referrer;
+ ASSERT_TRUE(content::ExecuteScriptAndExtractString(
+ tab,
+ "window.domAutomationController.send(window.document.body.textContent);",
+ &actual_referrer));
+ ASSERT_EQ(correct_referrer, actual_referrer);
mmenke 2013/03/19 19:01:09 We should check "document.referrer" just like we d
mef 2013/03/19 21:40:29 Right. We've discussed this with Paul. We are tryi
+}
+
} // namespace

Powered by Google App Engine
This is Rietveld 408576698