Index: third_party/WebKit/Source/core/html/parser/HTMLTreeBuilderSimulatorTest.cpp |
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLTreeBuilderSimulatorTest.cpp b/third_party/WebKit/Source/core/html/parser/HTMLTreeBuilderSimulatorTest.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b98d475131e7c77af06ead2998d794f498f56e0d |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/html/parser/HTMLTreeBuilderSimulatorTest.cpp |
@@ -0,0 +1,66 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "core/html/parser/HTMLTreeBuilderSimulator.h" |
+ |
+#include "core/html/parser/CompactHTMLToken.h" |
+#include "core/html/parser/HTMLToken.h" |
+#include "core/html/parser/HTMLTokenizer.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace blink { |
+ |
+TEST(HTMLTreeBuilderSimulatorTest, SelfClosingSVGFollowedByScript) { |
+ HTMLParserOptions options; |
+ HTMLTreeBuilderSimulator simulator(options); |
+ std::unique_ptr<HTMLTokenizer> tokenizer = HTMLTokenizer::create(options); |
+ SegmentedString input("<svg/><script></script>"); |
+ HTMLToken token; |
+ EXPECT_TRUE(tokenizer->nextToken(input, token)); |
+ EXPECT_EQ(HTMLTreeBuilderSimulator::OtherToken, |
+ simulator.simulate(CompactHTMLToken(&token, TextPosition()), |
+ tokenizer.get())); |
+ |
+ token.clear(); |
+ EXPECT_TRUE(tokenizer->nextToken(input, token)); |
+ EXPECT_EQ(HTMLTreeBuilderSimulator::ScriptStart, |
+ simulator.simulate(CompactHTMLToken(&token, TextPosition()), |
+ tokenizer.get())); |
+ |
+ EXPECT_EQ(HTMLTokenizer::ScriptDataState, tokenizer->getState()); |
+ |
+ token.clear(); |
+ EXPECT_TRUE(tokenizer->nextToken(input, token)); |
+ EXPECT_EQ(HTMLTreeBuilderSimulator::ScriptEnd, |
+ simulator.simulate(CompactHTMLToken(&token, TextPosition()), |
+ tokenizer.get())); |
+} |
+ |
+TEST(HTMLTreeBuilderSimulatorTest, SelfClosingMathFollowedByScript) { |
+ HTMLParserOptions options; |
+ HTMLTreeBuilderSimulator simulator(options); |
+ std::unique_ptr<HTMLTokenizer> tokenizer = HTMLTokenizer::create(options); |
+ SegmentedString input("<math/><script></script>"); |
+ HTMLToken token; |
+ EXPECT_TRUE(tokenizer->nextToken(input, token)); |
+ EXPECT_EQ(HTMLTreeBuilderSimulator::OtherToken, |
+ simulator.simulate(CompactHTMLToken(&token, TextPosition()), |
+ tokenizer.get())); |
+ |
+ token.clear(); |
+ EXPECT_TRUE(tokenizer->nextToken(input, token)); |
+ EXPECT_EQ(HTMLTreeBuilderSimulator::ScriptStart, |
+ simulator.simulate(CompactHTMLToken(&token, TextPosition()), |
+ tokenizer.get())); |
+ |
+ EXPECT_EQ(HTMLTokenizer::ScriptDataState, tokenizer->getState()); |
+ |
+ token.clear(); |
+ EXPECT_TRUE(tokenizer->nextToken(input, token)); |
+ EXPECT_EQ(HTMLTreeBuilderSimulator::ScriptEnd, |
+ simulator.simulate(CompactHTMLToken(&token, TextPosition()), |
+ tokenizer.get())); |
+} |
+ |
+} // namespace blink |