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

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

Issue 2169433002: HTMLTreeBuilderSimulator: Element created inside HTMLIntegrationPoint should be HTMLElement Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months 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
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
index f5471c62e8e90530891672a07bb92fccacf7315f..56f11ff7039ec60eef893b626b9d1f9fe36ceaea 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLTreeBuilderSimulatorTest.cpp
+++ b/third_party/WebKit/Source/core/html/parser/HTMLTreeBuilderSimulatorTest.cpp
@@ -45,26 +45,62 @@ TEST(HTMLTreeBuilderSimulatorTest, ChangeStateInForeignContentAtHTMLIntegrationP
EXPECT_EQ(HTMLTokenizer::DataState, tokenizer->getState())
<< "the svg start tag should have put the simulator into 'in body' "
<< "state";
+ EXPECT_TRUE(simulator.inForeignContent());
startTag(token, "title");
simulate(simulator, token, tokenizer.get()); // svg > title
EXPECT_EQ(HTMLTokenizer::DataState, tokenizer->getState())
<< "the title start tag should not have flipped the simulator into "
<< "RCDATA state because svg is not a HTML integration point";
+ EXPECT_TRUE(simulator.inForeignContent());
startTag(token, "desc");
simulate(simulator, token, tokenizer.get()); // svg > title > desc
EXPECT_EQ(HTMLTokenizer::DataState, tokenizer->getState())
dominicc (has gone to gerrit) 2016/07/21 02:14:48 I'm mildly confused comparing the code of the asse
- << "the desc tag should not have flipped the simulator into the "
- << "any unusual state because desc parsing rules do not change state, "
- << "despite title being a HTML integration point";
+ << "the desc tag should have been created in HTML namespace";
+ EXPECT_FALSE(simulator.inForeignContent());
startTag(token, "title");
simulate(simulator, token, tokenizer.get()); // svg > title > desc > title
EXPECT_EQ(HTMLTokenizer::RCDATAState, tokenizer->getState())
<< "the title start tag should have flipped the simulator into the "
- << "RCDATA state for title, despite being in foreign content mode, "
- << "because desc is a HTML integration point";
+ << "RCDATA state for title, as the desc tag should have been created "
+ << "in HTML namespace";
+ EXPECT_FALSE(simulator.inForeignContent());
+}
+
+TEST(HTMLTreeBuilderSimulatorTest, HTMLElementShouldBeCreatedInsideHTMLIntegrationPoint)
+{
+ HTMLParserOptions options;
+ HTMLTreeBuilderSimulator simulator(options);
+ std::unique_ptr<HTMLTokenizer> tokenizer = HTMLTokenizer::create(options);
+ HTMLToken token;
+
+ startTag(token, "svg");
+ simulate(simulator, token, tokenizer.get()); // open elements: svg
+ EXPECT_EQ(HTMLTokenizer::DataState, tokenizer->getState())
+ << "the svg start tag should have put the simulator into 'in body' "
+ << "state";
+
+ startTag(token, "title");
+ simulate(simulator, token, tokenizer.get()); // svg > title
+ EXPECT_EQ(HTMLTokenizer::DataState, tokenizer->getState())
+ << "the title start tag should not have flipped the simulator into "
+ << "RCDATA state because svg is not a HTML integration point";
+
+ startTag(token, "foobar");
+ simulate(simulator, token, tokenizer.get()); // svg > title > foobar
+ EXPECT_EQ(HTMLTokenizer::DataState, tokenizer->getState())
+ << "the foobar tag should have been created in HTML namespace";
+ EXPECT_FALSE(simulator.inForeignContent());
+
+ startTag(token, "title");
+ simulate(simulator, token, tokenizer.get()); // svg > title > foobar > title
+ EXPECT_EQ(HTMLTokenizer::RCDATAState, tokenizer->getState())
+ << "the title start tag should have flipped the simulator into the "
+ << "RCDATA state for title, as the foobar tag should have been created "
+ << "in HTML namespace";
+ EXPECT_FALSE(simulator.inForeignContent());
}
}

Powered by Google App Engine
This is Rietveld 408576698