TEST_F(HTMLSelectElementTest, ActiveSelectionEndAfterOptionRemoval)
{
    document().documentElement()->setInnerHTML("<select><optgroup><option selected>o1</option></optgroup></select>", ASSERT_NO_EXCEPTION);
    document().view()->updateAllLifecyclePhases();
    HTMLSelectElement* select = toHTMLSelectElement(document().body()->firstChild());
    HTMLOptionElement* option = toHTMLOptionElement(select->firstChild()->firstChild());
    EXPECT_EQ(1, select->activeSelectionEndListIndex());
    select->firstChild()->removeChild(option, ASSERT_NO_EXCEPTION);
    EXPECT_EQ(-1, select->activeSelectionEndListIndex());
    select->appendChild(option, ASSERT_NO_EXCEPTION);
    EXPECT_EQ(1, select->activeSelectionEndListIndex());
}
void HTMLKeygenElement::didAddUserAgentShadowRoot(ShadowRoot& root) {
  DEFINE_STATIC_LOCAL(AtomicString, keygenSelectPseudoId,
                      ("-webkit-keygen-select"));

  Vector<String> keys;
  keys.reserveCapacity(2);
  keys.append(
      locale().queryString(WebLocalizedString::KeygenMenuHighGradeKeySize));
  keys.append(
      locale().queryString(WebLocalizedString::KeygenMenuMediumGradeKeySize));

  // Create a select element with one option element for each key size.
  HTMLSelectElement* select = HTMLSelectElement::create(document());
  select->setShadowPseudoId(keygenSelectPseudoId);
  for (const String& key : keys) {
    HTMLOptionElement* option = HTMLOptionElement::create(document());
    option->appendChild(Text::create(document(), key));
    select->appendChild(option);
  }

  root.appendChild(select);
}