| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015, Google Inc. All rights reserved. | 2 * Copyright (c) 2015, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 request, Resource::MainResource, FetchRequest::NoDefer)); | 490 request, Resource::MainResource, FetchRequest::NoDefer)); |
| 491 | 491 |
| 492 // Post | 492 // Post |
| 493 ResourceRequest postRequest("http://www.example.com"); | 493 ResourceRequest postRequest("http://www.example.com"); |
| 494 postRequest.setHTTPMethod("POST"); | 494 postRequest.setHTTPMethod("POST"); |
| 495 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, | 495 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, |
| 496 fetchContext->resourceRequestCachePolicy( | 496 fetchContext->resourceRequestCachePolicy( |
| 497 postRequest, Resource::MainResource, FetchRequest::NoDefer)); | 497 postRequest, Resource::MainResource, FetchRequest::NoDefer)); |
| 498 | 498 |
| 499 // Re-post | 499 // Re-post |
| 500 document->frame()->loader().setLoadType(FrameLoadTypeBackForward); | 500 document->loader()->setLoadType(FrameLoadTypeBackForward); |
| 501 EXPECT_EQ(WebCachePolicy::ReturnCacheDataDontLoad, | 501 EXPECT_EQ(WebCachePolicy::ReturnCacheDataDontLoad, |
| 502 fetchContext->resourceRequestCachePolicy( | 502 fetchContext->resourceRequestCachePolicy( |
| 503 postRequest, Resource::MainResource, FetchRequest::NoDefer)); | 503 postRequest, Resource::MainResource, FetchRequest::NoDefer)); |
| 504 | 504 |
| 505 // FrameLoadTypeReloadMainResource | 505 // FrameLoadTypeReloadMainResource |
| 506 document->frame()->loader().setLoadType(FrameLoadTypeReloadMainResource); | 506 document->loader()->setLoadType(FrameLoadTypeReloadMainResource); |
| 507 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, | 507 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, |
| 508 fetchContext->resourceRequestCachePolicy( | 508 fetchContext->resourceRequestCachePolicy( |
| 509 request, Resource::MainResource, FetchRequest::NoDefer)); | 509 request, Resource::MainResource, FetchRequest::NoDefer)); |
| 510 | 510 |
| 511 // Conditional request | 511 // Conditional request |
| 512 document->frame()->loader().setLoadType(FrameLoadTypeStandard); | 512 document->loader()->setLoadType(FrameLoadTypeStandard); |
| 513 ResourceRequest conditional("http://www.example.com"); | 513 ResourceRequest conditional("http://www.example.com"); |
| 514 conditional.setHTTPHeaderField(HTTPNames::If_Modified_Since, "foo"); | 514 conditional.setHTTPHeaderField(HTTPNames::If_Modified_Since, "foo"); |
| 515 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, | 515 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, |
| 516 fetchContext->resourceRequestCachePolicy( | 516 fetchContext->resourceRequestCachePolicy( |
| 517 conditional, Resource::MainResource, FetchRequest::NoDefer)); | 517 conditional, Resource::MainResource, FetchRequest::NoDefer)); |
| 518 | 518 |
| 519 // Set up a child frame | 519 // Set up a child frame |
| 520 FrameFetchContext* childFetchContext = createChildFrame(); | 520 FrameFetchContext* childFetchContext = createChildFrame(); |
| 521 | 521 |
| 522 // Child frame as part of back/forward | 522 // Child frame as part of back/forward |
| 523 document->frame()->loader().setLoadType(FrameLoadTypeBackForward); | 523 document->loader()->setLoadType(FrameLoadTypeBackForward); |
| 524 EXPECT_EQ(WebCachePolicy::ReturnCacheDataElseLoad, | 524 EXPECT_EQ(WebCachePolicy::ReturnCacheDataElseLoad, |
| 525 childFetchContext->resourceRequestCachePolicy( | 525 childFetchContext->resourceRequestCachePolicy( |
| 526 request, Resource::MainResource, FetchRequest::NoDefer)); | 526 request, Resource::MainResource, FetchRequest::NoDefer)); |
| 527 | 527 |
| 528 // Child frame as part of reload | 528 // Child frame as part of reload |
| 529 document->frame()->loader().setLoadType(FrameLoadTypeReload); | 529 document->loader()->setLoadType(FrameLoadTypeReload); |
| 530 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, | 530 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, |
| 531 childFetchContext->resourceRequestCachePolicy( | 531 childFetchContext->resourceRequestCachePolicy( |
| 532 request, Resource::MainResource, FetchRequest::NoDefer)); | 532 request, Resource::MainResource, FetchRequest::NoDefer)); |
| 533 | 533 |
| 534 // Child frame as part of reload bypassing cache | 534 // Child frame as part of reload bypassing cache |
| 535 document->frame()->loader().setLoadType(FrameLoadTypeReloadBypassingCache); | 535 document->loader()->setLoadType(FrameLoadTypeReloadBypassingCache); |
| 536 EXPECT_EQ(WebCachePolicy::BypassingCache, | 536 EXPECT_EQ(WebCachePolicy::BypassingCache, |
| 537 childFetchContext->resourceRequestCachePolicy( | 537 childFetchContext->resourceRequestCachePolicy( |
| 538 request, Resource::MainResource, FetchRequest::NoDefer)); | 538 request, Resource::MainResource, FetchRequest::NoDefer)); |
| 539 } | 539 } |
| 540 | 540 |
| 541 TEST_F(FrameFetchContextTest, SetFirstPartyCookieAndRequestorOrigin) { | 541 TEST_F(FrameFetchContextTest, SetFirstPartyCookieAndRequestorOrigin) { |
| 542 struct TestCase { | 542 struct TestCase { |
| 543 const char* documentURL; | 543 const char* documentURL; |
| 544 bool documentSandboxed; | 544 bool documentSandboxed; |
| 545 const char* requestorOrigin; // "" => unique origin | 545 const char* requestorOrigin; // "" => unique origin |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource); | 803 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource); |
| 804 EXPECT_EQ(test.isExternalExpectation, mainRequest.isExternalRequest()); | 804 EXPECT_EQ(test.isExternalExpectation, mainRequest.isExternalRequest()); |
| 805 | 805 |
| 806 ResourceRequest subRequest(test.url); | 806 ResourceRequest subRequest(test.url); |
| 807 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); | 807 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); |
| 808 EXPECT_EQ(test.isExternalExpectation, subRequest.isExternalRequest()); | 808 EXPECT_EQ(test.isExternalExpectation, subRequest.isExternalRequest()); |
| 809 } | 809 } |
| 810 } | 810 } |
| 811 | 811 |
| 812 } // namespace blink | 812 } // namespace blink |
| OLD | NEW |