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 // Open link in new tab shouldn't send URL fragment as referrer | |
|
pauljensen
2013/03/14 18:53:44
Our comments are almost always complete sentances.
mef
2013/03/14 20:31:38
Done.
| |
| 170 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, OpenInNewTabReferrer) { | |
| 171 EXPECT_FALSE(browser()->profile()->IsOffTheRecord()); | |
|
pauljensen
2013/03/14 18:53:44
Why do we need a non-incognito window?
mef
2013/03/14 20:31:38
I guess we don't.
| |
| 172 ui_test_utils::WindowedTabAddedNotificationObserver tab_observer( | |
| 173 content::NotificationService::AllSources()); | |
| 174 | |
| 175 ASSERT_TRUE(test_server()->Start()); | |
| 176 GURL echoheader_url(test_server()->GetURL("echoheader?Referer")); | |
| 177 | |
| 178 // Go to a page with a link to echoheader url | |
|
pauljensen
2013/03/14 18:53:44
Capitalize URL and add period.
mef
2013/03/14 20:31:38
Done.
| |
| 179 ui_test_utils::NavigateToURL( | |
| 180 browser(), GURL("data:text/html,<a href='" + echoheader_url.spec() | |
| 181 + "'>link</a>")); | |
| 182 | |
| 183 // set up referrer url with fragment | |
|
pauljensen
2013/03/14 18:53:44
Capitalize "set" and URL and add period.
mef
2013/03/14 20:31:38
Done.
| |
| 184 GURL referrer_with_fragment_url("http://foo.com/test#fragment"); | |
|
pauljensen
2013/03/14 18:53:44
Do we need the "_url" suffix?
mef
2013/03/14 20:31:38
Done.
| |
| 185 GURL referrer_url("http://foo.com/test"); | |
|
pauljensen
2013/03/14 18:53:44
Can we name this more descriptively, like "correct
mef
2013/03/14 20:31:38
Done.
| |
| 186 | |
| 187 // Copy link URL. | |
| 188 content::ContextMenuParams context_menu_params; | |
| 189 context_menu_params.page_url = GURL(referrer_with_fragment_url); | |
| 190 context_menu_params.link_url = GURL(echoheader_url); | |
| 191 | |
| 192 // The menu_observer will select "Open in new tab", wait for the new tab to | |
| 193 // be added. | |
| 194 TestRenderViewContextMenu menu( | |
| 195 browser()->tab_strip_model()->GetActiveWebContents(), | |
| 196 context_menu_params); | |
| 197 menu.Init(); | |
| 198 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 0); | |
| 199 | |
| 200 tab_observer.Wait(); | |
| 201 content::WebContents* tab = tab_observer.GetTab(); | |
| 202 content::WaitForLoadStop(tab); | |
| 203 | |
| 204 // Verify that it's the correct tab. | |
| 205 EXPECT_EQ(echoheader_url, tab->GetURL()); | |
|
pauljensen
2013/03/14 18:53:44
Should this be ASSERT instead of EXPECT? I imagin
mef
2013/03/14 20:31:38
Done.
| |
| 206 // Verify that the data on the page matches referrer_url (without fragment) | |
|
pauljensen
2013/03/14 18:53:44
Add period. When mentioning variable names in com
mef
2013/03/14 20:31:38
Done.
| |
| 207 std::string actual; | |
| 208 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | |
| 209 tab, | |
| 210 "window.domAutomationController.send(window.document.referrer);", | |
| 211 &actual)); | |
| 212 EXPECT_EQ(referrer_url.spec(), actual); | |
| 213 } | |
| 214 | |
| 169 } // namespace | 215 } // namespace |
| OLD | NEW |