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 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); | 633 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); |
634 EXPECT_TRUE(memoryCache()->contains(resource)); | 634 EXPECT_TRUE(memoryCache()->contains(resource)); |
635 EXPECT_TRUE(resource->isPreloaded()); | 635 EXPECT_TRUE(resource->isPreloaded()); |
636 | 636 |
637 // DCL reached on second fetcher | 637 // DCL reached on second fetcher |
638 fetcher2->clearPreloads(ResourceFetcher::ClearSpeculativeMarkupPreloads); | 638 fetcher2->clearPreloads(ResourceFetcher::ClearSpeculativeMarkupPreloads); |
639 EXPECT_TRUE(memoryCache()->contains(resource)); | 639 EXPECT_TRUE(memoryCache()->contains(resource)); |
640 EXPECT_FALSE(resource->isPreloaded()); | 640 EXPECT_FALSE(resource->isPreloaded()); |
641 } | 641 } |
642 | 642 |
| 643 TEST_F(ResourceFetcherTest, Revalidate304) |
| 644 { |
| 645 KURL url(ParsedURLString, "http://127.0.0.1:8000/foo.html"); |
| 646 Resource* resource = Resource::create(url, Resource::Raw); |
| 647 memoryCache()->add(resource); |
| 648 ResourceResponse response; |
| 649 response.setURL(url); |
| 650 response.setHTTPStatusCode(304); |
| 651 response.setHTTPHeaderField("etag", "1234567890"); |
| 652 resource->responseReceived(response, nullptr); |
| 653 resource->finish(); |
| 654 |
| 655 ResourceFetcher* fetcher = ResourceFetcher::create(ResourceFetcherTestMockFe
tchContext::create()); |
| 656 FetchRequest fetchRequest = FetchRequest(url, FetchInitiatorInfo()); |
| 657 Platform::current()->getURLLoaderMockFactory()->registerURL(url, WebURLRespo
nse(), ""); |
| 658 Resource* newResource = fetcher->requestResource(fetchRequest, TestResourceF
actory(Resource::Raw)); |
| 659 fetcher->stopFetching(); |
| 660 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); |
| 661 |
| 662 EXPECT_NE(resource, newResource); |
| 663 } |
| 664 |
643 } // namespace blink | 665 } // namespace blink |
OLD | NEW |