| // Copyright 2022 The Cobalt Authors. All Rights Reserved. |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| |
| #ifndef COBALT_DOM_TESTING_FAKE_DOCUMENT_H_ |
| #define COBALT_DOM_TESTING_FAKE_DOCUMENT_H_ |
| |
| #include <memory> |
| #include <utility> |
| |
| #include "cobalt/dom/document.h" |
| #include "cobalt/web/csp_delegate_factory.h" |
| |
| namespace cobalt { |
| namespace dom { |
| namespace testing { |
| |
| class FakeDocument : public dom::Document { |
| public: |
| explicit FakeDocument(dom::HTMLElementContext* html_element_context) |
| : FakeDocument(html_element_context, dom::Document::Options()) {} |
| |
| FakeDocument(dom::HTMLElementContext* html_element_context, |
| const dom::Document::Options& doc_options) |
| : dom::Document(html_element_context, doc_options) { |
| web::WindowOrWorkerGlobalScope::Options options; |
| csp_delegate_ = |
| web::CspDelegateFactory::Create(nullptr, options.csp_options); |
| } |
| |
| web::CspDelegate* GetCSPDelegate() const override { |
| return csp_delegate_.get(); |
| } |
| |
| private: |
| std::unique_ptr<web::CspDelegate> csp_delegate_; |
| }; |
| |
| } // namespace testing |
| } // namespace dom |
| } // namespace cobalt |
| |
| #endif // COBALT_DOM_TESTING_FAKE_DOCUMENT_H_ |