| 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 "public/platform/WebDocumentSubresourceFilter.h" | 5 #include "public/platform/WebDocumentSubresourceFilter.h" |
| 6 | 6 |
| 7 #include "core/dom/Element.h" | 7 #include "core/dom/Element.h" |
| 8 #include "core/html/HTMLImageElement.h" | 8 #include "core/html/HTMLImageElement.h" |
| 9 #include "platform/testing/URLTestHelpers.h" | 9 #include "platform/testing/URLTestHelpers.h" |
| 10 #include "platform/testing/UnitTestHelpers.h" | 10 #include "platform/testing/UnitTestHelpers.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 } | 44 } |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 std::vector<std::string> m_queriedSubresourcePaths; | 47 std::vector<std::string> m_queriedSubresourcePaths; |
| 48 bool m_allowLoads; | 48 bool m_allowLoads; |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 class SubresourceFilteringWebFrameClient | 51 class SubresourceFilteringWebFrameClient |
| 52 : public FrameTestHelpers::TestWebFrameClient { | 52 : public FrameTestHelpers::TestWebFrameClient { |
| 53 public: | 53 public: |
| 54 void didStartProvisionalLoad(WebDataSource* dataSource) override { | 54 void didStartProvisionalLoad(WebDataSource* dataSource, |
| 55 WebURLRequest& request) override { |
| 55 // Normally, the filter should be set when the load is committed. For | 56 // Normally, the filter should be set when the load is committed. For |
| 56 // the sake of this test, however, inject it earlier to verify that it | 57 // the sake of this test, however, inject it earlier to verify that it |
| 57 // is not consulted for the main resource load. | 58 // is not consulted for the main resource load. |
| 58 m_subresourceFilter = | 59 m_subresourceFilter = |
| 59 new TestDocumentSubresourceFilter(m_allowSubresourcesFromNextLoad); | 60 new TestDocumentSubresourceFilter(m_allowSubresourcesFromNextLoad); |
| 60 dataSource->setSubresourceFilter(m_subresourceFilter); | 61 dataSource->setSubresourceFilter(m_subresourceFilter); |
| 61 } | 62 } |
| 62 | 63 |
| 63 void setAllowSubresourcesFromNextLoad(bool allow) { | 64 void setAllowSubresourcesFromNextLoad(bool allow) { |
| 64 m_allowSubresourcesFromNextLoad = allow; | 65 m_allowSubresourcesFromNextLoad = allow; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 loadDocument(!allowSubresources); | 145 loadDocument(!allowSubresources); |
| 145 expectSubresourceWasLoaded(!allowSubresources); | 146 expectSubresourceWasLoaded(!allowSubresources); |
| 146 EXPECT_THAT(queriedSubresourcePaths(), | 147 EXPECT_THAT(queriedSubresourcePaths(), |
| 147 ::testing::ElementsAre("/white-1x1.png")); | 148 ::testing::ElementsAre("/white-1x1.png")); |
| 148 | 149 |
| 149 WebCache::clear(); | 150 WebCache::clear(); |
| 150 } | 151 } |
| 151 } | 152 } |
| 152 | 153 |
| 153 } // namespace blink | 154 } // namespace blink |
| OLD | NEW |