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

Side by Side 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, add UMA_HISTOGRAM 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 GURL page("data:text/html,<a href='" + echoheader.spec() + "'>link</a>");
177
178 // Go to a page with a link to echoheader URL.
pauljensen 2013/03/15 21:50:00 Can you move the definition of |page| down here?
mef 2013/03/18 16:42:07 Done.
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"
pauljensen 2013/03/15 21:50:00 Can you move more words onto this line to bring it
mef 2013/03/18 16:42:07 Done.
191 // and wait for 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.referrer);",
pauljensen 2013/03/15 21:50:00 Can we add another ASSERT_TRUE(ExecuteScriptAndExt
pauljensen 2013/03/18 20:16:19 I didn't see a response to this comment but it loo
209 &actual_referrer));
210 ASSERT_EQ(correct_referrer, actual_referrer);
211 }
212
169 } // namespace 213 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698