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

Unified Diff: chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc

Issue 2240553003: Track text selection on the browser side (Mac) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the failing tests on 'mac_chromium_rel_ng' Created 4 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
Index: chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc
diff --git a/chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc b/chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc
index 38443d3030b2d0beae064231f95932e440830148..9269d11cfba1151fb67b0683d0616c0655c290ba 100644
--- a/chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc
+++ b/chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc
@@ -565,6 +565,60 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
reset_state_observer.Wait();
}
+// This test creates a page with multiple child frames and adds an <input> to
+// each frame. Then, sequentially, each <input> is focused by sending a tab key.
+// After focusing each input, a sequence of key presses (character 'E') are sent
+// to the focused widget and then the whole text is selected using Ctrl+A. The
+// test then verifies that the selection length equals the length of the
+// sequence of 'E's.
+IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
+ TrackTextSelectionForAllFrames) {
+ CreateIframePage("a(b,c(a,b),d)");
+ std::vector<content::RenderFrameHost*> frames{
+ GetFrame(IndexVector{}), GetFrame(IndexVector{0}),
+ GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}),
+ GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})};
+ std::vector<std::string> values{"main", "b", "c", "ca", "cb", "d"};
+ std::vector<content::RenderWidgetHostView*> views;
+ for (auto* frame : frames)
+ views.push_back(frame->GetView());
+ for (size_t i = 0; i < frames.size(); ++i)
+ AddInputFieldToFrame(frames[i], "text", values[i], true);
+
+ content::WebContents* web_contents = active_contents();
+
+ auto send_tab_and_wait_for_value = [&web_contents](const std::string& value) {
+ TextInputManagerValueObserver observer(web_contents, value);
+ SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB,
+ ui::VKEY_TAB, false, false, false, false);
+ observer.Wait();
+ };
+
+ auto send_keys_select_all_wait_for_selection_change = [&web_contents](
+ content::RenderWidgetHostView* view, size_t count) {
+ ViewTextSelectionObserver observer(web_contents, view, count);
+ for (size_t i = 0; i < count; ++i) {
+ SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('E'),
+ ui::DomCode::US_E, ui::VKEY_E, false, false, false,
+ false);
+ }
+ // Send Ctrl+A to select the whole text.
+ SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('a'),
+ ui::DomCode::US_A, ui::VKEY_A, true, false, false, false);
Avi (use Gerrit) 2016/08/12 15:53:10 Why is control-A supposed to work on the Mac? On t
EhsanK 2016/08/16 13:36:44 Very good catch! You are right and I was not selec
EhsanK 2016/08/16 13:46:45 Sorry - outdated comment. The second paragraph is
+ observer.Wait();
+ };
+
+ size_t count = 2;
+ for (size_t i = 0; i < views.size(); ++i) {
+ // First focus the <input>.
+ send_tab_and_wait_for_value(values[i]);
+
+ // Send a sequence of |count| 'E' keys and wait until the view receives a
+ // selection change update for a text of the corresponding size, |count|.
+ send_keys_select_all_wait_for_selection_change(views[i], count++);
+ }
+}
+
// TODO(ekaramad): Enable the following tests on other platforms when the
// corresponding feature is implemented (http://crbug.com/578168).
#if defined(USE_AURA)
@@ -642,60 +696,6 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
send_tab_set_composition_wait_for_bounds_change(view);
}
-// This test creates a page with multiple child frames and adds an <input> to
-// each frame. Then, sequentially, each <input> is focused by sending a tab key.
-// After focusing each input, a sequence of key presses (character 'E') are sent
-// to the focused widget and then the whole text is selected using Ctrl+A. The
-// test then verifies that the selection length equals the length of the
-// sequence of 'E's.
-IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
- TrackTextSelectionForAllFrames) {
- CreateIframePage("a(b,c(a,b),d)");
- std::vector<content::RenderFrameHost*> frames{
- GetFrame(IndexVector{}), GetFrame(IndexVector{0}),
- GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}),
- GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})};
- std::vector<std::string> values{"main", "b", "c", "ca", "cb", "d"};
- std::vector<content::RenderWidgetHostView*> views;
- for (auto* frame : frames)
- views.push_back(frame->GetView());
- for (size_t i = 0; i < frames.size(); ++i)
- AddInputFieldToFrame(frames[i], "text", values[i], true);
-
- content::WebContents* web_contents = active_contents();
-
- auto send_tab_and_wait_for_value = [&web_contents](const std::string& value) {
- TextInputManagerValueObserver observer(web_contents, value);
- SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB,
- ui::VKEY_TAB, false, false, false, false);
- observer.Wait();
- };
-
- auto send_keys_select_all_wait_for_selection_change = [&web_contents](
- content::RenderWidgetHostView* view, size_t count) {
- ViewTextSelectionObserver observer(web_contents, view, count);
- for (size_t i = 0; i < count; ++i) {
- SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('E'),
- ui::DomCode::US_E, ui::VKEY_E, false, false, false,
- false);
- }
- // Send Ctrl+A to select the whole text.
- SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('a'),
- ui::DomCode::US_A, ui::VKEY_A, true, false, false, false);
- observer.Wait();
- };
-
- size_t count = 2;
- for (size_t i = 0; i < views.size(); ++i) {
- // First focus the <input>.
- send_tab_and_wait_for_value(values[i]);
-
- // Send a sequence of |count| 'E' keys and wait until the view receives a
- // selection change update for a text of the corresponding size, |count|.
- send_keys_select_all_wait_for_selection_change(views[i], count++);
- }
-}
-
// The following test verifies that when the active widget changes value, it is
// always from nullptr to non-null or vice versa.
IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,

Powered by Google App Engine
This is Rietveld 408576698