| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 Resource* create(const ResourceRequest& request, | 120 Resource* create(const ResourceRequest& request, |
| 121 const ResourceLoaderOptions& options, | 121 const ResourceLoaderOptions& options, |
| 122 const String& charset) const override { | 122 const String& charset) const override { |
| 123 return Resource::create(request, type(), options); | 123 return Resource::create(request, type(), options); |
| 124 } | 124 } |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 TEST_F(ResourceFetcherTest, StartLoadAfterFrameDetach) { | 127 TEST_F(ResourceFetcherTest, StartLoadAfterFrameDetach) { |
| 128 KURL secureURL(ParsedURLString, "https://secureorigin.test/image.png"); | 128 KURL secureURL(ParsedURLString, "https://secureorigin.test/image.png"); |
| 129 // Try to request a url. The request should fail, and a resource in an error | 129 // Try to request a url. The request should fail, no resource should be |
| 130 // state should be returned, and no resource should be present in the cache. | 130 // returned, and no resource should be present in the cache. |
| 131 ResourceFetcher* fetcher = ResourceFetcher::create(nullptr); | 131 ResourceFetcher* fetcher = ResourceFetcher::create(nullptr); |
| 132 FetchRequest fetchRequest = | 132 FetchRequest fetchRequest = |
| 133 FetchRequest(ResourceRequest(secureURL), FetchInitiatorInfo()); | 133 FetchRequest(ResourceRequest(secureURL), FetchInitiatorInfo()); |
| 134 Resource* resource = | 134 Resource* resource = |
| 135 fetcher->requestResource(fetchRequest, TestResourceFactory()); | 135 fetcher->requestResource(fetchRequest, TestResourceFactory()); |
| 136 ASSERT_TRUE(resource); | 136 EXPECT_FALSE(resource); |
| 137 EXPECT_TRUE(resource->errorOccurred()); | |
| 138 EXPECT_TRUE(resource->resourceError().isAccessCheck()); | |
| 139 EXPECT_FALSE(memoryCache()->resourceForURL(secureURL)); | 137 EXPECT_FALSE(memoryCache()->resourceForURL(secureURL)); |
| 140 | 138 |
| 141 // Start by calling startLoad() directly, rather than via requestResource(). | 139 // Start by calling startLoad() directly, rather than via requestResource(). |
| 142 // This shouldn't crash. | 140 // This shouldn't crash. |
| 143 fetcher->startLoad(Resource::create(secureURL, Resource::Raw)); | 141 fetcher->startLoad(Resource::create(secureURL, Resource::Raw)); |
| 144 } | 142 } |
| 145 | 143 |
| 146 TEST_F(ResourceFetcherTest, UseExistingResource) { | 144 TEST_F(ResourceFetcherTest, UseExistingResource) { |
| 147 ResourceFetcher* fetcher = | 145 ResourceFetcher* fetcher = |
| 148 ResourceFetcher::create(ResourceFetcherTestMockFetchContext::create()); | 146 ResourceFetcher::create(ResourceFetcherTestMockFetchContext::create()); |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 url, WebURLResponse(), ""); | 746 url, WebURLResponse(), ""); |
| 749 Resource* newResource = fetcher->requestResource( | 747 Resource* newResource = fetcher->requestResource( |
| 750 fetchRequest, TestResourceFactory(Resource::Raw)); | 748 fetchRequest, TestResourceFactory(Resource::Raw)); |
| 751 fetcher->stopFetching(); | 749 fetcher->stopFetching(); |
| 752 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); | 750 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); |
| 753 | 751 |
| 754 EXPECT_NE(resource, newResource); | 752 EXPECT_NE(resource, newResource); |
| 755 } | 753 } |
| 756 | 754 |
| 757 } // namespace blink | 755 } // namespace blink |
| OLD | NEW |