Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Unified Diff: third_party/WebKit/Source/core/html/parser/HTMLTreeBuilderSimulatorTest.cpp

Issue 2546373002: Properly simulate self-closing tags when in "foreign content" mode (Closed)
Patch Set: Add CORE_EXPORT Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/parser/HTMLTreeBuilderSimulator.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « third_party/WebKit/Source/core/html/parser/HTMLTreeBuilderSimulator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698