| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/strings/string_number_conversions.h" | 6 #include "base/strings/string_number_conversions.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 10 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 11 #include "chrome/browser/tab_contents/render_view_context_menu_browsertest_util.
h" | 11 #include "chrome/browser/tab_contents/render_view_context_menu_browsertest_util.
h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_commands.h" | 13 #include "chrome/browser/ui/browser_commands.h" |
| 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 15 #include "chrome/test/base/in_process_browser_test.h" | 15 #include "chrome/test/base/in_process_browser_test.h" |
| 16 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
| 17 #include "content/public/browser/navigation_controller.h" |
| 18 #include "content/public/browser/navigation_entry.h" |
| 17 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
| 18 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
| 19 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/test/browser_test_utils.h" | 22 #include "content/public/test/browser_test_utils.h" |
| 21 #include "net/test/spawned_test_server/spawned_test_server.h" | 23 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 22 #include "third_party/WebKit/public/web/WebInputEvent.h" | 24 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 23 | 25 |
| 24 // GTK requires a X11-level mouse event to open a context menu correctly. | 26 // GTK requires a X11-level mouse event to open a context menu correctly. |
| 25 #if defined(TOOLKIT_GTK) | 27 #if defined(TOOLKIT_GTK) |
| 26 #define MAYBE_ContextMenuOrigin DISABLED_ContextMenuOrigin | 28 #define MAYBE_ContextMenuOrigin DISABLED_ContextMenuOrigin |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 void AddAllPossibleTitles(const GURL& url, | 94 void AddAllPossibleTitles(const GURL& url, |
| 93 content::TitleWatcher* title_watcher) { | 95 content::TitleWatcher* title_watcher) { |
| 94 title_watcher->AlsoWaitForTitle( | 96 title_watcher->AlsoWaitForTitle( |
| 95 GetExpectedTitle(url, EXPECT_EMPTY_REFERRER)); | 97 GetExpectedTitle(url, EXPECT_EMPTY_REFERRER)); |
| 96 title_watcher->AlsoWaitForTitle( | 98 title_watcher->AlsoWaitForTitle( |
| 97 GetExpectedTitle(url, EXPECT_FULL_REFERRER)); | 99 GetExpectedTitle(url, EXPECT_FULL_REFERRER)); |
| 98 title_watcher->AlsoWaitForTitle( | 100 title_watcher->AlsoWaitForTitle( |
| 99 GetExpectedTitle(url, EXPECT_ORIGIN_AS_REFERRER)); | 101 GetExpectedTitle(url, EXPECT_ORIGIN_AS_REFERRER)); |
| 100 } | 102 } |
| 101 | 103 |
| 104 // Returns a string representation of a given |referrer_policy|. |
| 105 std::string ReferrerPolicyToString(blink::WebReferrerPolicy referrer_policy) { |
| 106 switch (referrer_policy) { |
| 107 case blink::WebReferrerPolicyDefault: |
| 108 return "default"; |
| 109 case blink::WebReferrerPolicyOrigin: |
| 110 return "origin"; |
| 111 case blink::WebReferrerPolicyAlways: |
| 112 return "always"; |
| 113 case blink::WebReferrerPolicyNever: |
| 114 return "never"; |
| 115 default: |
| 116 NOTREACHED(); |
| 117 return ""; |
| 118 } |
| 119 } |
| 120 |
| 102 // Navigates from a page with a given |referrer_policy| and checks that the | 121 // Navigates from a page with a given |referrer_policy| and checks that the |
| 103 // reported referrer matches the expectation. | 122 // reported referrer matches the expectation. |
| 104 // Parameters: | 123 // Parameters: |
| 105 // referrer_policy: The referrer policy to test ("default", "always", | 124 // referrer_policy: The referrer policy to test. |
| 106 // "origin", "never") | |
| 107 // start_on_https: True if the test should start on an HTTPS page. | 125 // start_on_https: True if the test should start on an HTTPS page. |
| 108 // target_blank: True if the link that is generated should have the | 126 // target_blank: True if the link that is generated should have the |
| 109 // attribute target=_blank | 127 // attribute target=_blank |
| 110 // redirect: True if the link target should first do a server | 128 // redirect: True if the link target should first do a server |
| 111 // redirect before evaluating the passed referrer. | 129 // redirect before evaluating the passed referrer. |
| 112 // opens_new_tab: True if this test opens a new tab. | 130 // opens_new_tab: True if this test opens a new tab. |
| 113 // button: If not WebMouseEvent::ButtonNone, click on the | 131 // button: If not WebMouseEvent::ButtonNone, click on the |
| 114 // link with the specified mouse button. | 132 // link with the specified mouse button. |
| 115 // expected_referrer: The kind of referrer to expect. | 133 // expected_referrer: The kind of referrer to expect. |
| 116 // | 134 // |
| 117 // Returns: | 135 // Returns: |
| 118 // The URL of the first page navigated to. | 136 // The URL of the first page navigated to. |
| 119 GURL RunReferrerTest(const std::string referrer_policy, | 137 GURL RunReferrerTest(const blink::WebReferrerPolicy referrer_policy, |
| 120 bool start_on_https, | 138 bool start_on_https, |
| 121 bool target_blank, | 139 bool target_blank, |
| 122 bool redirect, | 140 bool redirect, |
| 123 bool opens_new_tab, | 141 bool opens_new_tab, |
| 124 blink::WebMouseEvent::Button button, | 142 blink::WebMouseEvent::Button button, |
| 125 ExpectedReferrer expected_referrer) { | 143 ExpectedReferrer expected_referrer) { |
| 126 GURL start_url; | 144 GURL start_url; |
| 127 net::SpawnedTestServer* start_server = | 145 net::SpawnedTestServer* start_server = |
| 128 start_on_https ? ssl_test_server_.get() : test_server_.get(); | 146 start_on_https ? ssl_test_server_.get() : test_server_.get(); |
| 129 start_url = start_server->GetURL( | 147 start_url = start_server->GetURL( |
| 130 std::string("files/referrer-policy-start.html?") + | 148 std::string("files/referrer-policy-start.html?") + |
| 131 "policy=" + referrer_policy + | 149 "policy=" + ReferrerPolicyToString(referrer_policy) + |
| 132 "&port=" + base::IntToString(test_server_->host_port_pair().port()) + | 150 "&port=" + base::IntToString(test_server_->host_port_pair().port()) + |
| 133 "&ssl_port=" + | 151 "&ssl_port=" + |
| 134 base::IntToString(ssl_test_server_->host_port_pair().port()) + | 152 base::IntToString(ssl_test_server_->host_port_pair().port()) + |
| 135 "&redirect=" + (redirect ? "true" : "false") + | 153 "&redirect=" + (redirect ? "true" : "false") + |
| 136 "&link=" + | 154 "&link=" + |
| 137 (button == blink::WebMouseEvent::ButtonNone ? "false" : "true") + | 155 (button == blink::WebMouseEvent::ButtonNone ? "false" : "true") + |
| 138 "&target=" + (target_blank ? "_blank" : "")); | 156 "&target=" + (target_blank ? "_blank" : "")); |
| 139 | 157 |
| 140 ui_test_utils::WindowedTabAddedNotificationObserver tab_added_observer( | 158 ui_test_utils::WindowedTabAddedNotificationObserver tab_added_observer( |
| 141 content::NotificationService::AllSources()); | 159 content::NotificationService::AllSources()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 166 if (opens_new_tab) { | 184 if (opens_new_tab) { |
| 167 tab_added_observer.Wait(); | 185 tab_added_observer.Wait(); |
| 168 tab = tab_added_observer.GetTab(); | 186 tab = tab_added_observer.GetTab(); |
| 169 EXPECT_TRUE(tab); | 187 EXPECT_TRUE(tab); |
| 170 content::WaitForLoadStop(tab); | 188 content::WaitForLoadStop(tab); |
| 171 EXPECT_EQ(expected_title, tab->GetTitle()); | 189 EXPECT_EQ(expected_title, tab->GetTitle()); |
| 172 } else { | 190 } else { |
| 173 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 191 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
| 174 } | 192 } |
| 175 | 193 |
| 194 EXPECT_EQ(referrer_policy, |
| 195 tab->GetController().GetActiveEntry()->GetReferrer().policy); |
| 196 |
| 176 return start_url; | 197 return start_url; |
| 177 } | 198 } |
| 178 | 199 |
| 179 scoped_ptr<net::SpawnedTestServer> test_server_; | 200 scoped_ptr<net::SpawnedTestServer> test_server_; |
| 180 scoped_ptr<net::SpawnedTestServer> ssl_test_server_; | 201 scoped_ptr<net::SpawnedTestServer> ssl_test_server_; |
| 181 }; | 202 }; |
| 182 | 203 |
| 183 // The basic behavior of referrer policies is covered by layout tests in | 204 // The basic behavior of referrer policies is covered by layout tests in |
| 184 // http/tests/security/referrer-policy-*. These tests cover (hopefully) all | 205 // http/tests/security/referrer-policy-*. These tests cover (hopefully) all |
| 185 // code paths chrome uses to navigate. To keep the number of combinations down, | 206 // code paths chrome uses to navigate. To keep the number of combinations down, |
| 186 // we only test the "origin" policy here. | 207 // we only test the "origin" policy here. |
| 187 // | 208 // |
| 188 // Some tests are marked as FAILS, see http://crbug.com/124750 | 209 // Some tests are marked as FAILS, see http://crbug.com/124750 |
| 189 | 210 |
| 190 // Content initiated navigation, from HTTP to HTTP. | 211 // Content initiated navigation, from HTTP to HTTP. |
| 191 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Origin) { | 212 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Origin) { |
| 192 RunReferrerTest("origin", false, false, false, false, | 213 RunReferrerTest(blink::WebReferrerPolicyOrigin, false, false, false, false, |
| 193 blink::WebMouseEvent::ButtonNone, | 214 blink::WebMouseEvent::ButtonNone, |
| 194 EXPECT_ORIGIN_AS_REFERRER); | 215 EXPECT_ORIGIN_AS_REFERRER); |
| 195 } | 216 } |
| 196 | 217 |
| 197 // Content initiated navigation, from HTTPS to HTTP. | 218 // Content initiated navigation, from HTTPS to HTTP. |
| 198 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsDefault) { | 219 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsDefault) { |
| 199 RunReferrerTest("origin", true, false, false, false, | 220 RunReferrerTest(blink::WebReferrerPolicyOrigin, true, false, false, false, |
| 200 blink::WebMouseEvent::ButtonNone, | 221 blink::WebMouseEvent::ButtonNone, |
| 201 EXPECT_ORIGIN_AS_REFERRER); | 222 EXPECT_ORIGIN_AS_REFERRER); |
| 202 } | 223 } |
| 203 | 224 |
| 204 // User initiated navigation, from HTTP to HTTP. | 225 // User initiated navigation, from HTTP to HTTP. |
| 205 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, LeftClickOrigin) { | 226 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, LeftClickOrigin) { |
| 206 RunReferrerTest("origin", false, false, false, false, | 227 RunReferrerTest(blink::WebReferrerPolicyOrigin, false, false, false, false, |
| 207 blink::WebMouseEvent::ButtonLeft, | 228 blink::WebMouseEvent::ButtonLeft, |
| 208 EXPECT_ORIGIN_AS_REFERRER); | 229 EXPECT_ORIGIN_AS_REFERRER); |
| 209 } | 230 } |
| 210 | 231 |
| 211 // User initiated navigation, from HTTPS to HTTP. | 232 // User initiated navigation, from HTTPS to HTTP. |
| 212 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsLeftClickOrigin) { | 233 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsLeftClickOrigin) { |
| 213 RunReferrerTest("origin", true, false, false, false, | 234 RunReferrerTest(blink::WebReferrerPolicyOrigin, true, false, false, false, |
| 214 blink::WebMouseEvent::ButtonLeft, | 235 blink::WebMouseEvent::ButtonLeft, |
| 215 EXPECT_ORIGIN_AS_REFERRER); | 236 EXPECT_ORIGIN_AS_REFERRER); |
| 216 } | 237 } |
| 217 | 238 |
| 218 // User initiated navigation, middle click, from HTTP to HTTP. | 239 // User initiated navigation, middle click, from HTTP to HTTP. |
| 219 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickOrigin) { | 240 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickOrigin) { |
| 220 RunReferrerTest("origin", false, false, false, true, | 241 RunReferrerTest(blink::WebReferrerPolicyOrigin, false, false, false, true, |
| 221 blink::WebMouseEvent::ButtonMiddle, | 242 blink::WebMouseEvent::ButtonMiddle, |
| 222 EXPECT_ORIGIN_AS_REFERRER); | 243 EXPECT_ORIGIN_AS_REFERRER); |
| 223 } | 244 } |
| 224 | 245 |
| 225 // User initiated navigation, middle click, from HTTPS to HTTP. | 246 // User initiated navigation, middle click, from HTTPS to HTTP. |
| 226 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickOrigin) { | 247 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickOrigin) { |
| 227 RunReferrerTest("origin", true, false, false, true, | 248 RunReferrerTest(blink::WebReferrerPolicyOrigin, true, false, false, true, |
| 228 blink::WebMouseEvent::ButtonMiddle, | 249 blink::WebMouseEvent::ButtonMiddle, |
| 229 EXPECT_ORIGIN_AS_REFERRER); | 250 EXPECT_ORIGIN_AS_REFERRER); |
| 230 } | 251 } |
| 231 | 252 |
| 232 // User initiated navigation, target blank, from HTTP to HTTP. | 253 // User initiated navigation, target blank, from HTTP to HTTP. |
| 233 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, TargetBlankOrigin) { | 254 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, TargetBlankOrigin) { |
| 234 RunReferrerTest("origin", false, true, false, true, | 255 RunReferrerTest(blink::WebReferrerPolicyOrigin, false, true, false, true, |
| 235 blink::WebMouseEvent::ButtonLeft, | 256 blink::WebMouseEvent::ButtonLeft, |
| 236 EXPECT_ORIGIN_AS_REFERRER); | 257 EXPECT_ORIGIN_AS_REFERRER); |
| 237 } | 258 } |
| 238 | 259 |
| 239 // User initiated navigation, target blank, from HTTPS to HTTP. | 260 // User initiated navigation, target blank, from HTTPS to HTTP. |
| 240 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsTargetBlankOrigin) { | 261 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsTargetBlankOrigin) { |
| 241 RunReferrerTest("origin", true, true, false, true, | 262 RunReferrerTest(blink::WebReferrerPolicyOrigin, true, true, false, true, |
| 242 blink::WebMouseEvent::ButtonLeft, | 263 blink::WebMouseEvent::ButtonLeft, |
| 243 EXPECT_ORIGIN_AS_REFERRER); | 264 EXPECT_ORIGIN_AS_REFERRER); |
| 244 } | 265 } |
| 245 | 266 |
| 246 // User initiated navigation, middle click, target blank, from HTTP to HTTP. | 267 // User initiated navigation, middle click, target blank, from HTTP to HTTP. |
| 247 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickTargetBlankOrigin) { | 268 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickTargetBlankOrigin) { |
| 248 RunReferrerTest("origin", false, true, false, true, | 269 RunReferrerTest(blink::WebReferrerPolicyOrigin, false, true, false, true, |
| 249 blink::WebMouseEvent::ButtonMiddle, | 270 blink::WebMouseEvent::ButtonMiddle, |
| 250 EXPECT_ORIGIN_AS_REFERRER); | 271 EXPECT_ORIGIN_AS_REFERRER); |
| 251 } | 272 } |
| 252 | 273 |
| 253 // User initiated navigation, middle click, target blank, from HTTPS to HTTP. | 274 // User initiated navigation, middle click, target blank, from HTTPS to HTTP. |
| 254 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickTargetBlankOrigin) { | 275 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickTargetBlankOrigin) { |
| 255 RunReferrerTest("origin", true, true, false, true, | 276 RunReferrerTest(blink::WebReferrerPolicyOrigin, true, true, false, true, |
| 256 blink::WebMouseEvent::ButtonMiddle, | 277 blink::WebMouseEvent::ButtonMiddle, |
| 257 EXPECT_ORIGIN_AS_REFERRER); | 278 EXPECT_ORIGIN_AS_REFERRER); |
| 258 } | 279 } |
| 259 | 280 |
| 260 // Context menu, from HTTP to HTTP. | 281 // Context menu, from HTTP to HTTP. |
| 261 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_ContextMenuOrigin) { | 282 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_ContextMenuOrigin) { |
| 262 ContextMenuNotificationObserver context_menu_observer( | 283 ContextMenuNotificationObserver context_menu_observer( |
| 263 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 284 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
| 264 RunReferrerTest("origin", false, false, false, true, | 285 RunReferrerTest(blink::WebReferrerPolicyOrigin, false, false, false, true, |
| 265 blink::WebMouseEvent::ButtonRight, | 286 blink::WebMouseEvent::ButtonRight, |
| 266 EXPECT_ORIGIN_AS_REFERRER); | 287 EXPECT_ORIGIN_AS_REFERRER); |
| 267 } | 288 } |
| 268 | 289 |
| 269 // Context menu, from HTTPS to HTTP. | 290 // Context menu, from HTTPS to HTTP. |
| 270 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_HttpsContextMenuOrigin) { | 291 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_HttpsContextMenuOrigin) { |
| 271 ContextMenuNotificationObserver context_menu_observer( | 292 ContextMenuNotificationObserver context_menu_observer( |
| 272 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 293 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
| 273 RunReferrerTest("origin", true, false, false, true, | 294 RunReferrerTest(blink::WebReferrerPolicyOrigin, true, false, false, true, |
| 274 blink::WebMouseEvent::ButtonRight, | 295 blink::WebMouseEvent::ButtonRight, |
| 275 EXPECT_ORIGIN_AS_REFERRER); | 296 EXPECT_ORIGIN_AS_REFERRER); |
| 276 } | 297 } |
| 277 | 298 |
| 278 // Content initiated navigation, from HTTP to HTTP via server redirect. | 299 // Content initiated navigation, from HTTP to HTTP via server redirect. |
| 279 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Redirect) { | 300 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Redirect) { |
| 280 RunReferrerTest("origin", false, false, true, false, | 301 RunReferrerTest(blink::WebReferrerPolicyOrigin, false, false, true, false, |
| 281 blink::WebMouseEvent::ButtonNone, | 302 blink::WebMouseEvent::ButtonNone, |
| 282 EXPECT_ORIGIN_AS_REFERRER); | 303 EXPECT_ORIGIN_AS_REFERRER); |
| 283 } | 304 } |
| 284 | 305 |
| 285 // Content initiated navigation, from HTTPS to HTTP via server redirect. | 306 // Content initiated navigation, from HTTPS to HTTP via server redirect. |
| 286 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsRedirect) { | 307 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsRedirect) { |
| 287 RunReferrerTest("origin", true, false, true, false, | 308 RunReferrerTest(blink::WebReferrerPolicyOrigin, true, false, true, false, |
| 288 blink::WebMouseEvent::ButtonNone, | 309 blink::WebMouseEvent::ButtonNone, |
| 289 EXPECT_ORIGIN_AS_REFERRER); | 310 EXPECT_ORIGIN_AS_REFERRER); |
| 290 } | 311 } |
| 291 | 312 |
| 292 // User initiated navigation, from HTTP to HTTP via server redirect. | 313 // User initiated navigation, from HTTP to HTTP via server redirect. |
| 293 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, LeftClickRedirect) { | 314 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, LeftClickRedirect) { |
| 294 RunReferrerTest("origin", false, false, true, false, | 315 RunReferrerTest(blink::WebReferrerPolicyOrigin, false, false, true, false, |
| 295 blink::WebMouseEvent::ButtonLeft, | 316 blink::WebMouseEvent::ButtonLeft, |
| 296 EXPECT_ORIGIN_AS_REFERRER); | 317 EXPECT_ORIGIN_AS_REFERRER); |
| 297 } | 318 } |
| 298 | 319 |
| 299 // User initiated navigation, from HTTPS to HTTP via server redirect. | 320 // User initiated navigation, from HTTPS to HTTP via server redirect. |
| 300 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsLeftClickRedirect) { | 321 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsLeftClickRedirect) { |
| 301 RunReferrerTest("origin", true, false, true, false, | 322 RunReferrerTest(blink::WebReferrerPolicyOrigin, true, false, true, false, |
| 302 blink::WebMouseEvent::ButtonLeft, | 323 blink::WebMouseEvent::ButtonLeft, |
| 303 EXPECT_ORIGIN_AS_REFERRER); | 324 EXPECT_ORIGIN_AS_REFERRER); |
| 304 } | 325 } |
| 305 | 326 |
| 306 // User initiated navigation, middle click, from HTTP to HTTP via server | 327 // User initiated navigation, middle click, from HTTP to HTTP via server |
| 307 // redirect. | 328 // redirect. |
| 308 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickRedirect) { | 329 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickRedirect) { |
| 309 RunReferrerTest("origin", false, false, true, true, | 330 RunReferrerTest(blink::WebReferrerPolicyOrigin, false, false, true, true, |
| 310 blink::WebMouseEvent::ButtonMiddle, | 331 blink::WebMouseEvent::ButtonMiddle, |
| 311 EXPECT_ORIGIN_AS_REFERRER); | 332 EXPECT_ORIGIN_AS_REFERRER); |
| 312 } | 333 } |
| 313 | 334 |
| 314 // User initiated navigation, middle click, from HTTPS to HTTP via server | 335 // User initiated navigation, middle click, from HTTPS to HTTP via server |
| 315 // redirect. | 336 // redirect. |
| 316 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickRedirect) { | 337 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickRedirect) { |
| 317 RunReferrerTest("origin", true, false, true, true, | 338 RunReferrerTest(blink::WebReferrerPolicyOrigin, true, false, true, true, |
| 318 blink::WebMouseEvent::ButtonMiddle, | 339 blink::WebMouseEvent::ButtonMiddle, |
| 319 EXPECT_ORIGIN_AS_REFERRER); | 340 EXPECT_ORIGIN_AS_REFERRER); |
| 320 } | 341 } |
| 321 | 342 |
| 322 // User initiated navigation, target blank, from HTTP to HTTP via server | 343 // User initiated navigation, target blank, from HTTP to HTTP via server |
| 323 // redirect. | 344 // redirect. |
| 324 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, TargetBlankRedirect) { | 345 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, TargetBlankRedirect) { |
| 325 RunReferrerTest("origin", false, true, true, true, | 346 RunReferrerTest(blink::WebReferrerPolicyOrigin, false, true, true, true, |
| 326 blink::WebMouseEvent::ButtonLeft, | 347 blink::WebMouseEvent::ButtonLeft, |
| 327 EXPECT_ORIGIN_AS_REFERRER); | 348 EXPECT_ORIGIN_AS_REFERRER); |
| 328 } | 349 } |
| 329 | 350 |
| 330 // User initiated navigation, target blank, from HTTPS to HTTP via server | 351 // User initiated navigation, target blank, from HTTPS to HTTP via server |
| 331 // redirect. | 352 // redirect. |
| 332 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsTargetBlankRedirect) { | 353 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsTargetBlankRedirect) { |
| 333 RunReferrerTest("origin", true, true, true, true, | 354 RunReferrerTest(blink::WebReferrerPolicyOrigin, true, true, true, true, |
| 334 blink::WebMouseEvent::ButtonLeft, | 355 blink::WebMouseEvent::ButtonLeft, |
| 335 EXPECT_ORIGIN_AS_REFERRER); | 356 EXPECT_ORIGIN_AS_REFERRER); |
| 336 } | 357 } |
| 337 | 358 |
| 338 // User initiated navigation, middle click, target blank, from HTTP to HTTP via | 359 // User initiated navigation, middle click, target blank, from HTTP to HTTP via |
| 339 // server redirect. | 360 // server redirect. |
| 340 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickTargetBlankRedirect) { | 361 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickTargetBlankRedirect) { |
| 341 RunReferrerTest("origin", false, true, true, true, | 362 RunReferrerTest(blink::WebReferrerPolicyOrigin, false, true, true, true, |
| 342 blink::WebMouseEvent::ButtonMiddle, | 363 blink::WebMouseEvent::ButtonMiddle, |
| 343 EXPECT_ORIGIN_AS_REFERRER); | 364 EXPECT_ORIGIN_AS_REFERRER); |
| 344 } | 365 } |
| 345 | 366 |
| 346 // User initiated navigation, middle click, target blank, from HTTPS to HTTP | 367 // User initiated navigation, middle click, target blank, from HTTPS to HTTP |
| 347 // via server redirect. | 368 // via server redirect. |
| 348 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, | 369 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, |
| 349 HttpsMiddleClickTargetBlankRedirect) { | 370 HttpsMiddleClickTargetBlankRedirect) { |
| 350 RunReferrerTest("origin", true, true, true, true, | 371 RunReferrerTest(blink::WebReferrerPolicyOrigin, true, true, true, true, |
| 351 blink::WebMouseEvent::ButtonMiddle, | 372 blink::WebMouseEvent::ButtonMiddle, |
| 352 EXPECT_ORIGIN_AS_REFERRER); | 373 EXPECT_ORIGIN_AS_REFERRER); |
| 353 } | 374 } |
| 354 | 375 |
| 355 // Context menu, from HTTP to HTTP via server redirect. | 376 // Context menu, from HTTP to HTTP via server redirect. |
| 356 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_ContextMenuRedirect) { | 377 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_ContextMenuRedirect) { |
| 357 ContextMenuNotificationObserver context_menu_observer( | 378 ContextMenuNotificationObserver context_menu_observer( |
| 358 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 379 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
| 359 RunReferrerTest("origin", false, false, true, true, | 380 RunReferrerTest(blink::WebReferrerPolicyOrigin, false, false, true, true, |
| 360 blink::WebMouseEvent::ButtonRight, | 381 blink::WebMouseEvent::ButtonRight, |
| 361 EXPECT_ORIGIN_AS_REFERRER); | 382 EXPECT_ORIGIN_AS_REFERRER); |
| 362 } | 383 } |
| 363 | 384 |
| 364 // Context menu, from HTTPS to HTTP via server redirect. | 385 // Context menu, from HTTPS to HTTP via server redirect. |
| 365 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_HttpsContextMenuRedirect) { | 386 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_HttpsContextMenuRedirect) { |
| 366 ContextMenuNotificationObserver context_menu_observer( | 387 ContextMenuNotificationObserver context_menu_observer( |
| 367 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 388 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
| 368 RunReferrerTest("origin", true, false, true, true, | 389 RunReferrerTest(blink::WebReferrerPolicyOrigin, true, false, true, true, |
| 369 blink::WebMouseEvent::ButtonRight, | 390 blink::WebMouseEvent::ButtonRight, |
| 370 EXPECT_ORIGIN_AS_REFERRER); | 391 EXPECT_ORIGIN_AS_REFERRER); |
| 371 } | 392 } |
| 372 | 393 |
| 373 // Tests history navigation actions: Navigate from A to B with a referrer | 394 // Tests history navigation actions: Navigate from A to B with a referrer |
| 374 // policy, then navigate to C, back to B, and reload. | 395 // policy, then navigate to C, back to B, and reload. |
| 375 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, History) { | 396 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, History) { |
| 376 // Navigate from A to B. | 397 // Navigate from A to B. |
| 377 GURL start_url = RunReferrerTest("origin", true, false, true, false, | 398 GURL start_url = RunReferrerTest(blink::WebReferrerPolicyOrigin, |
| 399 true, |
| 400 false, |
| 401 true, |
| 402 false, |
| 378 blink::WebMouseEvent::ButtonLeft, | 403 blink::WebMouseEvent::ButtonLeft, |
| 379 EXPECT_ORIGIN_AS_REFERRER); | 404 EXPECT_ORIGIN_AS_REFERRER); |
| 380 | 405 |
| 381 // Navigate to C. | 406 // Navigate to C. |
| 382 ui_test_utils::NavigateToURL(browser(), test_server_->GetURL(std::string())); | 407 ui_test_utils::NavigateToURL(browser(), test_server_->GetURL(std::string())); |
| 383 | 408 |
| 384 base::string16 expected_title = | 409 base::string16 expected_title = |
| 385 GetExpectedTitle(start_url, EXPECT_ORIGIN_AS_REFERRER); | 410 GetExpectedTitle(start_url, EXPECT_ORIGIN_AS_REFERRER); |
| 386 content::WebContents* tab = | 411 content::WebContents* tab = |
| 387 browser()->tab_strip_model()->GetActiveWebContents(); | 412 browser()->tab_strip_model()->GetActiveWebContents(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 402 chrome::Reload(browser(), CURRENT_TAB); | 427 chrome::Reload(browser(), CURRENT_TAB); |
| 403 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); | 428 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); |
| 404 | 429 |
| 405 title_watcher.reset(new content::TitleWatcher(tab, expected_title)); | 430 title_watcher.reset(new content::TitleWatcher(tab, expected_title)); |
| 406 AddAllPossibleTitles(start_url, title_watcher.get()); | 431 AddAllPossibleTitles(start_url, title_watcher.get()); |
| 407 | 432 |
| 408 // Shift-reload to B. | 433 // Shift-reload to B. |
| 409 chrome::ReloadIgnoringCache(browser(), CURRENT_TAB); | 434 chrome::ReloadIgnoringCache(browser(), CURRENT_TAB); |
| 410 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); | 435 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); |
| 411 } | 436 } |
| OLD | NEW |