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

Unified Diff: third_party/WebKit/Source/core/html/HTMLSelectElementTest.cpp

Issue 2151763002: SELECT element: Fix a DCHECK failure in optionToBeShown(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SELECT element: Fix a DCHECK failure in optionToBeShown(). 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
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSelectElement.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/HTMLSelectElementTest.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLSelectElementTest.cpp b/third_party/WebKit/Source/core/html/HTMLSelectElementTest.cpp
index 1b94a3dd5db94c443c1cc293f884e4e0c4eed236..2b8044b51daf472dfc5568c63876d132a3556b02 100644
--- a/third_party/WebKit/Source/core/html/HTMLSelectElementTest.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLSelectElementTest.cpp
@@ -102,6 +102,38 @@ TEST_F(HTMLSelectElementTest, SaveRestoreSelectMultipleFormControlState)
EXPECT_TRUE(opt3->selected());
}
+TEST_F(HTMLSelectElementTest, RestoreUnmatchedFormControlState)
+{
+ // We had a bug that selectedOption() and m_lastOnChangeOption were
+ // mismatched in optionToBeShown(). It happened when
+ // restoreFormControlState() couldn't find matched OPTIONs.
+ // crbug.com/627833.
+
+ document().documentElement()->setInnerHTML("<select id='sel'>"
+ "<option selected>Default</option>"
+ "<option id='2'>222</option>"
+ "</select>", ASSERT_NO_EXCEPTION);
+ document().view()->updateAllLifecyclePhases();
+ Element* element = document().getElementById("sel");
+ HTMLFormControlElementWithState* select = toHTMLSelectElement(element);
+ HTMLOptionElement* opt2 = toHTMLOptionElement(document().getElementById("2"));
+
+ toHTMLSelectElement(element)->setSelectedIndex(1);
+ // Save the current state.
+ FormControlState selectState = select->saveFormControlState();
+ EXPECT_EQ(2U, selectState.valueSize());
+
+ // Reset the status.
+ select->reset();
+ ASSERT_FALSE(opt2->selected());
+ element->removeChild(opt2);
+
+ // Restore
+ select->restoreFormControlState(selectState);
+ EXPECT_EQ(-1, toHTMLSelectElement(element)->selectedIndex());
+ EXPECT_EQ(nullptr, toHTMLSelectElement(element)->optionToBeShown());
+}
+
TEST_F(HTMLSelectElementTest, ElementRectRelativeToViewport)
{
document().documentElement()->setInnerHTML("<select style='position:fixed; top:12.3px; height:24px; -webkit-appearance:none;'><option>o1</select>", ASSERT_NO_EXCEPTION);
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSelectElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698