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, no resource should be | 129 // Try to request a url. The request should fail, and a resource in an error |
130 // returned, and no resource should be present in the cache. | 130 // state should be 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 EXPECT_FALSE(resource); | 136 ASSERT_TRUE(resource); |
| 137 EXPECT_TRUE(resource->errorOccurred()); |
| 138 EXPECT_TRUE(resource->resourceError().isAccessCheck()); |
137 EXPECT_FALSE(memoryCache()->resourceForURL(secureURL)); | 139 EXPECT_FALSE(memoryCache()->resourceForURL(secureURL)); |
138 | 140 |
139 // Start by calling startLoad() directly, rather than via requestResource(). | 141 // Start by calling startLoad() directly, rather than via requestResource(). |
140 // This shouldn't crash. | 142 // This shouldn't crash. |
141 fetcher->startLoad(Resource::create(secureURL, Resource::Raw)); | 143 fetcher->startLoad(Resource::create(secureURL, Resource::Raw)); |
142 } | 144 } |
143 | 145 |
144 TEST_F(ResourceFetcherTest, UseExistingResource) { | 146 TEST_F(ResourceFetcherTest, UseExistingResource) { |
145 ResourceFetcher* fetcher = | 147 ResourceFetcher* fetcher = |
146 ResourceFetcher::create(ResourceFetcherTestMockFetchContext::create()); | 148 ResourceFetcher::create(ResourceFetcherTestMockFetchContext::create()); |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 url, WebURLResponse(), ""); | 748 url, WebURLResponse(), ""); |
747 Resource* newResource = fetcher->requestResource( | 749 Resource* newResource = fetcher->requestResource( |
748 fetchRequest, TestResourceFactory(Resource::Raw)); | 750 fetchRequest, TestResourceFactory(Resource::Raw)); |
749 fetcher->stopFetching(); | 751 fetcher->stopFetching(); |
750 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); | 752 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); |
751 | 753 |
752 EXPECT_NE(resource, newResource); | 754 EXPECT_NE(resource, newResource); |
753 } | 755 } |
754 | 756 |
755 } // namespace blink | 757 } // namespace blink |
OLD | NEW |