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" |
(...skipping 20 matching lines...) Expand all Loading... |
31 bool isPrefetchOnly() override { return m_isPrefetchOnly; } | 31 bool isPrefetchOnly() override { return m_isPrefetchOnly; } |
32 | 32 |
33 bool m_isPrefetchOnly; | 33 bool m_isPrefetchOnly; |
34 }; | 34 }; |
35 | 35 |
36 class HTMLDocumentParserTest : public testing::Test { | 36 class HTMLDocumentParserTest : public testing::Test { |
37 protected: | 37 protected: |
38 HTMLDocumentParserTest() | 38 HTMLDocumentParserTest() |
39 : m_dummyPageHolder(DummyPageHolder::create()) | 39 : m_dummyPageHolder(DummyPageHolder::create()) |
40 { | 40 { |
| 41 m_dummyPageHolder->document().setURL(KURL(KURL(), "https://example.test"
)); |
41 } | 42 } |
42 | 43 |
43 HTMLDocumentParser* createParser(HTMLDocument& document) | 44 HTMLDocumentParser* createParser(HTMLDocument& document) |
44 { | 45 { |
45 HTMLDocumentParser* parser = | 46 HTMLDocumentParser* parser = |
46 HTMLDocumentParser::create(document, ForceSynchronousParsing); | 47 HTMLDocumentParser::create(document, ForceSynchronousParsing); |
47 TextResourceDecoderBuilder decoderBuilder("text/html", nullAtom); | 48 TextResourceDecoderBuilder decoderBuilder("text/html", nullAtom); |
48 std::unique_ptr<TextResourceDecoder> decoder( | 49 std::unique_ptr<TextResourceDecoder> decoder( |
49 decoderBuilder.buildFor(&document)); | 50 decoderBuilder.buildFor(&document)); |
50 parser->setDecoder(std::move(decoder)); | 51 parser->setDecoder(std::move(decoder)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 const char bytes[] = "<ht"; | 84 const char bytes[] = "<ht"; |
84 parser->appendBytes(bytes, sizeof(bytes)); | 85 parser->appendBytes(bytes, sizeof(bytes)); |
85 // The bytes are forwarded to the tokenizer. | 86 // The bytes are forwarded to the tokenizer. |
86 HTMLScriptRunnerHost* scriptRunnerHost = | 87 HTMLScriptRunnerHost* scriptRunnerHost = |
87 parser->asHTMLScriptRunnerHostForTesting(); | 88 parser->asHTMLScriptRunnerHostForTesting(); |
88 EXPECT_FALSE(scriptRunnerHost->hasPreloadScanner()); | 89 EXPECT_FALSE(scriptRunnerHost->hasPreloadScanner()); |
89 EXPECT_EQ(HTMLTokenizer::TagNameState, parser->tokenizer()->getState()); | 90 EXPECT_EQ(HTMLTokenizer::TagNameState, parser->tokenizer()->getState()); |
90 } | 91 } |
91 | 92 |
92 } // namespace blink | 93 } // namespace blink |
OLD | NEW |