| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 // should be cleared. | 264 // should be cleared. |
| 265 {"http://foo.test/one" /* original url */, | 265 {"http://foo.test/one" /* original url */, |
| 266 "http://foo.test/one" /* original referrer */, | 266 "http://foo.test/one" /* original referrer */, |
| 267 "Location: http://foo.test/test\n" | 267 "Location: http://foo.test/test\n" |
| 268 "Referrer-Policy: no-referrer\n", | 268 "Referrer-Policy: no-referrer\n", |
| 269 // original policy | 269 // original policy |
| 270 URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, | 270 URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, |
| 271 URLRequest::NO_REFERRER /* expected final policy */, | 271 URLRequest::NO_REFERRER /* expected final policy */, |
| 272 "" /* expected final referrer */}, | 272 "" /* expected final referrer */}, |
| 273 | 273 |
| 274 // Same as above but for the legacy keyword 'never'. | 274 // Same as above but for the legacy keyword 'never', which should |
| 275 // not be supported. |
| 275 {"http://foo.test/one" /* original url */, | 276 {"http://foo.test/one" /* original url */, |
| 276 "http://foo.test/one" /* original referrer */, | 277 "http://foo.test/one" /* original referrer */, |
| 277 "Location: http://foo.test/test\nReferrer-Policy: never\n", | 278 "Location: http://foo.test/test\nReferrer-Policy: never\n", |
| 278 // original policy | 279 // original policy |
| 279 URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, | 280 URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, |
| 280 URLRequest::NO_REFERRER /* expected final policy */, | 281 // expected final policy |
| 281 "" /* expected final referrer */}, | 282 URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, |
| 283 "http://foo.test/one" /* expected final referrer */}, |
| 282 | 284 |
| 283 // If a redirect serves 'Referrer-Policy: | 285 // If a redirect serves 'Referrer-Policy: |
| 284 // no-referrer-when-downgrade', then the referrer should be cleared | 286 // no-referrer-when-downgrade', then the referrer should be cleared |
| 285 // on downgrade, even if the original request's policy specified | 287 // on downgrade, even if the original request's policy specified |
| 286 // that the referrer should never be cleared. | 288 // that the referrer should never be cleared. |
| 287 {"https://foo.test/one" /* original url */, | 289 {"https://foo.test/one" /* original url */, |
| 288 "https://foo.test/one" /* original referrer */, | 290 "https://foo.test/one" /* original referrer */, |
| 289 "Location: http://foo.test\n" | 291 "Location: http://foo.test\n" |
| 290 "Referrer-Policy: no-referrer-when-downgrade\n", | 292 "Referrer-Policy: no-referrer-when-downgrade\n", |
| 291 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, | 293 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 292 // expected final policy | 294 // expected final policy |
| 293 URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, | 295 URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, |
| 294 "" /* expected final referrer */}, | 296 "" /* expected final referrer */}, |
| 295 | 297 |
| 296 // Same as above but for the legacy keyword 'default'. | 298 // Same as above but for the legacy keyword 'default', which |
| 299 // should not be supported. |
| 297 {"https://foo.test/one" /* original url */, | 300 {"https://foo.test/one" /* original url */, |
| 298 "https://foo.test/one" /* original referrer */, | 301 "https://foo.test/one" /* original referrer */, |
| 299 "Location: http://foo.test\n" | 302 "Location: http://foo.test\n" |
| 300 "Referrer-Policy: default\n", | 303 "Referrer-Policy: default\n", |
| 301 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, | 304 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 302 // expected final policy | 305 // expected final policy |
| 303 URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, | 306 URLRequest::NEVER_CLEAR_REFERRER, |
| 304 "" /* expected final referrer */}, | 307 "https://foo.test/one" /* expected final referrer */}, |
| 305 | 308 |
| 306 // If a redirect serves 'Referrer-Policy: origin', then the referrer | 309 // If a redirect serves 'Referrer-Policy: origin', then the referrer |
| 307 // should be stripped to its origin, even if the original request's | 310 // should be stripped to its origin, even if the original request's |
| 308 // policy specified that the referrer should never be cleared. | 311 // policy specified that the referrer should never be cleared. |
| 309 {"https://foo.test/one" /* original url */, | 312 {"https://foo.test/one" /* original url */, |
| 310 "https://foo.test/one" /* original referrer */, | 313 "https://foo.test/one" /* original referrer */, |
| 311 "Location: https://foo.test/two\n" | 314 "Location: https://foo.test/two\n" |
| 312 "Referrer-Policy: origin\n", | 315 "Referrer-Policy: origin\n", |
| 313 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, | 316 URLRequest::NEVER_CLEAR_REFERRER /* original policy */, |
| 314 URLRequest::ORIGIN /* expected final policy */, | 317 URLRequest::ORIGIN /* expected final policy */, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 339 // referrer should remain, even if originally set to clear on | 342 // referrer should remain, even if originally set to clear on |
| 340 // downgrade. | 343 // downgrade. |
| 341 {"https://foo.test/one" /* original url */, | 344 {"https://foo.test/one" /* original url */, |
| 342 "https://foo.test/one" /* original referrer */, | 345 "https://foo.test/one" /* original referrer */, |
| 343 "Location: https://bar.test/two\n" | 346 "Location: https://bar.test/two\n" |
| 344 "Referrer-Policy: unsafe-url\n", | 347 "Referrer-Policy: unsafe-url\n", |
| 345 URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN /* original policy */, | 348 URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN /* original policy */, |
| 346 URLRequest::NEVER_CLEAR_REFERRER /* expected final policy */, | 349 URLRequest::NEVER_CLEAR_REFERRER /* expected final policy */, |
| 347 "https://foo.test/one" /* expected final referrer */}, | 350 "https://foo.test/one" /* expected final referrer */}, |
| 348 | 351 |
| 349 // Same as above but for the legacy keyword 'always'. | 352 // Same as above but for the legacy keyword 'always', which should |
| 353 // not be supported. |
| 350 {"https://foo.test/one" /* original url */, | 354 {"https://foo.test/one" /* original url */, |
| 351 "https://foo.test/one" /* original referrer */, | 355 "https://foo.test/one" /* original referrer */, |
| 352 "Location: https://bar.test/two\n" | 356 "Location: https://bar.test/two\n" |
| 353 "Referrer-Policy: always\n", | 357 "Referrer-Policy: always\n", |
| 354 URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN /* original policy */, | 358 URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN /* original policy */, |
| 355 URLRequest::NEVER_CLEAR_REFERRER /* expected final policy */, | 359 URLRequest:: |
| 356 "https://foo.test/one" /* expected final referrer */}, | 360 ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN /* expected final policy */, |
| 361 "https://foo.test/" /* expected final referrer */}, |
| 357 | 362 |
| 358 // An invalid keyword should leave the policy untouched. | 363 // An invalid keyword should leave the policy untouched. |
| 359 {"https://foo.test/one" /* original url */, | 364 {"https://foo.test/one" /* original url */, |
| 360 "https://foo.test/one" /* original referrer */, | 365 "https://foo.test/one" /* original referrer */, |
| 361 "Location: https://bar.test/two\n" | 366 "Location: https://bar.test/two\n" |
| 362 "Referrer-Policy: not-a-valid-policy\n", | 367 "Referrer-Policy: not-a-valid-policy\n", |
| 363 URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN /* original policy */, | 368 URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN /* original policy */, |
| 364 URLRequest:: | 369 URLRequest:: |
| 365 ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN /* expected final policy */, | 370 ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN /* expected final policy */, |
| 366 "https://foo.test/" /* expected final referrer */}, | 371 "https://foo.test/" /* expected final referrer */}, |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 | 565 |
| 561 EXPECT_FALSE(d.request_failed()); | 566 EXPECT_FALSE(d.request_failed()); |
| 562 EXPECT_EQ(200, req->GetResponseCode()); | 567 EXPECT_EQ(200, req->GetResponseCode()); |
| 563 EXPECT_EQ(kBrotliDecodedHelloData, d.data_received()); | 568 EXPECT_EQ(kBrotliDecodedHelloData, d.data_received()); |
| 564 EXPECT_TRUE(network_layer.done_reading_called()); | 569 EXPECT_TRUE(network_layer.done_reading_called()); |
| 565 | 570 |
| 566 RemoveMockTransaction(&kBrotli_Slow_Transaction); | 571 RemoveMockTransaction(&kBrotli_Slow_Transaction); |
| 567 } | 572 } |
| 568 | 573 |
| 569 } // namespace net | 574 } // namespace net |
| OLD | NEW |