Chromium Code Reviews| 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 // Set up menu with 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 // Select "Open Link in New Tab" and wait for the new tab to be added. | |
| 191 TestRenderViewContextMenu menu( | |
| 192 browser()->tab_strip_model()->GetActiveWebContents(), | |
| 193 context_menu_params); | |
| 194 menu.Init(); | |
| 195 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 0); | |
| 196 | |
| 197 tab_observer.Wait(); | |
| 198 content::WebContents* tab = tab_observer.GetTab(); | |
| 199 content::WaitForLoadStop(tab); | |
| 200 | |
| 201 // Verify that it's the correct tab. | |
| 202 ASSERT_EQ(echoheader, tab->GetURL()); | |
| 203 // Verify that the text on the page matches |correct_referrer|. | |
| 204 std::string actual_referrer; | |
| 205 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | |
| 206 tab, | |
| 207 "window.domAutomationController.send(window.document.body.textContent);", | |
| 208 &actual_referrer)); | |
| 209 ASSERT_EQ(correct_referrer, actual_referrer); | |
| 210 | |
|
pauljensen
2013/03/18 20:16:19
You added some whitespace; please remove.
mef
2013/03/18 20:59:16
Done.
| |
| 211 } | |
| 212 | |
| 169 } // namespace | 213 } // namespace |
| OLD | NEW |