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/HTMLDocumentParser.h" | 5 #include "core/html/parser/HTMLDocumentParser.h" |
6 | 6 |
7 #include "core/html/HTMLDocument.h" | 7 #include "core/html/HTMLDocument.h" |
8 #include "core/html/parser/TextResourceDecoder.h" | 8 #include "core/html/parser/TextResourceDecoder.h" |
9 #include "core/loader/PrerendererClient.h" | 9 #include "core/loader/PrerendererClient.h" |
10 #include "core/loader/TextResourceDecoderBuilder.h" | 10 #include "core/loader/TextResourceDecoderBuilder.h" |
11 #include "core/testing/DummyPageHolder.h" | 11 #include "core/testing/DummyPageHolder.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include <memory> | 13 #include <memory> |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 class TestPrerendererClient : public GarbageCollected<TestPrerendererClient>, | 19 class TestPrerendererClient : public GarbageCollected<TestPrerendererClient>, |
20 public PrerendererClient { | 20 public PrerendererClient { |
21 USING_GARBAGE_COLLECTED_MIXIN(TestPrerendererClient); | 21 USING_GARBAGE_COLLECTED_MIXIN(TestPrerendererClient); |
22 | 22 |
23 public: | 23 public: |
24 TestPrerendererClient(Page& page, bool is_prefetch_only) | 24 TestPrerendererClient(Page& page, bool is_prefetch_only) |
25 : PrerendererClient(page), is_prefetch_only_(is_prefetch_only) {} | 25 : PrerendererClient(page), is_prefetch_only_(is_prefetch_only) {} |
26 | 26 |
27 private: | 27 private: |
28 void WillAddPrerender(Prerender*) override{}; | 28 void WillAddPrerender(Prerender*) override {} |
29 bool IsPrefetchOnly() override { return is_prefetch_only_; } | 29 bool IsPrefetchOnly() override { return is_prefetch_only_; } |
30 | 30 |
31 bool is_prefetch_only_; | 31 bool is_prefetch_only_; |
32 }; | 32 }; |
33 | 33 |
34 class HTMLDocumentParserTest : public testing::Test { | 34 class HTMLDocumentParserTest : public testing::Test { |
35 protected: | 35 protected: |
36 HTMLDocumentParserTest() : dummy_page_holder_(DummyPageHolder::Create()) { | 36 HTMLDocumentParserTest() : dummy_page_holder_(DummyPageHolder::Create()) { |
37 dummy_page_holder_->GetDocument().SetURL( | 37 dummy_page_holder_->GetDocument().SetURL( |
38 KURL(KURL(), "https://example.test")); | 38 KURL(KURL(), "https://example.test")); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 const char kBytes[] = "<ht"; | 79 const char kBytes[] = "<ht"; |
80 parser->AppendBytes(kBytes, sizeof(kBytes)); | 80 parser->AppendBytes(kBytes, sizeof(kBytes)); |
81 // The bytes are forwarded to the tokenizer. | 81 // The bytes are forwarded to the tokenizer. |
82 HTMLParserScriptRunnerHost* script_runner_host = | 82 HTMLParserScriptRunnerHost* script_runner_host = |
83 parser->AsHTMLParserScriptRunnerHostForTesting(); | 83 parser->AsHTMLParserScriptRunnerHostForTesting(); |
84 EXPECT_FALSE(script_runner_host->HasPreloadScanner()); | 84 EXPECT_FALSE(script_runner_host->HasPreloadScanner()); |
85 EXPECT_EQ(HTMLTokenizer::kTagNameState, parser->Tokenizer()->GetState()); | 85 EXPECT_EQ(HTMLTokenizer::kTagNameState, parser->Tokenizer()->GetState()); |
86 } | 86 } |
87 | 87 |
88 } // namespace blink | 88 } // namespace blink |
OLD | NEW |