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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
190 | 190 |
191 if (disposition == CURRENT_TAB) { | 191 if (disposition == WindowOpenDisposition::CURRENT_TAB) { |
192 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 192 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
193 } else { | 193 } else { |
194 tab_added_observer.Wait(); | 194 tab_added_observer.Wait(); |
195 tab = tab_added_observer.GetTab(); | 195 tab = tab_added_observer.GetTab(); |
196 EXPECT_TRUE(tab); | 196 EXPECT_TRUE(tab); |
197 content::TitleWatcher title_watcher2(tab, expected_title); | 197 content::TitleWatcher title_watcher2(tab, expected_title); |
198 | 198 |
199 // Watch for all possible outcomes to avoid timeouts if something breaks. | 199 // Watch for all possible outcomes to avoid timeouts if something breaks. |
200 AddAllPossibleTitles(start_url, &title_watcher2); | 200 AddAllPossibleTitles(start_url, &title_watcher2); |
201 | 201 |
(...skipping 30 matching lines...) Expand all Loading... |
232 | 232 |
233 // The basic behavior of referrer policies is covered by layout tests in | 233 // The basic behavior of referrer policies is covered by layout tests in |
234 // http/tests/security/referrer-policy-*. These tests cover (hopefully) all | 234 // http/tests/security/referrer-policy-*. These tests cover (hopefully) all |
235 // code paths chrome uses to navigate. To keep the number of combinations down, | 235 // code paths chrome uses to navigate. To keep the number of combinations down, |
236 // we only test the "origin" policy here. | 236 // we only test the "origin" policy here. |
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, START_ON_HTTP, REGULAR_LINK, |
243 START_ON_HTTP, | 243 NO_REDIRECT, WindowOpenDisposition::CURRENT_TAB, |
244 REGULAR_LINK, | |
245 NO_REDIRECT, | |
246 CURRENT_TAB, | |
247 blink::WebMouseEvent::Button::NoButton, | 244 blink::WebMouseEvent::Button::NoButton, |
248 EXPECT_ORIGIN_AS_REFERRER); | 245 EXPECT_ORIGIN_AS_REFERRER); |
249 } | 246 } |
250 | 247 |
251 // Content initiated navigation, from HTTPS to HTTP. | 248 // Content initiated navigation, from HTTPS to HTTP. |
252 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsDefault) { | 249 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsDefault) { |
253 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 250 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
254 START_ON_HTTPS, | 251 NO_REDIRECT, WindowOpenDisposition::CURRENT_TAB, |
255 REGULAR_LINK, | |
256 NO_REDIRECT, | |
257 CURRENT_TAB, | |
258 blink::WebMouseEvent::Button::NoButton, | 252 blink::WebMouseEvent::Button::NoButton, |
259 EXPECT_ORIGIN_AS_REFERRER); | 253 EXPECT_ORIGIN_AS_REFERRER); |
260 } | 254 } |
261 | 255 |
262 // User initiated navigation, from HTTP to HTTP. | 256 // User initiated navigation, from HTTP to HTTP. |
263 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, LeftClickOrigin) { | 257 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, LeftClickOrigin) { |
264 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 258 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, |
265 START_ON_HTTP, | 259 NO_REDIRECT, WindowOpenDisposition::CURRENT_TAB, |
266 REGULAR_LINK, | |
267 NO_REDIRECT, | |
268 CURRENT_TAB, | |
269 blink::WebMouseEvent::Button::Left, | 260 blink::WebMouseEvent::Button::Left, |
270 EXPECT_ORIGIN_AS_REFERRER); | 261 EXPECT_ORIGIN_AS_REFERRER); |
271 } | 262 } |
272 | 263 |
273 // User initiated navigation, from HTTPS to HTTP. | 264 // User initiated navigation, from HTTPS to HTTP. |
274 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsLeftClickOrigin) { | 265 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsLeftClickOrigin) { |
275 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 266 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
276 START_ON_HTTPS, | 267 NO_REDIRECT, WindowOpenDisposition::CURRENT_TAB, |
277 REGULAR_LINK, | |
278 NO_REDIRECT, | |
279 CURRENT_TAB, | |
280 blink::WebMouseEvent::Button::Left, | 268 blink::WebMouseEvent::Button::Left, |
281 EXPECT_ORIGIN_AS_REFERRER); | 269 EXPECT_ORIGIN_AS_REFERRER); |
282 } | 270 } |
283 | 271 |
284 // User initiated navigation, middle click, from HTTP to HTTP. | 272 // User initiated navigation, middle click, from HTTP to HTTP. |
285 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickOrigin) { | 273 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickOrigin) { |
286 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 274 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, |
287 START_ON_HTTP, | 275 NO_REDIRECT, WindowOpenDisposition::NEW_BACKGROUND_TAB, |
288 REGULAR_LINK, | |
289 NO_REDIRECT, | |
290 NEW_BACKGROUND_TAB, | |
291 blink::WebMouseEvent::Button::Middle, | 276 blink::WebMouseEvent::Button::Middle, |
292 EXPECT_ORIGIN_AS_REFERRER); | 277 EXPECT_ORIGIN_AS_REFERRER); |
293 } | 278 } |
294 | 279 |
295 // User initiated navigation, middle click, from HTTPS to HTTP. | 280 // User initiated navigation, middle click, from HTTPS to HTTP. |
296 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickOrigin) { | 281 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickOrigin) { |
297 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 282 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
298 START_ON_HTTPS, | 283 NO_REDIRECT, WindowOpenDisposition::NEW_BACKGROUND_TAB, |
299 REGULAR_LINK, | |
300 NO_REDIRECT, | |
301 NEW_BACKGROUND_TAB, | |
302 blink::WebMouseEvent::Button::Middle, | 284 blink::WebMouseEvent::Button::Middle, |
303 EXPECT_ORIGIN_AS_REFERRER); | 285 EXPECT_ORIGIN_AS_REFERRER); |
304 } | 286 } |
305 | 287 |
306 // User initiated navigation, target blank, from HTTP to HTTP. | 288 // User initiated navigation, target blank, from HTTP to HTTP. |
307 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, TargetBlankOrigin) { | 289 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, TargetBlankOrigin) { |
308 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 290 RunReferrerTest( |
309 START_ON_HTTP, | 291 blink::WebReferrerPolicyOrigin, START_ON_HTTP, LINK_WITH_TARGET_BLANK, |
310 LINK_WITH_TARGET_BLANK, | 292 NO_REDIRECT, WindowOpenDisposition::NEW_FOREGROUND_TAB, |
311 NO_REDIRECT, | 293 blink::WebMouseEvent::Button::Left, EXPECT_ORIGIN_AS_REFERRER); |
312 NEW_FOREGROUND_TAB, | |
313 blink::WebMouseEvent::Button::Left, | |
314 EXPECT_ORIGIN_AS_REFERRER); | |
315 } | 294 } |
316 | 295 |
317 // User initiated navigation, target blank, from HTTPS to HTTP. | 296 // User initiated navigation, target blank, from HTTPS to HTTP. |
318 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsTargetBlankOrigin) { | 297 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsTargetBlankOrigin) { |
319 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 298 RunReferrerTest( |
320 START_ON_HTTPS, | 299 blink::WebReferrerPolicyOrigin, START_ON_HTTPS, LINK_WITH_TARGET_BLANK, |
321 LINK_WITH_TARGET_BLANK, | 300 NO_REDIRECT, WindowOpenDisposition::NEW_FOREGROUND_TAB, |
322 NO_REDIRECT, | 301 blink::WebMouseEvent::Button::Left, EXPECT_ORIGIN_AS_REFERRER); |
323 NEW_FOREGROUND_TAB, | |
324 blink::WebMouseEvent::Button::Left, | |
325 EXPECT_ORIGIN_AS_REFERRER); | |
326 } | 302 } |
327 | 303 |
328 // User initiated navigation, middle click, target blank, from HTTP to HTTP. | 304 // User initiated navigation, middle click, target blank, from HTTP to HTTP. |
329 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickTargetBlankOrigin) { | 305 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickTargetBlankOrigin) { |
330 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 306 RunReferrerTest( |
331 START_ON_HTTP, | 307 blink::WebReferrerPolicyOrigin, START_ON_HTTP, LINK_WITH_TARGET_BLANK, |
332 LINK_WITH_TARGET_BLANK, | 308 NO_REDIRECT, WindowOpenDisposition::NEW_FOREGROUND_TAB, |
333 NO_REDIRECT, | 309 blink::WebMouseEvent::Button::Middle, EXPECT_ORIGIN_AS_REFERRER); |
334 NEW_FOREGROUND_TAB, | |
335 blink::WebMouseEvent::Button::Middle, | |
336 EXPECT_ORIGIN_AS_REFERRER); | |
337 } | 310 } |
338 | 311 |
339 // User initiated navigation, middle click, target blank, from HTTPS to HTTP. | 312 // User initiated navigation, middle click, target blank, from HTTPS to HTTP. |
340 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickTargetBlankOrigin) { | 313 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickTargetBlankOrigin) { |
341 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 314 RunReferrerTest( |
342 START_ON_HTTPS, | 315 blink::WebReferrerPolicyOrigin, START_ON_HTTPS, LINK_WITH_TARGET_BLANK, |
343 LINK_WITH_TARGET_BLANK, | 316 NO_REDIRECT, WindowOpenDisposition::NEW_FOREGROUND_TAB, |
344 NO_REDIRECT, | 317 blink::WebMouseEvent::Button::Middle, EXPECT_ORIGIN_AS_REFERRER); |
345 NEW_FOREGROUND_TAB, | |
346 blink::WebMouseEvent::Button::Middle, | |
347 EXPECT_ORIGIN_AS_REFERRER); | |
348 } | 318 } |
349 | 319 |
350 // Context menu, from HTTP to HTTP. | 320 // Context menu, from HTTP to HTTP. |
351 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, ContextMenuOrigin) { | 321 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, ContextMenuOrigin) { |
352 ContextMenuNotificationObserver context_menu_observer( | 322 ContextMenuNotificationObserver context_menu_observer( |
353 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 323 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
354 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 324 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, |
355 START_ON_HTTP, | 325 NO_REDIRECT, WindowOpenDisposition::NEW_FOREGROUND_TAB, |
356 REGULAR_LINK, | |
357 NO_REDIRECT, | |
358 NEW_FOREGROUND_TAB, | |
359 blink::WebMouseEvent::Button::Right, | 326 blink::WebMouseEvent::Button::Right, |
360 EXPECT_ORIGIN_AS_REFERRER); | 327 EXPECT_ORIGIN_AS_REFERRER); |
361 } | 328 } |
362 | 329 |
363 // Context menu, from HTTPS to HTTP. | 330 // Context menu, from HTTPS to HTTP. |
364 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsContextMenuOrigin) { | 331 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsContextMenuOrigin) { |
365 ContextMenuNotificationObserver context_menu_observer( | 332 ContextMenuNotificationObserver context_menu_observer( |
366 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 333 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
367 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 334 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
368 START_ON_HTTPS, | 335 NO_REDIRECT, WindowOpenDisposition::NEW_FOREGROUND_TAB, |
369 REGULAR_LINK, | |
370 NO_REDIRECT, | |
371 NEW_FOREGROUND_TAB, | |
372 blink::WebMouseEvent::Button::Right, | 336 blink::WebMouseEvent::Button::Right, |
373 EXPECT_ORIGIN_AS_REFERRER); | 337 EXPECT_ORIGIN_AS_REFERRER); |
374 } | 338 } |
375 | 339 |
376 // Content initiated navigation, from HTTP to HTTP via server redirect. | 340 // Content initiated navigation, from HTTP to HTTP via server redirect. |
377 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Redirect) { | 341 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Redirect) { |
378 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, | 342 RunReferrerTest( |
379 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, | 343 blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, |
380 blink::WebMouseEvent::Button::NoButton, | 344 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, WindowOpenDisposition::CURRENT_TAB, |
381 EXPECT_ORIGIN_AS_REFERRER); | 345 blink::WebMouseEvent::Button::NoButton, EXPECT_ORIGIN_AS_REFERRER); |
382 } | 346 } |
383 | 347 |
384 // Content initiated navigation, from HTTPS to HTTP via server redirect. | 348 // Content initiated navigation, from HTTPS to HTTP via server redirect. |
385 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsRedirect) { | 349 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsRedirect) { |
386 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, | 350 RunReferrerTest( |
387 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, | 351 blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
388 blink::WebMouseEvent::Button::NoButton, | 352 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, WindowOpenDisposition::CURRENT_TAB, |
389 EXPECT_ORIGIN_AS_REFERRER); | 353 blink::WebMouseEvent::Button::NoButton, EXPECT_ORIGIN_AS_REFERRER); |
390 } | 354 } |
391 | 355 |
392 // User initiated navigation, from HTTP to HTTP via server redirect. | 356 // User initiated navigation, from HTTP to HTTP via server redirect. |
393 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, LeftClickRedirect) { | 357 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, LeftClickRedirect) { |
394 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, | 358 RunReferrerTest( |
395 SERVER_REDIRECT_FROM_HTTP_TO_HTTP, CURRENT_TAB, | 359 blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, |
396 blink::WebMouseEvent::Button::Left, | 360 SERVER_REDIRECT_FROM_HTTP_TO_HTTP, WindowOpenDisposition::CURRENT_TAB, |
397 EXPECT_ORIGIN_AS_REFERRER); | 361 blink::WebMouseEvent::Button::Left, EXPECT_ORIGIN_AS_REFERRER); |
398 } | 362 } |
399 | 363 |
400 // User initiated navigation, from HTTPS to HTTP via server redirect. | 364 // User initiated navigation, from HTTPS to HTTP via server redirect. |
401 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsLeftClickRedirect) { | 365 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsLeftClickRedirect) { |
402 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, | 366 RunReferrerTest( |
403 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, | 367 blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
404 blink::WebMouseEvent::Button::Left, | 368 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, WindowOpenDisposition::CURRENT_TAB, |
405 EXPECT_ORIGIN_AS_REFERRER); | 369 blink::WebMouseEvent::Button::Left, EXPECT_ORIGIN_AS_REFERRER); |
406 } | 370 } |
407 | 371 |
408 // User initiated navigation, middle click, from HTTP to HTTP via server | 372 // User initiated navigation, middle click, from HTTP to HTTP via server |
409 // redirect. | 373 // redirect. |
410 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickRedirect) { | 374 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickRedirect) { |
411 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, | 375 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, |
412 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_BACKGROUND_TAB, | 376 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, |
| 377 WindowOpenDisposition::NEW_BACKGROUND_TAB, |
413 blink::WebMouseEvent::Button::Middle, | 378 blink::WebMouseEvent::Button::Middle, |
414 EXPECT_ORIGIN_AS_REFERRER); | 379 EXPECT_ORIGIN_AS_REFERRER); |
415 } | 380 } |
416 | 381 |
417 // User initiated navigation, middle click, from HTTPS to HTTP via server | 382 // User initiated navigation, middle click, from HTTPS to HTTP via server |
418 // redirect. | 383 // redirect. |
419 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickRedirect) { | 384 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickRedirect) { |
420 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, | 385 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
421 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_BACKGROUND_TAB, | 386 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, |
| 387 WindowOpenDisposition::NEW_BACKGROUND_TAB, |
422 blink::WebMouseEvent::Button::Middle, | 388 blink::WebMouseEvent::Button::Middle, |
423 EXPECT_ORIGIN_AS_REFERRER); | 389 EXPECT_ORIGIN_AS_REFERRER); |
424 } | 390 } |
425 | 391 |
426 // User initiated navigation, target blank, from HTTP to HTTP via server | 392 // User initiated navigation, target blank, from HTTP to HTTP via server |
427 // redirect. | 393 // redirect. |
428 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, TargetBlankRedirect) { | 394 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, TargetBlankRedirect) { |
429 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, | 395 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, |
430 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, | 396 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, |
431 NEW_FOREGROUND_TAB, blink::WebMouseEvent::Button::Left, | 397 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 398 blink::WebMouseEvent::Button::Left, |
432 EXPECT_ORIGIN_AS_REFERRER); | 399 EXPECT_ORIGIN_AS_REFERRER); |
433 } | 400 } |
434 | 401 |
435 // User initiated navigation, target blank, from HTTPS to HTTP via server | 402 // User initiated navigation, target blank, from HTTPS to HTTP via server |
436 // redirect. | 403 // redirect. |
437 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsTargetBlankRedirect) { | 404 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsTargetBlankRedirect) { |
438 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, | 405 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, |
439 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, | 406 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, |
440 NEW_FOREGROUND_TAB, blink::WebMouseEvent::Button::Left, | 407 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 408 blink::WebMouseEvent::Button::Left, |
441 EXPECT_ORIGIN_AS_REFERRER); | 409 EXPECT_ORIGIN_AS_REFERRER); |
442 } | 410 } |
443 | 411 |
444 // User initiated navigation, middle click, target blank, from HTTP to HTTP via | 412 // User initiated navigation, middle click, target blank, from HTTP to HTTP via |
445 // server redirect. | 413 // server redirect. |
446 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickTargetBlankRedirect) { | 414 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickTargetBlankRedirect) { |
447 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, | 415 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, |
448 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, | 416 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, |
449 NEW_FOREGROUND_TAB, blink::WebMouseEvent::Button::Middle, | 417 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 418 blink::WebMouseEvent::Button::Middle, |
450 EXPECT_ORIGIN_AS_REFERRER); | 419 EXPECT_ORIGIN_AS_REFERRER); |
451 } | 420 } |
452 | 421 |
453 // User initiated navigation, middle click, target blank, from HTTPS to HTTP | 422 // User initiated navigation, middle click, target blank, from HTTPS to HTTP |
454 // via server redirect. | 423 // via server redirect. |
455 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, | 424 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, |
456 HttpsMiddleClickTargetBlankRedirect) { | 425 HttpsMiddleClickTargetBlankRedirect) { |
457 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, | 426 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, |
458 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, | 427 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, |
459 NEW_FOREGROUND_TAB, blink::WebMouseEvent::Button::Middle, | 428 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 429 blink::WebMouseEvent::Button::Middle, |
460 EXPECT_ORIGIN_AS_REFERRER); | 430 EXPECT_ORIGIN_AS_REFERRER); |
461 } | 431 } |
462 | 432 |
463 // Context menu, from HTTP to HTTP via server redirect. | 433 // Context menu, from HTTP to HTTP via server redirect. |
464 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, ContextMenuRedirect) { | 434 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, ContextMenuRedirect) { |
465 ContextMenuNotificationObserver context_menu_observer( | 435 ContextMenuNotificationObserver context_menu_observer( |
466 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 436 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
467 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, | 437 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, |
468 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_FOREGROUND_TAB, | 438 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, |
| 439 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
469 blink::WebMouseEvent::Button::Right, | 440 blink::WebMouseEvent::Button::Right, |
470 EXPECT_ORIGIN_AS_REFERRER); | 441 EXPECT_ORIGIN_AS_REFERRER); |
471 } | 442 } |
472 | 443 |
473 // Context menu, from HTTPS to HTTP via server redirect. | 444 // Context menu, from HTTPS to HTTP via server redirect. |
474 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsContextMenuRedirect) { | 445 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsContextMenuRedirect) { |
475 ContextMenuNotificationObserver context_menu_observer( | 446 ContextMenuNotificationObserver context_menu_observer( |
476 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 447 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
477 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, | 448 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
478 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_FOREGROUND_TAB, | 449 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, |
| 450 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
479 blink::WebMouseEvent::Button::Right, | 451 blink::WebMouseEvent::Button::Right, |
480 EXPECT_ORIGIN_AS_REFERRER); | 452 EXPECT_ORIGIN_AS_REFERRER); |
481 } | 453 } |
482 | 454 |
483 // Tests history navigation actions: Navigate from A to B with a referrer | 455 // Tests history navigation actions: Navigate from A to B with a referrer |
484 // policy, then navigate to C, back to B, and reload. | 456 // policy, then navigate to C, back to B, and reload. |
485 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, History) { | 457 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, History) { |
486 // Navigate from A to B. | 458 // Navigate from A to B. |
487 GURL start_url = RunReferrerTest( | 459 GURL start_url = RunReferrerTest( |
488 blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, | 460 blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
489 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, | 461 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, WindowOpenDisposition::CURRENT_TAB, |
490 blink::WebMouseEvent::Button::Left, EXPECT_ORIGIN_AS_REFERRER); | 462 blink::WebMouseEvent::Button::Left, EXPECT_ORIGIN_AS_REFERRER); |
491 | 463 |
492 // Navigate to C. | 464 // Navigate to C. |
493 ui_test_utils::NavigateToURL( | 465 ui_test_utils::NavigateToURL( |
494 browser(), net::URLRequestMockHTTPJob::GetMockUrl(std::string())); | 466 browser(), net::URLRequestMockHTTPJob::GetMockUrl(std::string())); |
495 | 467 |
496 base::string16 expected_title = | 468 base::string16 expected_title = |
497 GetExpectedTitle(start_url, EXPECT_ORIGIN_AS_REFERRER); | 469 GetExpectedTitle(start_url, EXPECT_ORIGIN_AS_REFERRER); |
498 content::WebContents* tab = | 470 content::WebContents* tab = |
499 browser()->tab_strip_model()->GetActiveWebContents(); | 471 browser()->tab_strip_model()->GetActiveWebContents(); |
500 std::unique_ptr<content::TitleWatcher> title_watcher( | 472 std::unique_ptr<content::TitleWatcher> title_watcher( |
501 new content::TitleWatcher(tab, expected_title)); | 473 new content::TitleWatcher(tab, expected_title)); |
502 | 474 |
503 // Watch for all possible outcomes to avoid timeouts if something breaks. | 475 // Watch for all possible outcomes to avoid timeouts if something breaks. |
504 AddAllPossibleTitles(start_url, title_watcher.get()); | 476 AddAllPossibleTitles(start_url, title_watcher.get()); |
505 | 477 |
506 // Go back to B. | 478 // Go back to B. |
507 chrome::GoBack(browser(), CURRENT_TAB); | 479 chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB); |
508 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); | 480 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); |
509 | 481 |
510 title_watcher.reset(new content::TitleWatcher(tab, expected_title)); | 482 title_watcher.reset(new content::TitleWatcher(tab, expected_title)); |
511 AddAllPossibleTitles(start_url, title_watcher.get()); | 483 AddAllPossibleTitles(start_url, title_watcher.get()); |
512 | 484 |
513 // Reload to B. | 485 // Reload to B. |
514 chrome::Reload(browser(), CURRENT_TAB); | 486 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB); |
515 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); | 487 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); |
516 | 488 |
517 title_watcher.reset(new content::TitleWatcher(tab, expected_title)); | 489 title_watcher.reset(new content::TitleWatcher(tab, expected_title)); |
518 AddAllPossibleTitles(start_url, title_watcher.get()); | 490 AddAllPossibleTitles(start_url, title_watcher.get()); |
519 | 491 |
520 // Shift-reload to B. | 492 // Shift-reload to B. |
521 chrome::ReloadBypassingCache(browser(), CURRENT_TAB); | 493 chrome::ReloadBypassingCache(browser(), WindowOpenDisposition::CURRENT_TAB); |
522 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); | 494 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); |
523 } | 495 } |
524 | 496 |
525 // Tests that reloading a site for "request tablet version" correctly clears | 497 // Tests that reloading a site for "request tablet version" correctly clears |
526 // the referrer. | 498 // the referrer. |
527 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, RequestTabletSite) { | 499 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, RequestTabletSite) { |
528 GURL start_url = RunReferrerTest( | 500 GURL start_url = RunReferrerTest( |
529 blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, | 501 blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
530 SERVER_REDIRECT_FROM_HTTP_TO_HTTP, CURRENT_TAB, | 502 SERVER_REDIRECT_FROM_HTTP_TO_HTTP, WindowOpenDisposition::CURRENT_TAB, |
531 blink::WebMouseEvent::Button::Left, EXPECT_ORIGIN_AS_REFERRER); | 503 blink::WebMouseEvent::Button::Left, EXPECT_ORIGIN_AS_REFERRER); |
532 | 504 |
533 base::string16 expected_title = | 505 base::string16 expected_title = |
534 GetExpectedTitle(start_url, EXPECT_EMPTY_REFERRER); | 506 GetExpectedTitle(start_url, EXPECT_EMPTY_REFERRER); |
535 content::WebContents* tab = | 507 content::WebContents* tab = |
536 browser()->tab_strip_model()->GetActiveWebContents(); | 508 browser()->tab_strip_model()->GetActiveWebContents(); |
537 content::TitleWatcher title_watcher(tab, expected_title); | 509 content::TitleWatcher title_watcher(tab, expected_title); |
538 | 510 |
539 // Watch for all possible outcomes to avoid timeouts if something breaks. | 511 // Watch for all possible outcomes to avoid timeouts if something breaks. |
540 AddAllPossibleTitles(start_url, &title_watcher); | 512 AddAllPossibleTitles(start_url, &title_watcher); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 net::URLRequestMockHTTPJob::GetMockUrl( | 568 net::URLRequestMockHTTPJob::GetMockUrl( |
597 "referrer_policy/referrer-policy-log.html").spec(), | 569 "referrer_policy/referrer-policy-log.html").spec(), |
598 title); | 570 title); |
599 } | 571 } |
600 | 572 |
601 // Origin When Cross-Origin | 573 // Origin When Cross-Origin |
602 | 574 |
603 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, | 575 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, |
604 HttpLeftClickHTTPSRedirectToHTTPOriginWhenCrossOrigin) { | 576 HttpLeftClickHTTPSRedirectToHTTPOriginWhenCrossOrigin) { |
605 RunReferrerTest(blink::WebReferrerPolicyOriginWhenCrossOrigin, START_ON_HTTPS, | 577 RunReferrerTest(blink::WebReferrerPolicyOriginWhenCrossOrigin, START_ON_HTTPS, |
606 REGULAR_LINK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, | 578 REGULAR_LINK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, |
| 579 WindowOpenDisposition::CURRENT_TAB, |
607 blink::WebMouseEvent::Button::Left, | 580 blink::WebMouseEvent::Button::Left, |
608 EXPECT_ORIGIN_AS_REFERRER); | 581 EXPECT_ORIGIN_AS_REFERRER); |
609 } | 582 } |
610 | 583 |
611 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, | 584 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, |
612 HttpLeftClickRedirectToHTTPSOriginWhenCrossOrigin) { | 585 HttpLeftClickRedirectToHTTPSOriginWhenCrossOrigin) { |
613 RunReferrerTest(blink::WebReferrerPolicyOriginWhenCrossOrigin, START_ON_HTTP, | 586 RunReferrerTest(blink::WebReferrerPolicyOriginWhenCrossOrigin, START_ON_HTTP, |
614 REGULAR_LINK, SERVER_REDIRECT_FROM_HTTP_TO_HTTPS, CURRENT_TAB, | 587 REGULAR_LINK, SERVER_REDIRECT_FROM_HTTP_TO_HTTPS, |
| 588 WindowOpenDisposition::CURRENT_TAB, |
615 blink::WebMouseEvent::Button::Left, | 589 blink::WebMouseEvent::Button::Left, |
616 EXPECT_ORIGIN_AS_REFERRER); | 590 EXPECT_ORIGIN_AS_REFERRER); |
617 } | 591 } |
618 | 592 |
619 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, | 593 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, |
620 HttpLeftClickRedirectToHTTPOriginWhenCrossOrigin) { | 594 HttpLeftClickRedirectToHTTPOriginWhenCrossOrigin) { |
621 RunReferrerTest(blink::WebReferrerPolicyOriginWhenCrossOrigin, START_ON_HTTP, | 595 RunReferrerTest(blink::WebReferrerPolicyOriginWhenCrossOrigin, START_ON_HTTP, |
622 REGULAR_LINK, SERVER_REDIRECT_FROM_HTTP_TO_HTTP, CURRENT_TAB, | 596 REGULAR_LINK, SERVER_REDIRECT_FROM_HTTP_TO_HTTP, |
| 597 WindowOpenDisposition::CURRENT_TAB, |
623 blink::WebMouseEvent::Button::Left, EXPECT_FULL_REFERRER); | 598 blink::WebMouseEvent::Button::Left, EXPECT_FULL_REFERRER); |
624 } | 599 } |
625 | 600 |
626 // Reduced 'referer' granularity flag tests. | 601 // Reduced 'referer' granularity flag tests. |
627 | 602 |
628 // User initiated navigation, from HTTP to HTTPS via server redirect. | 603 // User initiated navigation, from HTTP to HTTPS via server redirect. |
629 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpLeftClickRedirectDefaultNoFlag) { | 604 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpLeftClickRedirectDefaultNoFlag) { |
630 RunReferrerTest(blink::WebReferrerPolicyDefault, START_ON_HTTP, REGULAR_LINK, | 605 RunReferrerTest(blink::WebReferrerPolicyDefault, START_ON_HTTP, REGULAR_LINK, |
631 SERVER_REDIRECT_FROM_HTTP_TO_HTTPS, CURRENT_TAB, | 606 SERVER_REDIRECT_FROM_HTTP_TO_HTTPS, |
| 607 WindowOpenDisposition::CURRENT_TAB, |
632 blink::WebMouseEvent::Button::Left, EXPECT_FULL_REFERRER, | 608 blink::WebMouseEvent::Button::Left, EXPECT_FULL_REFERRER, |
633 blink::WebReferrerPolicyNoReferrerWhenDowngrade); | 609 blink::WebReferrerPolicyNoReferrerWhenDowngrade); |
634 } | 610 } |
635 | 611 |
636 IN_PROC_BROWSER_TEST_F(ReferrerPolicyWithReduceReferrerGranularityFlagTest, | 612 IN_PROC_BROWSER_TEST_F(ReferrerPolicyWithReduceReferrerGranularityFlagTest, |
637 HttpLeftClickRedirectDefaultFlag) { | 613 HttpLeftClickRedirectDefaultFlag) { |
638 blink::WebReferrerPolicy expected_referrer_policy = | 614 blink::WebReferrerPolicy expected_referrer_policy = |
639 blink::WebReferrerPolicyNoReferrerWhenDowngradeOriginWhenCrossOrigin; | 615 blink::WebReferrerPolicyNoReferrerWhenDowngradeOriginWhenCrossOrigin; |
640 | 616 |
641 RunReferrerTest(blink::WebReferrerPolicyDefault, START_ON_HTTP, REGULAR_LINK, | 617 RunReferrerTest(blink::WebReferrerPolicyDefault, START_ON_HTTP, REGULAR_LINK, |
642 SERVER_REDIRECT_FROM_HTTP_TO_HTTPS, CURRENT_TAB, | 618 SERVER_REDIRECT_FROM_HTTP_TO_HTTPS, |
| 619 WindowOpenDisposition::CURRENT_TAB, |
643 blink::WebMouseEvent::Button::Left, EXPECT_ORIGIN_AS_REFERRER, | 620 blink::WebMouseEvent::Button::Left, EXPECT_ORIGIN_AS_REFERRER, |
644 expected_referrer_policy); | 621 expected_referrer_policy); |
645 } | 622 } |
OLD | NEW |