| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 resource->setStatus(Resource::Pending); | 53 resource->setStatus(Resource::Pending); |
| 54 | 54 |
| 55 PreloadSuppressingCSSPreloaderResourceClient* resourceClient = | 55 PreloadSuppressingCSSPreloaderResourceClient* resourceClient = |
| 56 new PreloadSuppressingCSSPreloaderResourceClient(resource, preloader); | 56 new PreloadSuppressingCSSPreloaderResourceClient(resource, preloader); |
| 57 | 57 |
| 58 const char* data = "@import url('http://127.0.0.1/preload.css');"; | 58 const char* data = "@import url('http://127.0.0.1/preload.css');"; |
| 59 resource->appendData(data, strlen(data)); | 59 resource->appendData(data, strlen(data)); |
| 60 | 60 |
| 61 EXPECT_EQ(1u, resourceClient->m_preloads.size()); | 61 EXPECT_EQ(1u, resourceClient->m_preloads.size()); |
| 62 EXPECT_EQ("http://127.0.0.1/preload.css", | 62 EXPECT_EQ("http://127.0.0.1/preload.css", |
| 63 resourceClient->m_preloads.first()->resourceURL()); | 63 resourceClient->m_preloads.front()->resourceURL()); |
| 64 } | 64 } |
| 65 | 65 |
| 66 // Regression test for crbug.com/608310 where the client is destroyed but was | 66 // Regression test for crbug.com/608310 where the client is destroyed but was |
| 67 // not removed from the resource's client list. | 67 // not removed from the resource's client list. |
| 68 TEST_F(CSSPreloadScannerTest, DestroyClientBeforeDataSent) { | 68 TEST_F(CSSPreloadScannerTest, DestroyClientBeforeDataSent) { |
| 69 std::unique_ptr<DummyPageHolder> dummyPageHolder = | 69 std::unique_ptr<DummyPageHolder> dummyPageHolder = |
| 70 DummyPageHolder::create(IntSize(500, 500)); | 70 DummyPageHolder::create(IntSize(500, 500)); |
| 71 dummyPageHolder->document().settings()->setCSSExternalScannerNoPreload(true); | 71 dummyPageHolder->document().settings()->setCSSExternalScannerNoPreload(true); |
| 72 | 72 |
| 73 Persistent<HTMLResourcePreloader> preloader = | 73 Persistent<HTMLResourcePreloader> preloader = |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 PreloadSuppressingCSSPreloaderResourceClient* resourceClient = | 132 PreloadSuppressingCSSPreloaderResourceClient* resourceClient = |
| 133 new PreloadSuppressingCSSPreloaderResourceClient(resource, preloader); | 133 new PreloadSuppressingCSSPreloaderResourceClient(resource, preloader); |
| 134 | 134 |
| 135 dummyPageHolder->document().shutdown(); | 135 dummyPageHolder->document().shutdown(); |
| 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.front()->resourceURL()); |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace blink | 145 } // namespace blink |
| OLD | NEW |