mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Backout bug 1110917 for Gij red.
This commit is contained in:
parent
0f74dc4c92
commit
f22a627b9b
@ -39,32 +39,17 @@ class SelectionCaretsTest(MarionetteTestCase):
|
||||
self._contenteditable = self.marionette.find_element(*self._contenteditable_selector)
|
||||
self._content = self.marionette.find_element(*self._content_selector)
|
||||
|
||||
def _first_word_location(self, el):
|
||||
'''Get the location (x, y) of the first word in el.
|
||||
|
||||
Note: this function has a side effect which changes focus to the
|
||||
target element el.
|
||||
|
||||
'''
|
||||
sel = SelectionManager(el)
|
||||
|
||||
# Move caret behind the first character to get the location of the first
|
||||
# word.
|
||||
def _long_press_to_select_first_word(self, el, sel):
|
||||
# Move caret inside the first word.
|
||||
el.tap()
|
||||
sel.move_caret_to_front()
|
||||
sel.move_caret_by_offset(1)
|
||||
x, y = sel.caret_location()
|
||||
|
||||
return sel.caret_location()
|
||||
|
||||
def _long_press_to_select(self, el, x, y):
|
||||
'''Long press the location (x, y) to select a word.
|
||||
|
||||
SelectionCarets should appear. On Windows, those spaces after the
|
||||
word will also be selected.
|
||||
|
||||
'''
|
||||
long_press_without_contextmenu(self.marionette, el, self._long_press_time,
|
||||
x, y)
|
||||
# Long press the caret position. Selection carets should appear, and the
|
||||
# first word will be selected. On Windows, those spaces after the word
|
||||
# will also be selected.
|
||||
long_press_without_contextmenu(self.marionette, el, self._long_press_time, x, y)
|
||||
|
||||
def _test_long_press_to_select_a_word(self, el, assertFunc):
|
||||
sel = SelectionManager(el)
|
||||
@ -74,8 +59,7 @@ class SelectionCaretsTest(MarionetteTestCase):
|
||||
target_content = words[0]
|
||||
|
||||
# Goal: Select the first word.
|
||||
x, y = self._first_word_location(el)
|
||||
self._long_press_to_select(el, x, y)
|
||||
self._long_press_to_select_first_word(el, sel)
|
||||
|
||||
# Ignore extra spaces selected after the word.
|
||||
assertFunc(target_content, sel.selected_content.rstrip())
|
||||
@ -95,8 +79,7 @@ class SelectionCaretsTest(MarionetteTestCase):
|
||||
sel.select_all()
|
||||
(_, _), (end_caret_x, end_caret_y) = sel.selection_carets_location()
|
||||
|
||||
x, y = self._first_word_location(el)
|
||||
self._long_press_to_select(el, x, y)
|
||||
self._long_press_to_select_first_word(el, sel)
|
||||
|
||||
# Move the right caret to the end of the content.
|
||||
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
|
||||
@ -108,8 +91,7 @@ class SelectionCaretsTest(MarionetteTestCase):
|
||||
# Ignore extra spaces at the beginning of the content in comparison.
|
||||
assertFunc(target_content.lstrip(), sel.selected_content.lstrip())
|
||||
|
||||
def _test_minimum_select_one_character(self, el, assertFunc,
|
||||
x=None, y=None):
|
||||
def _test_minimum_select_one_character(self, el, assertFunc):
|
||||
sel = SelectionManager(el)
|
||||
original_content = sel.content
|
||||
words = original_content.split()
|
||||
@ -118,13 +100,7 @@ class SelectionCaretsTest(MarionetteTestCase):
|
||||
# Goal: Select the first character.
|
||||
target_content = original_content[0]
|
||||
|
||||
if x and y:
|
||||
# If we got x and y from the arguments, use it as a hint of the
|
||||
# location of the first word
|
||||
pass
|
||||
else:
|
||||
x, y = self._first_word_location(el)
|
||||
self._long_press_to_select(el, x, y)
|
||||
self._long_press_to_select_first_word(el, sel)
|
||||
|
||||
# Move the right caret to the position of the left caret.
|
||||
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.selection_carets_location()
|
||||
@ -132,24 +108,6 @@ class SelectionCaretsTest(MarionetteTestCase):
|
||||
|
||||
assertFunc(target_content, sel.selected_content)
|
||||
|
||||
def _test_focus_obtained_by_long_press(self, el1, el2):
|
||||
'''Test the focus could be changed from el1 to el2 by long press.
|
||||
|
||||
If the focus is changed to e2 successfully, SelectionCarets should
|
||||
appear and could be dragged.
|
||||
|
||||
'''
|
||||
# Goal: Tap to focus el1, and then select the first character on
|
||||
# el2.
|
||||
|
||||
# We want to collect the location of the first word in el2 here
|
||||
# since self._first_word_location() has the side effect which would
|
||||
# change the focus.
|
||||
x, y = self._first_word_location(el2)
|
||||
el1.tap()
|
||||
self._test_minimum_select_one_character(el2, self.assertEqual,
|
||||
x=x, y=y)
|
||||
|
||||
########################################################################
|
||||
# <input> test cases with selection carets enabled
|
||||
########################################################################
|
||||
@ -165,18 +123,6 @@ class SelectionCaretsTest(MarionetteTestCase):
|
||||
self.openTestHtml(enabled=True)
|
||||
self._test_minimum_select_one_character(self._input, self.assertEqual)
|
||||
|
||||
def test_input_focus_obtained_by_long_press_from_textarea(self):
|
||||
self.openTestHtml(enabled=True)
|
||||
self._test_focus_obtained_by_long_press(self._textarea, self._input)
|
||||
|
||||
def test_input_focus_obtained_by_long_press_from_contenteditable(self):
|
||||
self.openTestHtml(enabled=True)
|
||||
self._test_focus_obtained_by_long_press(self._contenteditable, self._input)
|
||||
|
||||
def test_input_focus_obtained_by_long_press_from_content_non_editable(self):
|
||||
self.openTestHtml(enabled=True)
|
||||
self._test_focus_obtained_by_long_press(self._content, self._input)
|
||||
|
||||
########################################################################
|
||||
# <input> test cases with selection carets disabled
|
||||
########################################################################
|
||||
@ -203,18 +149,6 @@ class SelectionCaretsTest(MarionetteTestCase):
|
||||
self.openTestHtml(enabled=True)
|
||||
self._test_minimum_select_one_character(self._textarea, self.assertEqual)
|
||||
|
||||
def test_textarea_focus_obtained_by_long_press_from_input(self):
|
||||
self.openTestHtml(enabled=True)
|
||||
self._test_focus_obtained_by_long_press(self._input, self._textarea)
|
||||
|
||||
def test_textarea_focus_obtained_by_long_press_from_contenteditable(self):
|
||||
self.openTestHtml(enabled=True)
|
||||
self._test_focus_obtained_by_long_press(self._contenteditable, self._textarea)
|
||||
|
||||
def test_textarea_focus_obtained_by_long_press_from_content_non_editable(self):
|
||||
self.openTestHtml(enabled=True)
|
||||
self._test_focus_obtained_by_long_press(self._content, self._textarea)
|
||||
|
||||
########################################################################
|
||||
# <textarea> test cases with selection carets disabled
|
||||
########################################################################
|
||||
@ -267,18 +201,6 @@ class SelectionCaretsTest(MarionetteTestCase):
|
||||
self.openTestHtml(enabled=True)
|
||||
self._test_minimum_select_one_character(self._contenteditable, self.assertEqual)
|
||||
|
||||
def test_contenteditable_focus_obtained_by_long_press_from_input(self):
|
||||
self.openTestHtml(enabled=True)
|
||||
self._test_focus_obtained_by_long_press(self._input, self._contenteditable)
|
||||
|
||||
def test_contenteditable_focus_obtained_by_long_press_from_textarea(self):
|
||||
self.openTestHtml(enabled=True)
|
||||
self._test_focus_obtained_by_long_press(self._textarea, self._contenteditable)
|
||||
|
||||
def test_contenteditable_focus_obtained_by_long_press_from_content_non_editable(self):
|
||||
self.openTestHtml(enabled=True)
|
||||
self._test_focus_obtained_by_long_press(self._content, self._contenteditable)
|
||||
|
||||
########################################################################
|
||||
# <div> contenteditable test cases with selection carets disabled
|
||||
########################################################################
|
||||
@ -296,16 +218,3 @@ class SelectionCaretsTest(MarionetteTestCase):
|
||||
def test_content_non_editable_minimum_select_one_character_by_selection(self):
|
||||
self.openTestHtml(enabled=True)
|
||||
self._test_minimum_select_one_character(self._content, self.assertEqual)
|
||||
|
||||
def test_content_non_editable_focus_obtained_by_long_press_from_input(self):
|
||||
self.openTestHtml(enabled=True)
|
||||
self._test_focus_obtained_by_long_press(self._input, self._content)
|
||||
|
||||
def test_content_non_editable_focus_obtained_by_long_press_from_textarea(self):
|
||||
self.openTestHtml(enabled=True)
|
||||
self._test_focus_obtained_by_long_press(self._textarea, self._content)
|
||||
|
||||
def test_content_non_editable_focus_obtained_by_long_press_from_contenteditable(self):
|
||||
self.openTestHtml(enabled=True)
|
||||
self._test_focus_obtained_by_long_press(self._contenteditable, self._content)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user