summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorjcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-11 19:21:26 +0000
committerjcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-11 19:21:26 +0000
commit360bc0b11fca09bcfb942f8616c1feaf9d964545 (patch)
tree4d05df73ac0d6726fafd40f356dba1d693e0b9a7 /chrome/renderer
parentecc980cabad875a4b28c41d6361be6fedb35036a (diff)
downloadchromium_src-360bc0b11fca09bcfb942f8616c1feaf9d964545.zip
chromium_src-360bc0b11fca09bcfb942f8616c1feaf9d964545.tar.gz
chromium_src-360bc0b11fca09bcfb942f8616c1feaf9d964545.tar.bz2
Adding a test to test a craher with the select popup on Mac.
The crasher was fixed in WebKit: https://bugs.webkit.org/show_bug.cgi?id=49108 BUG=61997 TEST=Run the browser tests. Review URL: http://codereview.chromium.org/4642001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65827 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/external_popup_menu_unittest.cc44
-rw-r--r--chrome/renderer/render_view.h1
2 files changed, 40 insertions, 5 deletions
diff --git a/chrome/renderer/external_popup_menu_unittest.cc b/chrome/renderer/external_popup_menu_unittest.cc
index 9ab6067..9595bae 100644
--- a/chrome/renderer/external_popup_menu_unittest.cc
+++ b/chrome/renderer/external_popup_menu_unittest.cc
@@ -27,12 +27,21 @@ class ExternalPopupMenuTest : public RenderViewTest {
// We need to set this explictly as RenderMain is not run.
WebKit::WebView::setUseExternalPopupMenus(true);
+ std::string html = "<select id='mySelect' onchange='selectChanged(this)'>"
+ " <option>zero</option>"
+ " <option selected='1'>one</option>"
+ " <option>two</option>"
+ "</select>";
+ if (ShouldRemoveSelectOnChange()) {
+ html += "<script>"
+ " function selectChanged(select) {"
+ " select.parentNode.removeChild(select);"
+ " }"
+ "</script>";
+ }
+
// Load the test page.
- LoadHTML("<select id='mySelect'>"
- " <option>zero</option>"
- " <option selected='1'>one</option>"
- " <option>two</option>"
- "</select>");
+ LoadHTML(html.c_str());
// Set a minimum size and give focus so simulated events work.
view_->webwidget()->resize(WebKit::WebSize(500, 500));
@@ -47,6 +56,9 @@ class ExternalPopupMenuTest : public RenderViewTest {
return selected_index;
}
+ protected:
+ virtual bool ShouldRemoveSelectOnChange() const { return false; }
+
DISALLOW_COPY_AND_ASSIGN(ExternalPopupMenuTest);
};
@@ -96,3 +108,25 @@ TEST_F(ExternalPopupMenuTest, ShowPopupThenNavigate) {
// Now the user selects something, we should not crash.
view_->OnSelectPopupMenuItem(-1);
}
+
+class ExternalPopupMenuRemoveTest : public ExternalPopupMenuTest {
+ public:
+ ExternalPopupMenuRemoveTest() {}
+
+ protected:
+ virtual bool ShouldRemoveSelectOnChange() const { return true; }
+};
+
+// Tests that nothing bad happen when the page removes the select when it
+// changes. (http://crbug.com/61997)
+TEST_F(ExternalPopupMenuRemoveTest, RemoveOnChange) {
+ // Click the text field once to show the popup.
+ EXPECT_TRUE(SimulateElementClick(kSelectID));
+
+ // Select something, it causes the select to be removed from the page.
+ view_->OnSelectPopupMenuItem(0);
+
+ // Just to check the soundness of the test, call SimulateElementClick again.
+ // It should return false as the select has been removed.
+ EXPECT_FALSE(SimulateElementClick(kSelectID));
+}
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index f4bbc17..e5e9259 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -653,6 +653,7 @@ class RenderView : public RenderWidget,
FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase);
FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, ShowPopupThenNavigate);
+ FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange);
FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnNavStateChanged);
FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnImeStateChanged);
FRIEND_TEST_ALL_PREFIXES(RenderViewTest, ImeComposition);