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 /* final policy */ |
| 399 , |
| 400 "https://foo.test/referrer" /* expected final referrer */}, |
| 401 |
| 402 // ... but should be cleared for a cross-origin redirect. |
| 403 {"https://foo.test/one" /* original url */, |
| 404 "https://foo.test/referrer" /* original referrer */, |
| 405 "Location: https://bar.test/two\n" |
| 406 "Referrer-Policy: same-origin\n", |
| 407 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 408 URLRequest::CLEAR_REFERRER_ON_TRANSITION_CROSS_ORIGIN, |
| 409 "" /* expected final referrer */}, |
| 410 |
| 411 // If a redirect serves 'Referrer-Policy: strict-origin', then the |
| 412 // referrer should be the origin only for a cross-origin non-downgrading |
| 413 // redirect, |
| 414 {"https://foo.test/one" /* original url */, |
| 415 "https://foo.test/referrer" /* original referrer */, |
| 416 "Location: https://bar.test/two\n" |
| 417 "Referrer-Policy: strict-origin\n", |
| 418 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 419 URLRequest::ORIGIN_CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE, |
| 420 "https://foo.test/" /* expected final referrer */}, |
| 421 {"http://foo.test/one" /* original url */, |
| 422 "http://foo.test/referrer" /* original referrer */, |
| 423 "Location: http://bar.test/two\n" |
| 424 "Referrer-Policy: strict-origin\n", |
| 425 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 426 URLRequest::ORIGIN_CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE, |
| 427 "http://foo.test/" /* expected final referrer */}, |
| 428 |
| 429 // ... but should be cleared for a downgrading redirect. |
| 430 {"https://foo.test/one" /* original url */, |
| 431 "https://foo.test/referrer" /* original referrer */, |
| 432 "Location: http://foo.test/two\n" |
| 433 "Referrer-Policy: strict-origin\n", |
| 434 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 435 URLRequest::ORIGIN_CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE, |
| 436 "" /* expected final referrer */}, |
| 437 |
| 438 // If a redirect serves 'Referrer-Policy: |
| 439 // strict-origin-when-cross-origin', then the referrer should be preserved |
| 440 // for a same-origin redirect, |
| 441 {"https://foo.test/one" /* original url */, |
| 442 "https://foo.test/referrer" /* original referrer */, |
| 443 "Location: https://foo.test/two\n" |
| 444 "Referrer-Policy: strict-origin-when-cross-origin\n", |
| 445 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 446 URLRequest::REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN, |
| 447 "https://foo.test/referrer" /* expected final referrer */}, |
| 448 {"http://foo.test/one" /* original url */, |
| 449 "http://foo.test/referrer" /* original referrer */, |
| 450 "Location: http://foo.test/two\n" |
| 451 "Referrer-Policy: strict-origin-when-cross-origin\n", |
| 452 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 453 URLRequest::REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN, |
| 454 "http://foo.test/referrer" /* expected final referrer */}, |
| 455 |
| 456 // ... but should be stripped to the origin for a cross-origin |
| 457 // non-downgrading redirect, |
| 458 {"https://foo.test/one" /* original url */, |
| 459 "https://foo.test/referrer" /* original referrer */, |
| 460 "Location: https://bar.test/two\n" |
| 461 "Referrer-Policy: strict-origin-when-cross-origin\n", |
| 462 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 463 URLRequest::REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN, |
| 464 "https://foo.test/" /* expected final referrer */}, |
| 465 {"http://foo.test/one" /* original url */, |
| 466 "http://foo.test/referrer" /* original referrer */, |
| 467 "Location: http://bar.test/two\n" |
| 468 "Referrer-Policy: strict-origin-when-cross-origin\n", |
| 469 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 470 URLRequest::REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN, |
| 471 "http://foo.test/" /* expected final referrer */}, |
| 472 |
| 473 // ... and should be cleared for a downgrading redirect. |
| 474 {"https://foo.test/one" /* original url */, |
| 475 "https://foo.test/referrer" /* original referrer */, |
| 476 "Location: http://foo.test/two\n" |
| 477 "Referrer-Policy: strict-origin-when-cross-origin\n", |
| 478 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 479 URLRequest::REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN, |
| 480 "" /* expected final referrer */}, |
| 481 |
391 // If a redirect serves 'Referrer-Policy: unsafe-url', then the | 482 // If a redirect serves 'Referrer-Policy: unsafe-url', then the |
392 // referrer should remain, even if originally set to clear on | 483 // referrer should remain, even if originally set to clear on |
393 // downgrade. | 484 // downgrade. |
394 {"https://foo.test/one" /* original url */, | 485 {"https://foo.test/one" /* original url */, |
395 "https://foo.test/one" /* original referrer */, | 486 "https://foo.test/one" /* original referrer */, |
396 "Location: https://bar.test/two\n" | 487 "Location: https://bar.test/two\n" |
397 "Referrer-Policy: unsafe-url\n", | 488 "Referrer-Policy: unsafe-url\n", |
398 URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN /* original policy */, | 489 URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN /* original policy */, |
399 URLRequest::NEVER_CLEAR_REFERRER /* expected final policy */, | 490 URLRequest::NEVER_CLEAR_REFERRER /* expected final policy */, |
400 "https://foo.test/one" /* expected final referrer */}, | 491 "https://foo.test/one" /* expected final referrer */}, |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 | 711 |
621 EXPECT_FALSE(d.request_failed()); | 712 EXPECT_FALSE(d.request_failed()); |
622 EXPECT_EQ(200, req->GetResponseCode()); | 713 EXPECT_EQ(200, req->GetResponseCode()); |
623 EXPECT_EQ(kHelloData, d.data_received()); | 714 EXPECT_EQ(kHelloData, d.data_received()); |
624 EXPECT_TRUE(network_layer.done_reading_called()); | 715 EXPECT_TRUE(network_layer.done_reading_called()); |
625 | 716 |
626 RemoveMockTransaction(&kBrotli_Slow_Transaction); | 717 RemoveMockTransaction(&kBrotli_Slow_Transaction); |
627 } | 718 } |
628 | 719 |
629 } // namespace net | 720 } // namespace net |
OLD | NEW |