mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 00:32:11 +00:00
Bug 1833081 - Don't show AccessibleCaret when selected text is scrolled back into view via keyboard. r=webdriver-reviewers,emilio,jdescottes
Note: Per my local test, the testcase is not 100% reliable because the selection highlight can disappear intermittently for unknown reason after Step 2. As a result, the testcase intermittently fails *without* my patch, but it's still better than no test at all. Differential Revision: https://phabricator.services.mozilla.com/D179027
This commit is contained in:
parent
75dbaabf5e
commit
4d649b94d5
@ -732,9 +732,10 @@ void AccessibleCaretManager::OnScrollEnd() {
|
||||
}
|
||||
}
|
||||
|
||||
// For mouse input we don't want to show the carets.
|
||||
// For mouse and keyboard input, we don't want to show the carets.
|
||||
if (StaticPrefs::layout_accessiblecaret_hide_carets_for_mouse_input() &&
|
||||
mLastInputSource == MouseEvent_Binding::MOZ_SOURCE_MOUSE) {
|
||||
(mLastInputSource == MouseEvent_Binding::MOZ_SOURCE_MOUSE ||
|
||||
mLastInputSource == MouseEvent_Binding::MOZ_SOURCE_KEYBOARD)) {
|
||||
AC_LOG("%s: HideCaretsAndDispatchCaretStateChangedEvent()", __FUNCTION__);
|
||||
HideCaretsAndDispatchCaretStateChangedEvent();
|
||||
return;
|
||||
|
@ -15,6 +15,7 @@ from selection import (
|
||||
SelectionManager,
|
||||
)
|
||||
from marionette_driver.by import By
|
||||
from marionette_driver.keys import Keys
|
||||
from marionette_harness.marionette_test import (
|
||||
MarionetteTestCase,
|
||||
SkipTest,
|
||||
@ -49,6 +50,7 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
|
||||
_iframe_scroll_html = "layout/test_carets_iframe_scroll.html"
|
||||
_display_none_html = "layout/test_carets_display_none.html"
|
||||
_svg_shapes_html = "layout/test_carets_svg_shapes.html"
|
||||
_key_scroll_html = "layout/test_carets_key_scroll.html"
|
||||
|
||||
def setUp(self):
|
||||
# Code to execute before every test is running.
|
||||
@ -765,3 +767,31 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
|
||||
).perform()
|
||||
|
||||
self.assertEqual("DDDDDD EEEEEE", sel.selected_content)
|
||||
|
||||
def test_carets_not_show_after_key_scroll_down_and_up(self):
|
||||
self.open_test_html(self._key_scroll_html)
|
||||
html = self.marionette.find_element(By.ID, "html")
|
||||
sel = SelectionManager(html)
|
||||
|
||||
# Select "BBBBB" to get the position of the second caret. This is the
|
||||
# position to which we are going to drag the caret in the step 3.
|
||||
content2 = self.marionette.find_element(By.ID, self._content2_id)
|
||||
self.long_press_on_word(content2, 0)
|
||||
(_, _), (x2, y2) = sel.carets_location()
|
||||
|
||||
# Step 1: Select "AAAAA".
|
||||
content = self.marionette.find_element(By.ID, self._content_id)
|
||||
self.long_press_on_word(content, 0)
|
||||
(_, _), (x1, y1) = sel.carets_location()
|
||||
|
||||
# Step 2: Scroll the page down and up.
|
||||
self.actions.key_chain.send_keys(Keys.PAGE_DOWN).pause(1000).send_keys(
|
||||
Keys.PAGE_UP
|
||||
).perform()
|
||||
self.assertEqual("AAAAA", sel.selected_content)
|
||||
|
||||
# Step 3: The carets shouldn't show up after scrolling the page. We're
|
||||
# attempting to drag the second caret down so that if the bug occurs, we
|
||||
# can drag the second caret to extend the selection to "BBBBB".
|
||||
self.actions.flick(html, x1, y1, x2, y2).perform()
|
||||
self.assertNotEqual("AAAAA\nBBBBB", sel.selected_content)
|
||||
|
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html id="html">
|
||||
<style>
|
||||
:root {
|
||||
font: 16px/1.25 monospace;
|
||||
}
|
||||
div {
|
||||
width: 100px;
|
||||
height: 5000px;
|
||||
border: 5px solid blue;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>
|
||||
<span id="content">AAAAA</span><br>
|
||||
<span id="content2">BBBBB</span>
|
||||
</div>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user