diff options
-rw-r--r-- | content/renderer/external_popup_menu_browsertest.cc | 40 | ||||
-rw-r--r-- | content/renderer/render_view_impl.h | 1 |
2 files changed, 41 insertions, 0 deletions
diff --git a/content/renderer/external_popup_menu_browsertest.cc b/content/renderer/external_popup_menu_browsertest.cc index a0a6a90..c29306c 100644 --- a/content/renderer/external_popup_menu_browsertest.cc +++ b/content/renderer/external_popup_menu_browsertest.cc @@ -145,4 +145,44 @@ TEST_F(ExternalPopupMenuRemoveTest, RemoveOnChange) { EXPECT_FALSE(SimulateElementClick(kSelectID)); } +class ExternalPopupMenuDisplayNoneTest : public ExternalPopupMenuTest { + public: + ExternalPopupMenuDisplayNoneTest() {} + + virtual void SetUp() { + RenderViewTest::SetUp(); + // We need to set this explictly as RenderMain is not run. + blink::WebView::setUseExternalPopupMenus(true); + + std::string html = "<select id='mySelect'>" + " <option value='zero'>zero</option>" + " <optgroup label='hide' style='display: none'>" + " <option value='one'>one</option>" + " </optgroup>" + " <option value='two'>two</option>" + " <option value='three'>three</option>" + " <option value='four'>four</option>" + " <option value='five'>five</option>" + "</select>"; + // Load the test page. + LoadHTML(html.c_str()); + + // Set a minimum size and give focus so simulated events work. + view()->webwidget()->resize(blink::WebSize(500, 500)); + view()->webwidget()->setFocus(true); + } + +}; + +TEST_F(ExternalPopupMenuDisplayNoneTest, SelectItem) { + // Click the text field once to show the popup. + EXPECT_TRUE(SimulateElementClick(kSelectID)); + + // Select index 1 item. This should select item with index 2, + // skipping the item with 'display: none' + view()->OnSelectPopupMenuItem(1); + + EXPECT_EQ(2,GetSelectedIndex()); +} + } // namespace content diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index 4c674ca..e0932ea 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -571,6 +571,7 @@ class CONTENT_EXPORT RenderViewImpl // code away from this class. friend class RenderFrameImpl; + FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuDisplayNoneTest, SelectItem); FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange); FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase); FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, ShowPopupThenNavigate); |