| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/html/parser/CSSPreloadScanner.h" | 5 #include "core/html/parser/CSSPreloadScanner.h" |
| 6 | 6 |
| 7 #include "core/fetch/FetchContext.h" | 7 #include "core/fetch/FetchContext.h" |
| 8 #include "core/fetch/Resource.h" | 8 #include "core/fetch/Resource.h" |
| 9 #include "core/fetch/ResourceFetcher.h" | 9 #include "core/fetch/ResourceFetcher.h" |
| 10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 HTMLResourcePreloader* preloader = | 98 HTMLResourcePreloader* preloader = |
| 99 HTMLResourcePreloader::create(dummyPageHolder->document()); | 99 HTMLResourcePreloader::create(dummyPageHolder->document()); |
| 100 | 100 |
| 101 KURL url(ParsedURLString, "http://127.0.0.1/foo.css"); | 101 KURL url(ParsedURLString, "http://127.0.0.1/foo.css"); |
| 102 CSSStyleSheetResource* resource = | 102 CSSStyleSheetResource* resource = |
| 103 CSSStyleSheetResource::createForTest(ResourceRequest(url), "utf-8"); | 103 CSSStyleSheetResource::createForTest(ResourceRequest(url), "utf-8"); |
| 104 | 104 |
| 105 const char* data = "@import url('http://127.0.0.1/preload.css');"; | 105 const char* data = "@import url('http://127.0.0.1/preload.css');"; |
| 106 resource->appendData(data, strlen(data)); | 106 resource->appendData(data, strlen(data)); |
| 107 ResourceError error(errorDomainBlinkInternal, 0, url.getString(), ""); | 107 ResourceError error(errorDomainBlinkInternal, 0, url.getString(), ""); |
| 108 resource->error(error); | 108 resource->error(error, Resource::LoadError); |
| 109 | 109 |
| 110 // Should not crash. | 110 // Should not crash. |
| 111 PreloadSuppressingCSSPreloaderResourceClient* resourceClient = | 111 PreloadSuppressingCSSPreloaderResourceClient* resourceClient = |
| 112 new PreloadSuppressingCSSPreloaderResourceClient(resource, preloader); | 112 new PreloadSuppressingCSSPreloaderResourceClient(resource, preloader); |
| 113 | 113 |
| 114 EXPECT_EQ(0u, resourceClient->m_preloads.size()); | 114 EXPECT_EQ(0u, resourceClient->m_preloads.size()); |
| 115 } | 115 } |
| 116 | 116 |
| 117 // Regression test for crbug.com/645331, where a resource client gets callbacks | 117 // Regression test for crbug.com/645331, where a resource client gets callbacks |
| 118 // after the document is shutdown and we have no frame. | 118 // after the document is shutdown and we have no frame. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 136 | 136 |
| 137 const char* data = "@import url('http://127.0.0.1/preload.css');"; | 137 const char* data = "@import url('http://127.0.0.1/preload.css');"; |
| 138 resource->appendData(data, strlen(data)); | 138 resource->appendData(data, strlen(data)); |
| 139 | 139 |
| 140 EXPECT_EQ(1u, resourceClient->m_preloads.size()); | 140 EXPECT_EQ(1u, resourceClient->m_preloads.size()); |
| 141 EXPECT_EQ("http://127.0.0.1/preload.css", | 141 EXPECT_EQ("http://127.0.0.1/preload.css", |
| 142 resourceClient->m_preloads.first()->resourceURL()); | 142 resourceClient->m_preloads.first()->resourceURL()); |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace blink | 145 } // namespace blink |
| OLD | NEW |