OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, 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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); | 654 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); |
655 EXPECT_TRUE(memoryCache()->contains(resource)); | 655 EXPECT_TRUE(memoryCache()->contains(resource)); |
656 EXPECT_TRUE(resource->isPreloaded()); | 656 EXPECT_TRUE(resource->isPreloaded()); |
657 | 657 |
658 // DCL reached on second fetcher | 658 // DCL reached on second fetcher |
659 fetcher2->clearPreloads(ResourceFetcher::ClearSpeculativeMarkupPreloads); | 659 fetcher2->clearPreloads(ResourceFetcher::ClearSpeculativeMarkupPreloads); |
660 EXPECT_TRUE(memoryCache()->contains(resource)); | 660 EXPECT_TRUE(memoryCache()->contains(resource)); |
661 EXPECT_FALSE(resource->isPreloaded()); | 661 EXPECT_FALSE(resource->isPreloaded()); |
662 } | 662 } |
663 | 663 |
| 664 TEST_F(ResourceFetcherTest, Revalidate304) |
| 665 { |
| 666 KURL url(ParsedURLString, "http://127.0.0.1:8000/foo.html"); |
| 667 Resource* resource = Resource::create(url, Resource::Raw); |
| 668 memoryCache()->add(resource); |
| 669 ResourceResponse response; |
| 670 response.setURL(url); |
| 671 response.setHTTPStatusCode(304); |
| 672 response.setHTTPHeaderField("etag", "1234567890"); |
| 673 resource->responseReceived(response, nullptr); |
| 674 resource->finish(); |
| 675 |
| 676 ResourceFetcher* fetcher = ResourceFetcher::create(ResourceFetcherTestMockFe
tchContext::create()); |
| 677 FetchRequest fetchRequest = FetchRequest(url, FetchInitiatorInfo()); |
| 678 Platform::current()->getURLLoaderMockFactory()->registerURL(url, WebURLRespo
nse(), ""); |
| 679 Resource* newResource = fetcher->requestResource(fetchRequest, TestResourceF
actory(Resource::Raw)); |
| 680 fetcher->stopFetching(); |
| 681 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); |
| 682 |
| 683 EXPECT_NE(resource, newResource); |
| 684 } |
| 685 |
664 } // namespace blink | 686 } // namespace blink |
OLD | NEW |