| 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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 549 | 549 | 
| 550 TEST_F(FrameFetchContextTest, MainResource) { | 550 TEST_F(FrameFetchContextTest, MainResource) { | 
| 551   // Default case | 551   // Default case | 
| 552   ResourceRequest request("http://www.example.com"); | 552   ResourceRequest request("http://www.example.com"); | 
| 553   EXPECT_EQ(WebCachePolicy::UseProtocolCachePolicy, | 553   EXPECT_EQ(WebCachePolicy::UseProtocolCachePolicy, | 
| 554             fetchContext->resourceRequestCachePolicy( | 554             fetchContext->resourceRequestCachePolicy( | 
| 555                 request, Resource::MainResource, FetchRequest::NoDefer)); | 555                 request, Resource::MainResource, FetchRequest::NoDefer)); | 
| 556 | 556 | 
| 557   // Post | 557   // Post | 
| 558   ResourceRequest postRequest("http://www.example.com"); | 558   ResourceRequest postRequest("http://www.example.com"); | 
| 559   postRequest.setHTTPMethod("POST"); | 559   postRequest.setHTTPMethod(HTTPNames::POST); | 
| 560   EXPECT_EQ(WebCachePolicy::ValidatingCacheData, | 560   EXPECT_EQ(WebCachePolicy::ValidatingCacheData, | 
| 561             fetchContext->resourceRequestCachePolicy( | 561             fetchContext->resourceRequestCachePolicy( | 
| 562                 postRequest, Resource::MainResource, FetchRequest::NoDefer)); | 562                 postRequest, Resource::MainResource, FetchRequest::NoDefer)); | 
| 563 | 563 | 
| 564   // Re-post | 564   // Re-post | 
| 565   document->loader()->setLoadType(FrameLoadTypeBackForward); | 565   document->loader()->setLoadType(FrameLoadTypeBackForward); | 
| 566   EXPECT_EQ(WebCachePolicy::ReturnCacheDataDontLoad, | 566   EXPECT_EQ(WebCachePolicy::ReturnCacheDataDontLoad, | 
| 567             fetchContext->resourceRequestCachePolicy( | 567             fetchContext->resourceRequestCachePolicy( | 
| 568                 postRequest, Resource::MainResource, FetchRequest::NoDefer)); | 568                 postRequest, Resource::MainResource, FetchRequest::NoDefer)); | 
| 569 | 569 | 
| 570   // FrameLoadTypeReload | 570   // FrameLoadTypeReload | 
| 571   document->loader()->setLoadType(FrameLoadTypeReload); | 571   document->loader()->setLoadType(FrameLoadTypeReload); | 
| 572   EXPECT_EQ(WebCachePolicy::ValidatingCacheData, | 572   EXPECT_EQ(WebCachePolicy::ValidatingCacheData, | 
| 573             fetchContext->resourceRequestCachePolicy( | 573             fetchContext->resourceRequestCachePolicy( | 
| 574                 request, Resource::MainResource, FetchRequest::NoDefer)); | 574                 request, Resource::MainResource, FetchRequest::NoDefer)); | 
| 575 | 575 | 
| 576   // Conditional request | 576   // Conditional request | 
| 577   document->loader()->setLoadType(FrameLoadTypeStandard); | 577   document->loader()->setLoadType(FrameLoadTypeStandard); | 
| 578   ResourceRequest conditional("http://www.example.com"); | 578   ResourceRequest conditional("http://www.example.com"); | 
| 579   conditional.setHTTPHeaderField(HTTPNames::If_Modified_Since, "foo"); | 579   conditional.setHTTPHeaderField(HTTPNames::If_Modified_Since, "foo"); | 
| 580   EXPECT_EQ(WebCachePolicy::ValidatingCacheData, | 580   EXPECT_EQ(WebCachePolicy::ValidatingCacheData, | 
| 581             fetchContext->resourceRequestCachePolicy( | 581             fetchContext->resourceRequestCachePolicy( | 
| 582                 conditional, Resource::MainResource, FetchRequest::NoDefer)); | 582                 conditional, Resource::MainResource, FetchRequest::NoDefer)); | 
| 583 | 583 | 
|  | 584   // FrameLoadTypeReloadBypassingCache | 
|  | 585   document->loader()->setLoadType(FrameLoadTypeReloadBypassingCache); | 
|  | 586   EXPECT_EQ(WebCachePolicy::BypassingCache, | 
|  | 587             fetchContext->resourceRequestCachePolicy( | 
|  | 588                 request, Resource::MainResource, FetchRequest::NoDefer)); | 
|  | 589 | 
|  | 590   // FrameLoadTypeReloadBypassingCache with a conditional request | 
|  | 591   document->loader()->setLoadType(FrameLoadTypeReloadBypassingCache); | 
|  | 592   EXPECT_EQ(WebCachePolicy::BypassingCache, | 
|  | 593             fetchContext->resourceRequestCachePolicy( | 
|  | 594                 conditional, Resource::MainResource, FetchRequest::NoDefer)); | 
|  | 595 | 
|  | 596   // FrameLoadTypeReloadBypassingCache with a post request | 
|  | 597   document->loader()->setLoadType(FrameLoadTypeReloadBypassingCache); | 
|  | 598   EXPECT_EQ(WebCachePolicy::BypassingCache, | 
|  | 599             fetchContext->resourceRequestCachePolicy( | 
|  | 600                 postRequest, Resource::MainResource, FetchRequest::NoDefer)); | 
|  | 601 | 
| 584   // Set up a child frame | 602   // Set up a child frame | 
| 585   FrameFetchContext* childFetchContext = createChildFrame(); | 603   FrameFetchContext* childFetchContext = createChildFrame(); | 
| 586 | 604 | 
| 587   // Child frame as part of back/forward | 605   // Child frame as part of back/forward | 
| 588   document->loader()->setLoadType(FrameLoadTypeBackForward); | 606   document->loader()->setLoadType(FrameLoadTypeBackForward); | 
| 589   EXPECT_EQ(WebCachePolicy::ReturnCacheDataElseLoad, | 607   EXPECT_EQ(WebCachePolicy::ReturnCacheDataElseLoad, | 
| 590             childFetchContext->resourceRequestCachePolicy( | 608             childFetchContext->resourceRequestCachePolicy( | 
| 591                 request, Resource::MainResource, FetchRequest::NoDefer)); | 609                 request, Resource::MainResource, FetchRequest::NoDefer)); | 
| 592 | 610 | 
| 593   // Child frame as part of reload | 611   // Child frame as part of reload | 
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 940   setFilterPolicy(WebDocumentSubresourceFilter::kWouldDisallow); | 958   setFilterPolicy(WebDocumentSubresourceFilter::kWouldDisallow); | 
| 941 | 959 | 
| 942   EXPECT_EQ(ResourceRequestBlockedReason::None, canRequest()); | 960   EXPECT_EQ(ResourceRequestBlockedReason::None, canRequest()); | 
| 943   EXPECT_EQ(0, getFilteredLoadCallCount()); | 961   EXPECT_EQ(0, getFilteredLoadCallCount()); | 
| 944 | 962 | 
| 945   EXPECT_EQ(ResourceRequestBlockedReason::None, canRequestPreload()); | 963   EXPECT_EQ(ResourceRequestBlockedReason::None, canRequestPreload()); | 
| 946   EXPECT_EQ(0, getFilteredLoadCallCount()); | 964   EXPECT_EQ(0, getFilteredLoadCallCount()); | 
| 947 } | 965 } | 
| 948 | 966 | 
| 949 }  // namespace blink | 967 }  // namespace blink | 
| OLD | NEW | 
|---|