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

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 code 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..004ef8588e0d07a6081067c309ccfeea1b81ca73 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,49 @@ 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_url(test_server()->GetURL("echoheader?Referer"));
+
+ // Go to a page with a link to echoheader URL.
+ ui_test_utils::NavigateToURL(
+ browser(), GURL("data:text/html,<a href='" + echoheader_url.spec()
+ + "'>link</a>"));
pauljensen 2013/03/15 13:37:45 I think this should be indented like so: ui_test_
mef 2013/03/15 16:36:42 Done.
+
+ // Set up referrer URL with fragment.
+ GURL referrer_with_fragment("http://foo.com/test#fragment");
+ GURL correct_referrer("http://foo.com/test");
pauljensen 2013/03/15 13:37:45 I think correct_referrer should just be a std::str
mef 2013/03/15 16:36:42 Done.
+
+ // Copy link URL.
+ content::ContextMenuParams context_menu_params;
+ context_menu_params.page_url = GURL(referrer_with_fragment);
+ context_menu_params.link_url = GURL(echoheader_url);
pauljensen 2013/03/15 13:37:45 Can we change "GURL(blah)" to just "blah" on these
+
+ // The menu_observer will select "Open in new tab", wait for the new tab to
pauljensen 2013/03/15 13:37:45 You say "Open in new tab" here but "Open Link in N
mef 2013/03/15 16:36:42 Done.
+ // 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_url, tab->GetURL());
+ // Verify that the data on the page matches |correct_referrer|.
+ std::string actual_referrer;
+ ASSERT_TRUE(content::ExecuteScriptAndExtractString(
+ tab,
+ "window.domAutomationController.send(window.document.referrer);",
pauljensen 2013/03/15 13:37:45 This is sending back the referrer? The comment sa
mef 2013/03/15 16:36:42 Done.
+ &actual_referrer));
+ ASSERT_EQ(correct_referrer.spec(), actual_referrer);
+}
+
} // namespace

Powered by Google App Engine
This is Rietveld 408576698