| 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/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 } | 128 } |
| 129 | 129 |
| 130 // Navigates from a page with a given |referrer_policy| and checks that the | 130 // Navigates from a page with a given |referrer_policy| and checks that the |
| 131 // reported referrer matches the expectation. | 131 // reported referrer matches the expectation. |
| 132 // Parameters: | 132 // Parameters: |
| 133 // referrer_policy: The referrer policy to test. | 133 // referrer_policy: The referrer policy to test. |
| 134 // start_protocol: The protocol the test should start on. | 134 // start_protocol: The protocol the test should start on. |
| 135 // link_type: The link type that is used to trigger the navigation. | 135 // link_type: The link type that is used to trigger the navigation. |
| 136 // redirect: Whether the link target should redirect and how. | 136 // redirect: Whether the link target should redirect and how. |
| 137 // disposition: The disposition for the navigation. | 137 // disposition: The disposition for the navigation. |
| 138 // button: If not WebMouseEvent::ButtonNone, click on the | 138 // button: If not WebMouseEvent::Button::NoButton, click on the |
| 139 // link with the specified mouse button. | 139 // link with the specified mouse button. |
| 140 // expected_referrer: The kind of referrer to expect. | 140 // expected_referrer: The kind of referrer to expect. |
| 141 // expected_referrer_policy: The expected referrer policy of the activity. | 141 // expected_referrer_policy: The expected referrer policy of the activity. |
| 142 // | 142 // |
| 143 // Returns: | 143 // Returns: |
| 144 // The URL of the first page navigated to. | 144 // The URL of the first page navigated to. |
| 145 GURL RunReferrerTest(const blink::WebReferrerPolicy referrer_policy, | 145 GURL RunReferrerTest(const blink::WebReferrerPolicy referrer_policy, |
| 146 StartOnProtocol start_protocol, | 146 StartOnProtocol start_protocol, |
| 147 LinkType link_type, | 147 LinkType link_type, |
| 148 RedirectType redirect, | 148 RedirectType redirect, |
| 149 WindowOpenDisposition disposition, | 149 WindowOpenDisposition disposition, |
| 150 blink::WebMouseEvent::Button button, | 150 blink::WebMouseEvent::Button button, |
| 151 ExpectedReferrer expected_referrer, | 151 ExpectedReferrer expected_referrer, |
| 152 blink::WebReferrerPolicy expected_referrer_policy) { | 152 blink::WebReferrerPolicy expected_referrer_policy) { |
| 153 std::string relative_url = | 153 std::string relative_url = |
| 154 std::string("referrer_policy/referrer-policy-start.html?") + "policy=" + | 154 std::string("referrer_policy/referrer-policy-start.html?") + "policy=" + |
| 155 ReferrerPolicyToString(referrer_policy) + "&redirect=" + | 155 ReferrerPolicyToString(referrer_policy) + "&redirect=" + |
| 156 RedirectTypeToString(redirect) + "&link=" + | 156 RedirectTypeToString(redirect) + "&link=" + |
| 157 (button == blink::WebMouseEvent::ButtonNone ? "false" : "true") + | 157 (button == blink::WebMouseEvent::Button::NoButton ? "false" : "true") + |
| 158 "&target=" + (link_type == LINK_WITH_TARGET_BLANK ? "_blank" : ""); | 158 "&target=" + (link_type == LINK_WITH_TARGET_BLANK ? "_blank" : ""); |
| 159 | 159 |
| 160 const GURL start_url = | 160 const GURL start_url = |
| 161 (start_protocol == START_ON_HTTPS) | 161 (start_protocol == START_ON_HTTPS) |
| 162 ? net::URLRequestMockHTTPJob::GetMockHttpsUrl(relative_url) | 162 ? net::URLRequestMockHTTPJob::GetMockHttpsUrl(relative_url) |
| 163 : net::URLRequestMockHTTPJob::GetMockUrl(relative_url); | 163 : net::URLRequestMockHTTPJob::GetMockUrl(relative_url); |
| 164 | 164 |
| 165 ui_test_utils::WindowedTabAddedNotificationObserver tab_added_observer( | 165 ui_test_utils::WindowedTabAddedNotificationObserver tab_added_observer( |
| 166 content::NotificationService::AllSources()); | 166 content::NotificationService::AllSources()); |
| 167 | 167 |
| 168 base::string16 expected_title = | 168 base::string16 expected_title = |
| 169 GetExpectedTitle(start_url, expected_referrer); | 169 GetExpectedTitle(start_url, expected_referrer); |
| 170 content::WebContents* tab = | 170 content::WebContents* tab = |
| 171 browser()->tab_strip_model()->GetActiveWebContents(); | 171 browser()->tab_strip_model()->GetActiveWebContents(); |
| 172 content::TitleWatcher title_watcher(tab, expected_title); | 172 content::TitleWatcher title_watcher(tab, expected_title); |
| 173 | 173 |
| 174 // Watch for all possible outcomes to avoid timeouts if something breaks. | 174 // Watch for all possible outcomes to avoid timeouts if something breaks. |
| 175 AddAllPossibleTitles(start_url, &title_watcher); | 175 AddAllPossibleTitles(start_url, &title_watcher); |
| 176 | 176 |
| 177 ui_test_utils::NavigateToURL(browser(), start_url); | 177 ui_test_utils::NavigateToURL(browser(), start_url); |
| 178 | 178 |
| 179 if (button != blink::WebMouseEvent::ButtonNone) { | 179 if (button != blink::WebMouseEvent::Button::NoButton) { |
| 180 blink::WebMouseEvent mouse_event; | 180 blink::WebMouseEvent mouse_event; |
| 181 mouse_event.type = blink::WebInputEvent::MouseDown; | 181 mouse_event.type = blink::WebInputEvent::MouseDown; |
| 182 mouse_event.button = button; | 182 mouse_event.button = button; |
| 183 mouse_event.x = 15; | 183 mouse_event.x = 15; |
| 184 mouse_event.y = 15; | 184 mouse_event.y = 15; |
| 185 mouse_event.clickCount = 1; | 185 mouse_event.clickCount = 1; |
| 186 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); | 186 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); |
| 187 mouse_event.type = blink::WebInputEvent::MouseUp; | 187 mouse_event.type = blink::WebInputEvent::MouseUp; |
| 188 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); | 188 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); |
| 189 } | 189 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 // | 237 // |
| 238 // Some tests are marked as FAILS, see http://crbug.com/124750 | 238 // Some tests are marked as FAILS, see http://crbug.com/124750 |
| 239 | 239 |
| 240 // Content initiated navigation, from HTTP to HTTP. | 240 // Content initiated navigation, from HTTP to HTTP. |
| 241 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Origin) { | 241 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Origin) { |
| 242 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 242 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
| 243 START_ON_HTTP, | 243 START_ON_HTTP, |
| 244 REGULAR_LINK, | 244 REGULAR_LINK, |
| 245 NO_REDIRECT, | 245 NO_REDIRECT, |
| 246 CURRENT_TAB, | 246 CURRENT_TAB, |
| 247 blink::WebMouseEvent::ButtonNone, | 247 blink::WebMouseEvent::Button::NoButton, |
| 248 EXPECT_ORIGIN_AS_REFERRER); | 248 EXPECT_ORIGIN_AS_REFERRER); |
| 249 } | 249 } |
| 250 | 250 |
| 251 // Content initiated navigation, from HTTPS to HTTP. | 251 // Content initiated navigation, from HTTPS to HTTP. |
| 252 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsDefault) { | 252 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsDefault) { |
| 253 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 253 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
| 254 START_ON_HTTPS, | 254 START_ON_HTTPS, |
| 255 REGULAR_LINK, | 255 REGULAR_LINK, |
| 256 NO_REDIRECT, | 256 NO_REDIRECT, |
| 257 CURRENT_TAB, | 257 CURRENT_TAB, |
| 258 blink::WebMouseEvent::ButtonNone, | 258 blink::WebMouseEvent::Button::NoButton, |
| 259 EXPECT_ORIGIN_AS_REFERRER); | 259 EXPECT_ORIGIN_AS_REFERRER); |
| 260 } | 260 } |
| 261 | 261 |
| 262 // User initiated navigation, from HTTP to HTTP. | 262 // User initiated navigation, from HTTP to HTTP. |
| 263 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, LeftClickOrigin) { | 263 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, LeftClickOrigin) { |
| 264 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 264 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
| 265 START_ON_HTTP, | 265 START_ON_HTTP, |
| 266 REGULAR_LINK, | 266 REGULAR_LINK, |
| 267 NO_REDIRECT, | 267 NO_REDIRECT, |
| 268 CURRENT_TAB, | 268 CURRENT_TAB, |
| 269 blink::WebMouseEvent::ButtonLeft, | 269 blink::WebMouseEvent::Button::Left, |
| 270 EXPECT_ORIGIN_AS_REFERRER); | 270 EXPECT_ORIGIN_AS_REFERRER); |
| 271 } | 271 } |
| 272 | 272 |
| 273 // User initiated navigation, from HTTPS to HTTP. | 273 // User initiated navigation, from HTTPS to HTTP. |
| 274 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsLeftClickOrigin) { | 274 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsLeftClickOrigin) { |
| 275 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 275 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
| 276 START_ON_HTTPS, | 276 START_ON_HTTPS, |
| 277 REGULAR_LINK, | 277 REGULAR_LINK, |
| 278 NO_REDIRECT, | 278 NO_REDIRECT, |
| 279 CURRENT_TAB, | 279 CURRENT_TAB, |
| 280 blink::WebMouseEvent::ButtonLeft, | 280 blink::WebMouseEvent::Button::Left, |
| 281 EXPECT_ORIGIN_AS_REFERRER); | 281 EXPECT_ORIGIN_AS_REFERRER); |
| 282 } | 282 } |
| 283 | 283 |
| 284 // User initiated navigation, middle click, from HTTP to HTTP. | 284 // User initiated navigation, middle click, from HTTP to HTTP. |
| 285 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickOrigin) { | 285 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickOrigin) { |
| 286 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 286 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
| 287 START_ON_HTTP, | 287 START_ON_HTTP, |
| 288 REGULAR_LINK, | 288 REGULAR_LINK, |
| 289 NO_REDIRECT, | 289 NO_REDIRECT, |
| 290 NEW_BACKGROUND_TAB, | 290 NEW_BACKGROUND_TAB, |
| 291 blink::WebMouseEvent::ButtonMiddle, | 291 blink::WebMouseEvent::Button::Middle, |
| 292 EXPECT_ORIGIN_AS_REFERRER); | 292 EXPECT_ORIGIN_AS_REFERRER); |
| 293 } | 293 } |
| 294 | 294 |
| 295 // User initiated navigation, middle click, from HTTPS to HTTP. | 295 // User initiated navigation, middle click, from HTTPS to HTTP. |
| 296 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickOrigin) { | 296 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickOrigin) { |
| 297 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 297 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
| 298 START_ON_HTTPS, | 298 START_ON_HTTPS, |
| 299 REGULAR_LINK, | 299 REGULAR_LINK, |
| 300 NO_REDIRECT, | 300 NO_REDIRECT, |
| 301 NEW_BACKGROUND_TAB, | 301 NEW_BACKGROUND_TAB, |
| 302 blink::WebMouseEvent::ButtonMiddle, | 302 blink::WebMouseEvent::Button::Middle, |
| 303 EXPECT_ORIGIN_AS_REFERRER); | 303 EXPECT_ORIGIN_AS_REFERRER); |
| 304 } | 304 } |
| 305 | 305 |
| 306 // User initiated navigation, target blank, from HTTP to HTTP. | 306 // User initiated navigation, target blank, from HTTP to HTTP. |
| 307 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, TargetBlankOrigin) { | 307 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, TargetBlankOrigin) { |
| 308 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 308 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
| 309 START_ON_HTTP, | 309 START_ON_HTTP, |
| 310 LINK_WITH_TARGET_BLANK, | 310 LINK_WITH_TARGET_BLANK, |
| 311 NO_REDIRECT, | 311 NO_REDIRECT, |
| 312 NEW_FOREGROUND_TAB, | 312 NEW_FOREGROUND_TAB, |
| 313 blink::WebMouseEvent::ButtonLeft, | 313 blink::WebMouseEvent::Button::Left, |
| 314 EXPECT_ORIGIN_AS_REFERRER); | 314 EXPECT_ORIGIN_AS_REFERRER); |
| 315 } | 315 } |
| 316 | 316 |
| 317 // User initiated navigation, target blank, from HTTPS to HTTP. | 317 // User initiated navigation, target blank, from HTTPS to HTTP. |
| 318 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsTargetBlankOrigin) { | 318 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsTargetBlankOrigin) { |
| 319 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 319 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
| 320 START_ON_HTTPS, | 320 START_ON_HTTPS, |
| 321 LINK_WITH_TARGET_BLANK, | 321 LINK_WITH_TARGET_BLANK, |
| 322 NO_REDIRECT, | 322 NO_REDIRECT, |
| 323 NEW_FOREGROUND_TAB, | 323 NEW_FOREGROUND_TAB, |
| 324 blink::WebMouseEvent::ButtonLeft, | 324 blink::WebMouseEvent::Button::Left, |
| 325 EXPECT_ORIGIN_AS_REFERRER); | 325 EXPECT_ORIGIN_AS_REFERRER); |
| 326 } | 326 } |
| 327 | 327 |
| 328 // User initiated navigation, middle click, target blank, from HTTP to HTTP. | 328 // User initiated navigation, middle click, target blank, from HTTP to HTTP. |
| 329 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickTargetBlankOrigin) { | 329 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickTargetBlankOrigin) { |
| 330 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 330 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
| 331 START_ON_HTTP, | 331 START_ON_HTTP, |
| 332 LINK_WITH_TARGET_BLANK, | 332 LINK_WITH_TARGET_BLANK, |
| 333 NO_REDIRECT, | 333 NO_REDIRECT, |
| 334 NEW_FOREGROUND_TAB, | 334 NEW_FOREGROUND_TAB, |
| 335 blink::WebMouseEvent::ButtonMiddle, | 335 blink::WebMouseEvent::Button::Middle, |
| 336 EXPECT_ORIGIN_AS_REFERRER); | 336 EXPECT_ORIGIN_AS_REFERRER); |
| 337 } | 337 } |
| 338 | 338 |
| 339 // User initiated navigation, middle click, target blank, from HTTPS to HTTP. | 339 // User initiated navigation, middle click, target blank, from HTTPS to HTTP. |
| 340 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickTargetBlankOrigin) { | 340 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickTargetBlankOrigin) { |
| 341 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 341 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
| 342 START_ON_HTTPS, | 342 START_ON_HTTPS, |
| 343 LINK_WITH_TARGET_BLANK, | 343 LINK_WITH_TARGET_BLANK, |
| 344 NO_REDIRECT, | 344 NO_REDIRECT, |
| 345 NEW_FOREGROUND_TAB, | 345 NEW_FOREGROUND_TAB, |
| 346 blink::WebMouseEvent::ButtonMiddle, | 346 blink::WebMouseEvent::Button::Middle, |
| 347 EXPECT_ORIGIN_AS_REFERRER); | 347 EXPECT_ORIGIN_AS_REFERRER); |
| 348 } | 348 } |
| 349 | 349 |
| 350 // Context menu, from HTTP to HTTP. | 350 // Context menu, from HTTP to HTTP. |
| 351 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, ContextMenuOrigin) { | 351 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, ContextMenuOrigin) { |
| 352 ContextMenuNotificationObserver context_menu_observer( | 352 ContextMenuNotificationObserver context_menu_observer( |
| 353 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 353 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
| 354 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 354 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
| 355 START_ON_HTTP, | 355 START_ON_HTTP, |
| 356 REGULAR_LINK, | 356 REGULAR_LINK, |
| 357 NO_REDIRECT, | 357 NO_REDIRECT, |
| 358 NEW_FOREGROUND_TAB, | 358 NEW_FOREGROUND_TAB, |
| 359 blink::WebMouseEvent::ButtonRight, | 359 blink::WebMouseEvent::Button::Right, |
| 360 EXPECT_ORIGIN_AS_REFERRER); | 360 EXPECT_ORIGIN_AS_REFERRER); |
| 361 } | 361 } |
| 362 | 362 |
| 363 // Context menu, from HTTPS to HTTP. | 363 // Context menu, from HTTPS to HTTP. |
| 364 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsContextMenuOrigin) { | 364 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsContextMenuOrigin) { |
| 365 ContextMenuNotificationObserver context_menu_observer( | 365 ContextMenuNotificationObserver context_menu_observer( |
| 366 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 366 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
| 367 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 367 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
| 368 START_ON_HTTPS, | 368 START_ON_HTTPS, |
| 369 REGULAR_LINK, | 369 REGULAR_LINK, |
| 370 NO_REDIRECT, | 370 NO_REDIRECT, |
| 371 NEW_FOREGROUND_TAB, | 371 NEW_FOREGROUND_TAB, |
| 372 blink::WebMouseEvent::ButtonRight, | 372 blink::WebMouseEvent::Button::Right, |
| 373 EXPECT_ORIGIN_AS_REFERRER); | 373 EXPECT_ORIGIN_AS_REFERRER); |
| 374 } | 374 } |
| 375 | 375 |
| 376 // Content initiated navigation, from HTTP to HTTP via server redirect. | 376 // Content initiated navigation, from HTTP to HTTP via server redirect. |
| 377 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Redirect) { | 377 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Redirect) { |
| 378 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, | 378 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, |
| 379 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, | 379 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, |
| 380 blink::WebMouseEvent::ButtonNone, EXPECT_ORIGIN_AS_REFERRER); | 380 blink::WebMouseEvent::Button::NoButton, |
| 381 EXPECT_ORIGIN_AS_REFERRER); |
| 381 } | 382 } |
| 382 | 383 |
| 383 // Content initiated navigation, from HTTPS to HTTP via server redirect. | 384 // Content initiated navigation, from HTTPS to HTTP via server redirect. |
| 384 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsRedirect) { | 385 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsRedirect) { |
| 385 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, | 386 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
| 386 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, | 387 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, |
| 387 blink::WebMouseEvent::ButtonNone, EXPECT_ORIGIN_AS_REFERRER); | 388 blink::WebMouseEvent::Button::NoButton, |
| 389 EXPECT_ORIGIN_AS_REFERRER); |
| 388 } | 390 } |
| 389 | 391 |
| 390 // User initiated navigation, from HTTP to HTTP via server redirect. | 392 // User initiated navigation, from HTTP to HTTP via server redirect. |
| 391 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, LeftClickRedirect) { | 393 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, LeftClickRedirect) { |
| 392 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, | 394 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, |
| 393 SERVER_REDIRECT_FROM_HTTP_TO_HTTP, CURRENT_TAB, | 395 SERVER_REDIRECT_FROM_HTTP_TO_HTTP, CURRENT_TAB, |
| 394 blink::WebMouseEvent::ButtonLeft, EXPECT_ORIGIN_AS_REFERRER); | 396 blink::WebMouseEvent::Button::Left, |
| 397 EXPECT_ORIGIN_AS_REFERRER); |
| 395 } | 398 } |
| 396 | 399 |
| 397 // User initiated navigation, from HTTPS to HTTP via server redirect. | 400 // User initiated navigation, from HTTPS to HTTP via server redirect. |
| 398 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsLeftClickRedirect) { | 401 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsLeftClickRedirect) { |
| 399 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, | 402 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
| 400 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, | 403 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, |
| 401 blink::WebMouseEvent::ButtonLeft, EXPECT_ORIGIN_AS_REFERRER); | 404 blink::WebMouseEvent::Button::Left, |
| 405 EXPECT_ORIGIN_AS_REFERRER); |
| 402 } | 406 } |
| 403 | 407 |
| 404 // User initiated navigation, middle click, from HTTP to HTTP via server | 408 // User initiated navigation, middle click, from HTTP to HTTP via server |
| 405 // redirect. | 409 // redirect. |
| 406 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickRedirect) { | 410 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickRedirect) { |
| 407 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, | 411 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, |
| 408 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_BACKGROUND_TAB, | 412 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_BACKGROUND_TAB, |
| 409 blink::WebMouseEvent::ButtonMiddle, | 413 blink::WebMouseEvent::Button::Middle, |
| 410 EXPECT_ORIGIN_AS_REFERRER); | 414 EXPECT_ORIGIN_AS_REFERRER); |
| 411 } | 415 } |
| 412 | 416 |
| 413 // User initiated navigation, middle click, from HTTPS to HTTP via server | 417 // User initiated navigation, middle click, from HTTPS to HTTP via server |
| 414 // redirect. | 418 // redirect. |
| 415 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickRedirect) { | 419 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickRedirect) { |
| 416 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, | 420 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
| 417 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_BACKGROUND_TAB, | 421 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_BACKGROUND_TAB, |
| 418 blink::WebMouseEvent::ButtonMiddle, | 422 blink::WebMouseEvent::Button::Middle, |
| 419 EXPECT_ORIGIN_AS_REFERRER); | 423 EXPECT_ORIGIN_AS_REFERRER); |
| 420 } | 424 } |
| 421 | 425 |
| 422 // User initiated navigation, target blank, from HTTP to HTTP via server | 426 // User initiated navigation, target blank, from HTTP to HTTP via server |
| 423 // redirect. | 427 // redirect. |
| 424 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, TargetBlankRedirect) { | 428 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, TargetBlankRedirect) { |
| 425 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, | 429 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, |
| 426 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, | 430 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, |
| 427 NEW_FOREGROUND_TAB, blink::WebMouseEvent::ButtonLeft, | 431 NEW_FOREGROUND_TAB, blink::WebMouseEvent::Button::Left, |
| 428 EXPECT_ORIGIN_AS_REFERRER); | 432 EXPECT_ORIGIN_AS_REFERRER); |
| 429 } | 433 } |
| 430 | 434 |
| 431 // User initiated navigation, target blank, from HTTPS to HTTP via server | 435 // User initiated navigation, target blank, from HTTPS to HTTP via server |
| 432 // redirect. | 436 // redirect. |
| 433 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsTargetBlankRedirect) { | 437 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsTargetBlankRedirect) { |
| 434 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, | 438 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, |
| 435 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, | 439 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, |
| 436 NEW_FOREGROUND_TAB, blink::WebMouseEvent::ButtonLeft, | 440 NEW_FOREGROUND_TAB, blink::WebMouseEvent::Button::Left, |
| 437 EXPECT_ORIGIN_AS_REFERRER); | 441 EXPECT_ORIGIN_AS_REFERRER); |
| 438 } | 442 } |
| 439 | 443 |
| 440 // User initiated navigation, middle click, target blank, from HTTP to HTTP via | 444 // User initiated navigation, middle click, target blank, from HTTP to HTTP via |
| 441 // server redirect. | 445 // server redirect. |
| 442 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickTargetBlankRedirect) { | 446 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickTargetBlankRedirect) { |
| 443 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, | 447 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, |
| 444 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, | 448 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, |
| 445 NEW_FOREGROUND_TAB, blink::WebMouseEvent::ButtonMiddle, | 449 NEW_FOREGROUND_TAB, blink::WebMouseEvent::Button::Middle, |
| 446 EXPECT_ORIGIN_AS_REFERRER); | 450 EXPECT_ORIGIN_AS_REFERRER); |
| 447 } | 451 } |
| 448 | 452 |
| 449 // User initiated navigation, middle click, target blank, from HTTPS to HTTP | 453 // User initiated navigation, middle click, target blank, from HTTPS to HTTP |
| 450 // via server redirect. | 454 // via server redirect. |
| 451 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, | 455 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, |
| 452 HttpsMiddleClickTargetBlankRedirect) { | 456 HttpsMiddleClickTargetBlankRedirect) { |
| 453 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, | 457 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, |
| 454 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, | 458 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, |
| 455 NEW_FOREGROUND_TAB, blink::WebMouseEvent::ButtonMiddle, | 459 NEW_FOREGROUND_TAB, blink::WebMouseEvent::Button::Middle, |
| 456 EXPECT_ORIGIN_AS_REFERRER); | 460 EXPECT_ORIGIN_AS_REFERRER); |
| 457 } | 461 } |
| 458 | 462 |
| 459 // Context menu, from HTTP to HTTP via server redirect. | 463 // Context menu, from HTTP to HTTP via server redirect. |
| 460 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, ContextMenuRedirect) { | 464 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, ContextMenuRedirect) { |
| 461 ContextMenuNotificationObserver context_menu_observer( | 465 ContextMenuNotificationObserver context_menu_observer( |
| 462 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 466 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
| 463 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, | 467 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, |
| 464 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_FOREGROUND_TAB, | 468 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_FOREGROUND_TAB, |
| 465 blink::WebMouseEvent::ButtonRight, EXPECT_ORIGIN_AS_REFERRER); | 469 blink::WebMouseEvent::Button::Right, |
| 470 EXPECT_ORIGIN_AS_REFERRER); |
| 466 } | 471 } |
| 467 | 472 |
| 468 // Context menu, from HTTPS to HTTP via server redirect. | 473 // Context menu, from HTTPS to HTTP via server redirect. |
| 469 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsContextMenuRedirect) { | 474 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsContextMenuRedirect) { |
| 470 ContextMenuNotificationObserver context_menu_observer( | 475 ContextMenuNotificationObserver context_menu_observer( |
| 471 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 476 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
| 472 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, | 477 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
| 473 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_FOREGROUND_TAB, | 478 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_FOREGROUND_TAB, |
| 474 blink::WebMouseEvent::ButtonRight, EXPECT_ORIGIN_AS_REFERRER); | 479 blink::WebMouseEvent::Button::Right, |
| 480 EXPECT_ORIGIN_AS_REFERRER); |
| 475 } | 481 } |
| 476 | 482 |
| 477 // Tests history navigation actions: Navigate from A to B with a referrer | 483 // Tests history navigation actions: Navigate from A to B with a referrer |
| 478 // policy, then navigate to C, back to B, and reload. | 484 // policy, then navigate to C, back to B, and reload. |
| 479 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, History) { | 485 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, History) { |
| 480 // Navigate from A to B. | 486 // Navigate from A to B. |
| 481 GURL start_url = RunReferrerTest( | 487 GURL start_url = RunReferrerTest( |
| 482 blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, | 488 blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
| 483 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, | 489 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, |
| 484 blink::WebMouseEvent::ButtonLeft, EXPECT_ORIGIN_AS_REFERRER); | 490 blink::WebMouseEvent::Button::Left, EXPECT_ORIGIN_AS_REFERRER); |
| 485 | 491 |
| 486 // Navigate to C. | 492 // Navigate to C. |
| 487 ui_test_utils::NavigateToURL( | 493 ui_test_utils::NavigateToURL( |
| 488 browser(), net::URLRequestMockHTTPJob::GetMockUrl(std::string())); | 494 browser(), net::URLRequestMockHTTPJob::GetMockUrl(std::string())); |
| 489 | 495 |
| 490 base::string16 expected_title = | 496 base::string16 expected_title = |
| 491 GetExpectedTitle(start_url, EXPECT_ORIGIN_AS_REFERRER); | 497 GetExpectedTitle(start_url, EXPECT_ORIGIN_AS_REFERRER); |
| 492 content::WebContents* tab = | 498 content::WebContents* tab = |
| 493 browser()->tab_strip_model()->GetActiveWebContents(); | 499 browser()->tab_strip_model()->GetActiveWebContents(); |
| 494 std::unique_ptr<content::TitleWatcher> title_watcher( | 500 std::unique_ptr<content::TitleWatcher> title_watcher( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 515 chrome::ReloadBypassingCache(browser(), CURRENT_TAB); | 521 chrome::ReloadBypassingCache(browser(), CURRENT_TAB); |
| 516 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); | 522 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); |
| 517 } | 523 } |
| 518 | 524 |
| 519 // Tests that reloading a site for "request tablet version" correctly clears | 525 // Tests that reloading a site for "request tablet version" correctly clears |
| 520 // the referrer. | 526 // the referrer. |
| 521 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, RequestTabletSite) { | 527 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, RequestTabletSite) { |
| 522 GURL start_url = RunReferrerTest( | 528 GURL start_url = RunReferrerTest( |
| 523 blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, | 529 blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
| 524 SERVER_REDIRECT_FROM_HTTP_TO_HTTP, CURRENT_TAB, | 530 SERVER_REDIRECT_FROM_HTTP_TO_HTTP, CURRENT_TAB, |
| 525 blink::WebMouseEvent::ButtonLeft, EXPECT_ORIGIN_AS_REFERRER); | 531 blink::WebMouseEvent::Button::Left, EXPECT_ORIGIN_AS_REFERRER); |
| 526 | 532 |
| 527 base::string16 expected_title = | 533 base::string16 expected_title = |
| 528 GetExpectedTitle(start_url, EXPECT_EMPTY_REFERRER); | 534 GetExpectedTitle(start_url, EXPECT_EMPTY_REFERRER); |
| 529 content::WebContents* tab = | 535 content::WebContents* tab = |
| 530 browser()->tab_strip_model()->GetActiveWebContents(); | 536 browser()->tab_strip_model()->GetActiveWebContents(); |
| 531 content::TitleWatcher title_watcher(tab, expected_title); | 537 content::TitleWatcher title_watcher(tab, expected_title); |
| 532 | 538 |
| 533 // Watch for all possible outcomes to avoid timeouts if something breaks. | 539 // Watch for all possible outcomes to avoid timeouts if something breaks. |
| 534 AddAllPossibleTitles(start_url, &title_watcher); | 540 AddAllPossibleTitles(start_url, &title_watcher); |
| 535 | 541 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 "referrer_policy/referrer-policy-log.html").spec(), | 597 "referrer_policy/referrer-policy-log.html").spec(), |
| 592 title); | 598 title); |
| 593 } | 599 } |
| 594 | 600 |
| 595 // Origin When Cross-Origin | 601 // Origin When Cross-Origin |
| 596 | 602 |
| 597 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, | 603 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, |
| 598 HttpLeftClickHTTPSRedirectToHTTPOriginWhenCrossOrigin) { | 604 HttpLeftClickHTTPSRedirectToHTTPOriginWhenCrossOrigin) { |
| 599 RunReferrerTest(blink::WebReferrerPolicyOriginWhenCrossOrigin, START_ON_HTTPS, | 605 RunReferrerTest(blink::WebReferrerPolicyOriginWhenCrossOrigin, START_ON_HTTPS, |
| 600 REGULAR_LINK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, | 606 REGULAR_LINK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, |
| 601 blink::WebMouseEvent::ButtonLeft, EXPECT_ORIGIN_AS_REFERRER); | 607 blink::WebMouseEvent::Button::Left, |
| 608 EXPECT_ORIGIN_AS_REFERRER); |
| 602 } | 609 } |
| 603 | 610 |
| 604 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, | 611 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, |
| 605 HttpLeftClickRedirectToHTTPSOriginWhenCrossOrigin) { | 612 HttpLeftClickRedirectToHTTPSOriginWhenCrossOrigin) { |
| 606 RunReferrerTest(blink::WebReferrerPolicyOriginWhenCrossOrigin, START_ON_HTTP, | 613 RunReferrerTest(blink::WebReferrerPolicyOriginWhenCrossOrigin, START_ON_HTTP, |
| 607 REGULAR_LINK, SERVER_REDIRECT_FROM_HTTP_TO_HTTPS, CURRENT_TAB, | 614 REGULAR_LINK, SERVER_REDIRECT_FROM_HTTP_TO_HTTPS, CURRENT_TAB, |
| 608 blink::WebMouseEvent::ButtonLeft, EXPECT_ORIGIN_AS_REFERRER); | 615 blink::WebMouseEvent::Button::Left, |
| 616 EXPECT_ORIGIN_AS_REFERRER); |
| 609 } | 617 } |
| 610 | 618 |
| 611 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, | 619 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, |
| 612 HttpLeftClickRedirectToHTTPOriginWhenCrossOrigin) { | 620 HttpLeftClickRedirectToHTTPOriginWhenCrossOrigin) { |
| 613 RunReferrerTest(blink::WebReferrerPolicyOriginWhenCrossOrigin, START_ON_HTTP, | 621 RunReferrerTest(blink::WebReferrerPolicyOriginWhenCrossOrigin, START_ON_HTTP, |
| 614 REGULAR_LINK, SERVER_REDIRECT_FROM_HTTP_TO_HTTP, CURRENT_TAB, | 622 REGULAR_LINK, SERVER_REDIRECT_FROM_HTTP_TO_HTTP, CURRENT_TAB, |
| 615 blink::WebMouseEvent::ButtonLeft, EXPECT_FULL_REFERRER); | 623 blink::WebMouseEvent::Button::Left, EXPECT_FULL_REFERRER); |
| 616 } | 624 } |
| 617 | 625 |
| 618 // Reduced 'referer' granularity flag tests. | 626 // Reduced 'referer' granularity flag tests. |
| 619 | 627 |
| 620 // User initiated navigation, from HTTP to HTTPS via server redirect. | 628 // User initiated navigation, from HTTP to HTTPS via server redirect. |
| 621 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpLeftClickRedirectDefaultNoFlag) { | 629 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpLeftClickRedirectDefaultNoFlag) { |
| 622 RunReferrerTest(blink::WebReferrerPolicyDefault, START_ON_HTTP, REGULAR_LINK, | 630 RunReferrerTest(blink::WebReferrerPolicyDefault, START_ON_HTTP, REGULAR_LINK, |
| 623 SERVER_REDIRECT_FROM_HTTP_TO_HTTPS, CURRENT_TAB, | 631 SERVER_REDIRECT_FROM_HTTP_TO_HTTPS, CURRENT_TAB, |
| 624 blink::WebMouseEvent::ButtonLeft, EXPECT_FULL_REFERRER, | 632 blink::WebMouseEvent::Button::Left, EXPECT_FULL_REFERRER, |
| 625 blink::WebReferrerPolicyNoReferrerWhenDowngrade); | 633 blink::WebReferrerPolicyNoReferrerWhenDowngrade); |
| 626 } | 634 } |
| 627 | 635 |
| 628 IN_PROC_BROWSER_TEST_F(ReferrerPolicyWithReduceReferrerGranularityFlagTest, | 636 IN_PROC_BROWSER_TEST_F(ReferrerPolicyWithReduceReferrerGranularityFlagTest, |
| 629 HttpLeftClickRedirectDefaultFlag) { | 637 HttpLeftClickRedirectDefaultFlag) { |
| 630 blink::WebReferrerPolicy expected_referrer_policy = | 638 blink::WebReferrerPolicy expected_referrer_policy = |
| 631 blink::WebReferrerPolicyNoReferrerWhenDowngradeOriginWhenCrossOrigin; | 639 blink::WebReferrerPolicyNoReferrerWhenDowngradeOriginWhenCrossOrigin; |
| 632 | 640 |
| 633 RunReferrerTest(blink::WebReferrerPolicyDefault, START_ON_HTTP, REGULAR_LINK, | 641 RunReferrerTest(blink::WebReferrerPolicyDefault, START_ON_HTTP, REGULAR_LINK, |
| 634 SERVER_REDIRECT_FROM_HTTP_TO_HTTPS, CURRENT_TAB, | 642 SERVER_REDIRECT_FROM_HTTP_TO_HTTPS, CURRENT_TAB, |
| 635 blink::WebMouseEvent::ButtonLeft, EXPECT_ORIGIN_AS_REFERRER, | 643 blink::WebMouseEvent::Button::Left, EXPECT_ORIGIN_AS_REFERRER, |
| 636 expected_referrer_policy); | 644 expected_referrer_policy); |
| 637 } | 645 } |
| OLD | NEW |