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 "net/url_request/url_request_job.h" | 5 #include "net/url_request/url_request_job.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "net/base/request_priority.h" | 10 #include "net/base/request_priority.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 // ... but should be stripped to the origin for a cross-origin redirect. | 381 // ... but should be stripped to the origin for a cross-origin redirect. |
382 {"https://foo.test/one" /* original url */, | 382 {"https://foo.test/one" /* original url */, |
383 "https://foo.test/one" /* original referrer */, | 383 "https://foo.test/one" /* original referrer */, |
384 "Location: https://bar.test/two\n" | 384 "Location: https://bar.test/two\n" |
385 "Referrer-Policy: origin-when-cross-origin\n", | 385 "Referrer-Policy: origin-when-cross-origin\n", |
386 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, | 386 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
387 URLRequest:: | 387 URLRequest:: |
388 ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN /* expected final policy */, | 388 ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN /* expected final policy */, |
389 "https://foo.test/" /* expected final referrer */}, | 389 "https://foo.test/" /* expected final referrer */}, |
390 | 390 |
| 391 // If a redirect serves 'Referrer-Policy: same-origin', then the referrer |
| 392 // should be untouched for a same-origin redirect, |
| 393 {"https://foo.test/one" /* original url */, |
| 394 "https://foo.test/referrer" /* original referrer */, |
| 395 "Location: https://foo.test/two\n" |
| 396 "Referrer-Policy: same-origin\n", |
| 397 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 398 URLRequest::CLEAR_REFERRER_ON_TRANSITION_CROSS_ORIGIN /* expected final |
| 399 policy */ |
| 400 , |
| 401 "https://foo.test/referrer" /* expected final referrer */}, |
| 402 |
| 403 // ... but should be cleared for a cross-origin redirect. |
| 404 {"https://foo.test/one" /* original url */, |
| 405 "https://foo.test/referrer" /* original referrer */, |
| 406 "Location: https://bar.test/two\n" |
| 407 "Referrer-Policy: same-origin\n", |
| 408 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 409 URLRequest::CLEAR_REFERRER_ON_TRANSITION_CROSS_ORIGIN /* expected final |
| 410 policy */ |
| 411 , |
| 412 "" /* expected final referrer */}, |
| 413 |
| 414 // If a redirect serves 'Referrer-Policy: strict-origin', then the |
| 415 // referrer should be the origin only for a cross-origin non-downgrading |
| 416 // redirect, |
| 417 {"https://foo.test/one" /* original url */, |
| 418 "https://foo.test/referrer" /* original referrer */, |
| 419 "Location: https://bar.test/two\n" |
| 420 "Referrer-Policy: strict-origin\n", |
| 421 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 422 URLRequest:: |
| 423 ORIGIN_CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE /* expected final |
| 424 policy */ |
| 425 , |
| 426 "https://foo.test/" /* expected final referrer */}, |
| 427 {"http://foo.test/one" /* original url */, |
| 428 "http://foo.test/referrer" /* original referrer */, |
| 429 "Location: http://bar.test/two\n" |
| 430 "Referrer-Policy: strict-origin\n", |
| 431 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 432 URLRequest:: |
| 433 ORIGIN_CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE /* expected final |
| 434 policy */ |
| 435 , |
| 436 "http://foo.test/" /* expected final referrer */}, |
| 437 |
| 438 // ... but should be cleared for a downgrading redirect. |
| 439 {"https://foo.test/one" /* original url */, |
| 440 "https://foo.test/referrer" /* original referrer */, |
| 441 "Location: http://foo.test/two\n" |
| 442 "Referrer-Policy: strict-origin\n", |
| 443 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 444 URLRequest:: |
| 445 ORIGIN_CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE /* expected final |
| 446 policy */ |
| 447 , |
| 448 "" /* expected final referrer */}, |
| 449 |
| 450 // If a redirect serves 'Referrer-Policy: |
| 451 // strict-origin-when-cross-origin', then the referrer should be preserved |
| 452 // for a same-origin redirect, |
| 453 {"https://foo.test/one" /* original url */, |
| 454 "https://foo.test/referrer" /* original referrer */, |
| 455 "Location: https://foo.test/two\n" |
| 456 "Referrer-Policy: strict-origin-when-cross-origin\n", |
| 457 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 458 URLRequest:: |
| 459 REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN /* expected |
| 460 final |
| 461 policy */ |
| 462 , |
| 463 "https://foo.test/referrer" /* expected final referrer */}, |
| 464 {"http://foo.test/one" /* original url */, |
| 465 "http://foo.test/referrer" /* original referrer */, |
| 466 "Location: http://foo.test/two\n" |
| 467 "Referrer-Policy: strict-origin-when-cross-origin\n", |
| 468 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 469 URLRequest:: |
| 470 REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN /* expected |
| 471 final |
| 472 policy */ |
| 473 , |
| 474 "http://foo.test/referrer" /* expected final referrer */}, |
| 475 |
| 476 // ... but should be stripped to the origin for a cross-origin |
| 477 // non-downgrading redirect, |
| 478 {"https://foo.test/one" /* original url */, |
| 479 "https://foo.test/referrer" /* original referrer */, |
| 480 "Location: https://bar.test/two\n" |
| 481 "Referrer-Policy: strict-origin-when-cross-origin\n", |
| 482 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 483 URLRequest:: |
| 484 REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN /* expected |
| 485 final |
| 486 policy */ |
| 487 , |
| 488 "https://foo.test/" /* expected final referrer */}, |
| 489 {"http://foo.test/one" /* original url */, |
| 490 "http://foo.test/referrer" /* original referrer */, |
| 491 "Location: http://bar.test/two\n" |
| 492 "Referrer-Policy: strict-origin-when-cross-origin\n", |
| 493 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 494 URLRequest:: |
| 495 REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN /* expected |
| 496 final |
| 497 policy */ |
| 498 , |
| 499 "http://foo.test/" /* expected final referrer */}, |
| 500 |
| 501 // ... and should be cleared for a downgrading redirect. |
| 502 {"https://foo.test/one" /* original url */, |
| 503 "https://foo.test/referrer" /* original referrer */, |
| 504 "Location: http://foo.test/two\n" |
| 505 "Referrer-Policy: strict-origin-when-cross-origin\n", |
| 506 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 507 URLRequest:: |
| 508 REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN /* expected |
| 509 final |
| 510 policy */ |
| 511 , |
| 512 "" /* expected final referrer */}, |
| 513 |
391 // If a redirect serves 'Referrer-Policy: unsafe-url', then the | 514 // If a redirect serves 'Referrer-Policy: unsafe-url', then the |
392 // referrer should remain, even if originally set to clear on | 515 // referrer should remain, even if originally set to clear on |
393 // downgrade. | 516 // downgrade. |
394 {"https://foo.test/one" /* original url */, | 517 {"https://foo.test/one" /* original url */, |
395 "https://foo.test/one" /* original referrer */, | 518 "https://foo.test/one" /* original referrer */, |
396 "Location: https://bar.test/two\n" | 519 "Location: https://bar.test/two\n" |
397 "Referrer-Policy: unsafe-url\n", | 520 "Referrer-Policy: unsafe-url\n", |
398 URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN /* original policy */, | 521 URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN /* original policy */, |
399 URLRequest::NEVER_CLEAR_REFERRER /* expected final policy */, | 522 URLRequest::NEVER_CLEAR_REFERRER /* expected final policy */, |
400 "https://foo.test/one" /* expected final referrer */}, | 523 "https://foo.test/one" /* expected final referrer */}, |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 | 743 |
621 EXPECT_FALSE(d.request_failed()); | 744 EXPECT_FALSE(d.request_failed()); |
622 EXPECT_EQ(200, req->GetResponseCode()); | 745 EXPECT_EQ(200, req->GetResponseCode()); |
623 EXPECT_EQ(kHelloData, d.data_received()); | 746 EXPECT_EQ(kHelloData, d.data_received()); |
624 EXPECT_TRUE(network_layer.done_reading_called()); | 747 EXPECT_TRUE(network_layer.done_reading_called()); |
625 | 748 |
626 RemoveMockTransaction(&kBrotli_Slow_Transaction); | 749 RemoveMockTransaction(&kBrotli_Slow_Transaction); |
627 } | 750 } |
628 | 751 |
629 } // namespace net | 752 } // namespace net |
OLD | NEW |