| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 Resource* create(const ResourceRequest& request, const ResourceLoaderOptions
& options, const String& charset) const override | 111 Resource* create(const ResourceRequest& request, const ResourceLoaderOptions
& options, const String& charset) const override |
| 112 { | 112 { |
| 113 return Resource::create(request, type(), options); | 113 return Resource::create(request, type(), options); |
| 114 } | 114 } |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 TEST_F(ResourceFetcherTest, StartLoadAfterFrameDetach) | 117 TEST_F(ResourceFetcherTest, StartLoadAfterFrameDetach) |
| 118 { | 118 { |
| 119 KURL secureURL(ParsedURLString, "https://secureorigin.test/image.png"); | 119 KURL secureURL(ParsedURLString, "https://secureorigin.test/image.png"); |
| 120 // Try to request a url. The request should fail, no resource should be retu
rned, | 120 // Try to request a url. The request should fail, and a resource in an error
state |
| 121 // and no resource should be present in the cache. | 121 // should be returned, and no resource should be present in the cache. |
| 122 ResourceFetcher* fetcher = ResourceFetcher::create(nullptr); | 122 ResourceFetcher* fetcher = ResourceFetcher::create(nullptr); |
| 123 FetchRequest fetchRequest = FetchRequest(ResourceRequest(secureURL), FetchIn
itiatorInfo()); | 123 FetchRequest fetchRequest = FetchRequest(ResourceRequest(secureURL), FetchIn
itiatorInfo()); |
| 124 Resource* resource = fetcher->requestResource(fetchRequest, TestResourceFact
ory()); | 124 Resource* resource = fetcher->requestResource(fetchRequest, TestResourceFact
ory()); |
| 125 EXPECT_FALSE(resource); | 125 ASSERT_TRUE(resource); |
| 126 EXPECT_TRUE(resource->errorOccurred()); |
| 127 EXPECT_TRUE(resource->resourceError().isAccessCheck()); |
| 126 EXPECT_FALSE(memoryCache()->resourceForURL(secureURL)); | 128 EXPECT_FALSE(memoryCache()->resourceForURL(secureURL)); |
| 127 | 129 |
| 128 // Start by calling startLoad() directly, rather than via requestResource(). | 130 // Start by calling startLoad() directly, rather than via requestResource(). |
| 129 // This shouldn't crash. | 131 // This shouldn't crash. |
| 130 fetcher->startLoad(Resource::create(secureURL, Resource::Raw)); | 132 fetcher->startLoad(Resource::create(secureURL, Resource::Raw)); |
| 131 } | 133 } |
| 132 | 134 |
| 133 TEST_F(ResourceFetcherTest, UseExistingResource) | 135 TEST_F(ResourceFetcherTest, UseExistingResource) |
| 134 { | 136 { |
| 135 ResourceFetcher* fetcher = ResourceFetcher::create(ResourceFetcherTestMockFe
tchContext::create()); | 137 ResourceFetcher* fetcher = ResourceFetcher::create(ResourceFetcherTestMockFe
tchContext::create()); |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 FetchRequest fetchRequest = FetchRequest(url, FetchInitiatorInfo()); | 679 FetchRequest fetchRequest = FetchRequest(url, FetchInitiatorInfo()); |
| 678 Platform::current()->getURLLoaderMockFactory()->registerURL(url, WebURLRespo
nse(), ""); | 680 Platform::current()->getURLLoaderMockFactory()->registerURL(url, WebURLRespo
nse(), ""); |
| 679 Resource* newResource = fetcher->requestResource(fetchRequest, TestResourceF
actory(Resource::Raw)); | 681 Resource* newResource = fetcher->requestResource(fetchRequest, TestResourceF
actory(Resource::Raw)); |
| 680 fetcher->stopFetching(); | 682 fetcher->stopFetching(); |
| 681 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); | 683 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); |
| 682 | 684 |
| 683 EXPECT_NE(resource, newResource); | 685 EXPECT_NE(resource, newResource); |
| 684 } | 686 } |
| 685 | 687 |
| 686 } // namespace blink | 688 } // namespace blink |
| OLD | NEW |