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

Unified Diff: content/renderer/external_popup_menu_browsertest.cc

Issue 447503002: Add content browser test for <optgroup> with 'display: none' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 | « content/public/test/render_view_test.cc ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/external_popup_menu_browsertest.cc
diff --git a/content/renderer/external_popup_menu_browsertest.cc b/content/renderer/external_popup_menu_browsertest.cc
index a0a6a90c8f373354d170c5fe6757df2a4dcba85d..ba0b6d9cd099159a2a84f3d6b3afc1802ed4366b 100644
--- a/content/renderer/external_popup_menu_browsertest.cc
+++ b/content/renderer/external_popup_menu_browsertest.cc
@@ -145,4 +145,54 @@ TEST_F(ExternalPopupMenuRemoveTest, RemoveOnChange) {
EXPECT_FALSE(SimulateElementClick(kSelectID));
}
+class ExternalPopupMenuDisplayNoneTest : public RenderViewTest {
+ public:
+ ExternalPopupMenuDisplayNoneTest() {}
+ RenderViewImpl* view() {
+ return static_cast<RenderViewImpl*>(view_);
+ }
+
+ 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);
+ }
+
+ std::string GetSelectedValue() {
+ base::string16 script(base::ASCIIToUTF16(kSelectID));
+ script.append(base::ASCIIToUTF16(".value"));
keishi 2014/08/06 03:10:55 Maybe if you used selectedIndex, you won't need to
spartha 2014/08/06 05:29:32 Since we are skipping an item because of "display:
keishi 2014/08/06 06:43:27 I'm not sure. After calling "view()->OnSelectPopup
spartha 2014/08/06 11:09:40 Done.
+ std::string value;
+ ExecuteJavaScriptAndReturnStringValue(script, value);
+ return value;
+ }
+};
+
+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 value 'two'.
+ view()->OnSelectPopupMenuItem(1);
+
+ EXPECT_EQ("two",GetSelectedValue());
+}
+
} // namespace content
« no previous file with comments | « content/public/test/render_view_test.cc ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698