| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // in the message loop to delete itself, which frees the Browser object | 159 // in the message loop to delete itself, which frees the Browser object |
| 160 // which fires this event. | 160 // which fires this event. |
| 161 AutoreleasePool()->Recycle(); | 161 AutoreleasePool()->Recycle(); |
| 162 #endif | 162 #endif |
| 163 | 163 |
| 164 signal.Wait(); | 164 signal.Wait(); |
| 165 EXPECT_FALSE(clipboard->IsFormatAvailable( | 165 EXPECT_FALSE(clipboard->IsFormatAvailable( |
| 166 ui::Clipboard::GetPlainTextFormatType(), ui::Clipboard::BUFFER_STANDARD)); | 166 ui::Clipboard::GetPlainTextFormatType(), ui::Clipboard::BUFFER_STANDARD)); |
| 167 } | 167 } |
| 168 | 168 |
| 169 // Verify that "Open Link in New Tab" doesn't send URL fragment as referrer. |
| 170 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, OpenInNewTabReferrer) { |
| 171 ui_test_utils::WindowedTabAddedNotificationObserver tab_observer( |
| 172 content::NotificationService::AllSources()); |
| 173 |
| 174 ASSERT_TRUE(test_server()->Start()); |
| 175 GURL echoheader(test_server()->GetURL("echoheader?Referer")); |
| 176 |
| 177 // Go to a |page| with a link to echoheader URL. |
| 178 GURL page("data:text/html,<a href='" + echoheader.spec() + "'>link</a>"); |
| 179 ui_test_utils::NavigateToURL(browser(), page); |
| 180 |
| 181 // Set up referrer URL with fragment. |
| 182 GURL referrer_with_fragment("http://foo.com/test#fragment"); |
| 183 std::string correct_referrer("http://foo.com/test"); |
| 184 |
| 185 // Copy link URL. |
| 186 content::ContextMenuParams context_menu_params; |
| 187 context_menu_params.page_url = referrer_with_fragment; |
| 188 context_menu_params.link_url = echoheader; |
| 189 |
| 190 // The menu_observer will select "Open Link in New Tab" and wait for |
| 191 // the new tab to be added. |
| 192 TestRenderViewContextMenu menu( |
| 193 browser()->tab_strip_model()->GetActiveWebContents(), |
| 194 context_menu_params); |
| 195 menu.Init(); |
| 196 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 0); |
| 197 |
| 198 tab_observer.Wait(); |
| 199 content::WebContents* tab = tab_observer.GetTab(); |
| 200 content::WaitForLoadStop(tab); |
| 201 |
| 202 // Verify that it's the correct tab. |
| 203 ASSERT_EQ(echoheader, tab->GetURL()); |
| 204 // Verify that the referrer on the page matches |correct_referrer|. |
| 205 std::string actual_referrer; |
| 206 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 207 tab, |
| 208 "window.domAutomationController.send(window.document.body.textContent);", |
| 209 &actual_referrer)); |
| 210 ASSERT_EQ(correct_referrer, actual_referrer); |
| 211 |
| 212 } |
| 213 |
| 169 } // namespace | 214 } // namespace |
| OLD | NEW |