From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- layout/base/tests/marionette/manifest.ini | 5 + .../marionette/test_accessiblecaret_cursor_mode.py | 298 ++++++++++ .../test_accessiblecaret_selection_mode.py | 632 +++++++++++++++++++++ 3 files changed, 935 insertions(+) create mode 100644 layout/base/tests/marionette/manifest.ini create mode 100644 layout/base/tests/marionette/test_accessiblecaret_cursor_mode.py create mode 100644 layout/base/tests/marionette/test_accessiblecaret_selection_mode.py (limited to 'layout/base/tests/marionette') diff --git a/layout/base/tests/marionette/manifest.ini b/layout/base/tests/marionette/manifest.ini new file mode 100644 index 000000000..98428ccf5 --- /dev/null +++ b/layout/base/tests/marionette/manifest.ini @@ -0,0 +1,5 @@ +[DEFAULT] +run-if = buildapp == 'browser' + +[test_accessiblecaret_cursor_mode.py] +[test_accessiblecaret_selection_mode.py] diff --git a/layout/base/tests/marionette/test_accessiblecaret_cursor_mode.py b/layout/base/tests/marionette/test_accessiblecaret_cursor_mode.py new file mode 100644 index 000000000..e330e4d70 --- /dev/null +++ b/layout/base/tests/marionette/test_accessiblecaret_cursor_mode.py @@ -0,0 +1,298 @@ +# -*- coding: utf-8 -*- +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +import string + +from marionette_driver.by import By +from marionette_driver.marionette import Actions +from marionette_driver.selection import SelectionManager +from marionette_harness.marionette_test import ( + MarionetteTestCase, + parameterized, +) + + +class AccessibleCaretCursorModeTestCase(MarionetteTestCase): + '''Test cases for AccessibleCaret under cursor mode. + + We call the blinking cursor (nsCaret) as cursor, and call AccessibleCaret as + caret for short. + + ''' + # Element IDs. + _input_id = 'input' + _input_padding_id = 'input-padding' + _textarea_id = 'textarea' + _textarea_one_line_id = 'textarea-one-line' + _contenteditable_id = 'contenteditable' + + # Test html files. + _cursor_html = 'test_carets_cursor.html' + + def setUp(self): + # Code to execute before every test is running. + super(AccessibleCaretCursorModeTestCase, self).setUp() + self.caret_tested_pref = 'layout.accessiblecaret.enabled' + self.caret_timeout_ms_pref = 'layout.accessiblecaret.timeout_ms' + self.hide_carets_for_mouse = 'layout.accessiblecaret.hide_carets_for_mouse_input' + self.prefs = { + self.caret_tested_pref: True, + self.caret_timeout_ms_pref: 0, + self.hide_carets_for_mouse: False, + } + self.marionette.set_prefs(self.prefs) + self.actions = Actions(self.marionette) + + def open_test_html(self, test_html): + self.marionette.navigate(self.marionette.absolute_url(test_html)) + + @parameterized(_input_id, el_id=_input_id) + @parameterized(_textarea_id, el_id=_textarea_id) + @parameterized(_contenteditable_id, el_id=_contenteditable_id) + def test_move_cursor_to_the_right_by_one_character(self, el_id): + self.open_test_html(self._cursor_html) + el = self.marionette.find_element(By.ID, el_id) + sel = SelectionManager(el) + content_to_add = '!' + target_content = sel.content + target_content = target_content[:1] + content_to_add + target_content[1:] + + # Get first caret (x, y) at position 1 and 2. + el.tap() + sel.move_cursor_to_front() + cursor0_x, cursor0_y = sel.cursor_location() + first_caret0_x, first_caret0_y = sel.first_caret_location() + sel.move_cursor_by_offset(1) + first_caret1_x, first_caret1_y = sel.first_caret_location() + + # Tap the front of the input to make first caret appear. + el.tap(cursor0_x, cursor0_y) + + # Move first caret. + self.actions.flick(el, first_caret0_x, first_caret0_y, + first_caret1_x, first_caret1_y).perform() + + self.actions.key_down(content_to_add).key_up(content_to_add).perform() + self.assertEqual(target_content, sel.content) + + @parameterized(_input_id, el_id=_input_id) + @parameterized(_textarea_id, el_id=_textarea_id) + @parameterized(_contenteditable_id, el_id=_contenteditable_id) + def test_move_cursor_to_end_by_dragging_caret_to_bottom_right_corner(self, el_id): + self.open_test_html(self._cursor_html) + el = self.marionette.find_element(By.ID, el_id) + sel = SelectionManager(el) + content_to_add = '!' + target_content = sel.content + content_to_add + + # Tap the front of the input to make first caret appear. + el.tap() + sel.move_cursor_to_front() + el.tap(*sel.cursor_location()) + + # Move first caret to the bottom-right corner of the element. + src_x, src_y = sel.first_caret_location() + dest_x, dest_y = el.size['width'], el.size['height'] + self.actions.flick(el, src_x, src_y, dest_x, dest_y).perform() + + self.actions.key_down(content_to_add).key_up(content_to_add).perform() + self.assertEqual(target_content, sel.content) + + @parameterized(_input_id, el_id=_input_id) + @parameterized(_textarea_id, el_id=_textarea_id) + @parameterized(_contenteditable_id, el_id=_contenteditable_id) + def test_move_cursor_to_front_by_dragging_caret_to_front(self, el_id): + self.open_test_html(self._cursor_html) + el = self.marionette.find_element(By.ID, el_id) + sel = SelectionManager(el) + content_to_add = '!' + target_content = content_to_add + sel.content + + # Get first caret location at the front. + el.tap() + sel.move_cursor_to_front() + dest_x, dest_y = sel.first_caret_location() + + # Tap to make first caret appear. Note: it's strange that when the caret + # is at the end, the rect of the caret in