| 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..deeebe3375e4e1b000c05387d9340bc3c9f59ea7 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(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");
|
| +
|
| + // Copy link URL.
|
| + content::ContextMenuParams context_menu_params;
|
| + context_menu_params.page_url = referrer_with_fragment;
|
| + context_menu_params.link_url = echoheader;
|
| +
|
| + // The menu_observer will 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 referrer 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);
|
| +
|
| +}
|
| +
|
| } // namespace
|
|
|