gecko-dev/layout/base/tests/marionette/test_accessiblecaret_select...

629 строки
27 KiB
Python
Исходник Обычный вид История

# -*- 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 re
from marionette_driver.by import By
from marionette_driver.marionette import Actions
from marionette_driver.selection import SelectionManager
Bug 1320073 - Rename marionette-client to marionette-harness and release version 4.0.0. r=gps,maja_zf,mtseng,SingingTree MozReview-Commit-ID: L6V3b5h8RWm --HG-- rename : testing/marionette/harness/marionette/chrome/test.xul => testing/marionette/chrome/test.xul rename : testing/marionette/harness/marionette/chrome/test2.xul => testing/marionette/chrome/test2.xul rename : testing/marionette/harness/marionette/chrome/test_anonymous_content.xul => testing/marionette/chrome/test_anonymous_content.xul rename : testing/marionette/harness/marionette/chrome/test_dialog.xul => testing/marionette/chrome/test_dialog.xul rename : testing/marionette/harness/marionette/chrome/test_nested_iframe.xul => testing/marionette/chrome/test_nested_iframe.xul rename : testing/marionette/harness/marionette/__init__.py => testing/marionette/harness/marionette_harness/__init__.py rename : testing/marionette/harness/marionette/marionette_test/__init__.py => testing/marionette/harness/marionette_harness/marionette_test/__init__.py rename : testing/marionette/harness/marionette/marionette_test/decorators.py => testing/marionette/harness/marionette_harness/marionette_test/decorators.py rename : testing/marionette/harness/marionette/marionette_test/errors.py => testing/marionette/harness/marionette_harness/marionette_test/errors.py rename : testing/marionette/harness/marionette/marionette_test/testcases.py => testing/marionette/harness/marionette_harness/marionette_test/testcases.py rename : testing/marionette/harness/marionette/runner/__init__.py => testing/marionette/harness/marionette_harness/runner/__init__.py rename : testing/marionette/harness/marionette/runner/base.py => testing/marionette/harness/marionette_harness/runner/base.py rename : testing/marionette/harness/marionette/runner/httpd.py => testing/marionette/harness/marionette_harness/runner/httpd.py rename : testing/marionette/harness/marionette/runner/mixins/__init__.py => testing/marionette/harness/marionette_harness/runner/mixins/__init__.py rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/History.md => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/History.md rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/browsermobproxy/__init__.py => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/browsermobproxy/__init__.py rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/browsermobproxy/client.py => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/browsermobproxy/client.py rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/browsermobproxy/server.py => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/browsermobproxy/server.py rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/browsermobproxy/webdriver_event_listener.py => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/browsermobproxy/webdriver_event_listener.py rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/Makefile => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/Makefile rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/.buildinfo => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/.buildinfo rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/_modules/browsermobproxy.html => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/_modules/browsermobproxy.html rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/_modules/index.html => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/_modules/index.html rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/_sources/client.txt => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/_sources/client.txt rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/_sources/index.txt => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/_sources/index.txt rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/_sources/server.txt => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/_sources/server.txt rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/_static/basic.css => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/_static/basic.css rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/_static/default.css => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/_static/default.css rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/_static/doctools.js => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/_static/doctools.js rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/_static/jquery.js => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/_static/jquery.js rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/_static/pygments.css => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/_static/pygments.css rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/_static/searchtools.js => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/_static/searchtools.js rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/_static/sidebar.js => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/_static/sidebar.js rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/_static/underscore.js => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/_static/underscore.js rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/_static/websupport.js => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/_static/websupport.js rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/client.html => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/client.html rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/genindex.html => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/genindex.html rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/index.html => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/index.html rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/objects.inv => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/objects.inv rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/py-modindex.html => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/py-modindex.html rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/search.html => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/search.html rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/searchindex.js => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/searchindex.js rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/_build/html/server.html => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/_build/html/server.html rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/client.rst => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/client.rst rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/conf.py => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/conf.py rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/index.rst => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/index.rst rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/make.bat => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/make.bat rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/docs/server.rst => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/server.rst rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/readme.md => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/readme.md rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/setup.py => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/setup.py rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/test/test_client.py => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/test/test_client.py rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/test/test_remote.py => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/test/test_remote.py rename : testing/marionette/harness/marionette/runner/mixins/browsermob-proxy-py/test/test_webdriver.py => testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/test/test_webdriver.py rename : testing/marionette/harness/marionette/runner/mixins/browsermob.py => testing/marionette/harness/marionette_harness/runner/mixins/browsermob.py rename : testing/marionette/harness/marionette/runner/mixins/window_manager.py => testing/marionette/harness/marionette_harness/runner/mixins/window_manager.py rename : testing/marionette/harness/marionette/runner/serve.py => testing/marionette/harness/marionette_harness/runner/serve.py rename : testing/marionette/harness/marionette/runner/test.cert => testing/marionette/harness/marionette_harness/runner/test.cert rename : testing/marionette/harness/marionette/runner/test.key => testing/marionette/harness/marionette_harness/runner/test.key rename : testing/marionette/harness/marionette/runtests.py => testing/marionette/harness/marionette_harness/runtests.py rename : testing/marionette/harness/marionette/tests/harness_unit/conftest.py => testing/marionette/harness/marionette_harness/tests/harness_unit/conftest.py rename : testing/marionette/harness/marionette/tests/harness_unit/test_httpd.py => testing/marionette/harness/marionette_harness/tests/harness_unit/test_httpd.py rename : testing/marionette/harness/marionette/tests/harness_unit/test_marionette_arguments.py => testing/marionette/harness/marionette_harness/tests/harness_unit/test_marionette_arguments.py rename : testing/marionette/harness/marionette/tests/harness_unit/test_marionette_harness.py => testing/marionette/harness/marionette_harness/tests/harness_unit/test_marionette_harness.py rename : testing/marionette/harness/marionette/tests/harness_unit/test_marionette_runner.py => testing/marionette/harness/marionette_harness/tests/harness_unit/test_marionette_runner.py rename : testing/marionette/harness/marionette/tests/harness_unit/test_marionette_test_result.py => testing/marionette/harness/marionette_harness/tests/harness_unit/test_marionette_test_result.py rename : testing/marionette/harness/marionette/tests/harness_unit/test_serve.py => testing/marionette/harness/marionette_harness/tests/harness_unit/test_serve.py rename : testing/marionette/harness/marionette/tests/unit-tests.ini => testing/marionette/harness/marionette_harness/tests/unit-tests.ini rename : testing/marionette/harness/marionette/tests/unit/importanotherscript.js => testing/marionette/harness/marionette_harness/tests/unit/importanotherscript.js rename : testing/marionette/harness/marionette/tests/unit/importscript.js => testing/marionette/harness/marionette_harness/tests/unit/importscript.js rename : testing/marionette/harness/marionette/tests/unit/mn-restartless-unsigned.xpi => testing/marionette/harness/marionette_harness/tests/unit/mn-restartless-unsigned.xpi rename : testing/marionette/harness/marionette/tests/unit/single_finger_functions.py => testing/marionette/harness/marionette_harness/tests/unit/single_finger_functions.py rename : testing/marionette/harness/marionette/tests/unit/test_about_pages.py => testing/marionette/harness/marionette_harness/tests/unit/test_about_pages.py rename : testing/marionette/harness/marionette/tests/unit/test_accessibility.py => testing/marionette/harness/marionette_harness/tests/unit/test_accessibility.py rename : testing/marionette/harness/marionette/tests/unit/test_addons.py => testing/marionette/harness/marionette_harness/tests/unit/test_addons.py rename : testing/marionette/harness/marionette/tests/unit/test_anonymous_content.py => testing/marionette/harness/marionette_harness/tests/unit/test_anonymous_content.py rename : testing/marionette/harness/marionette/tests/unit/test_browsermobproxy.py => testing/marionette/harness/marionette_harness/tests/unit/test_browsermobproxy.py rename : testing/marionette/harness/marionette/tests/unit/test_capabilities.py => testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py rename : testing/marionette/harness/marionette/tests/unit/test_certificates.py => testing/marionette/harness/marionette_harness/tests/unit/test_certificates.py rename : testing/marionette/harness/marionette/tests/unit/test_checkbox.py => testing/marionette/harness/marionette_harness/tests/unit/test_checkbox.py rename : testing/marionette/harness/marionette/tests/unit/test_checkbox_chrome.py => testing/marionette/harness/marionette_harness/tests/unit/test_checkbox_chrome.py rename : testing/marionette/harness/marionette/tests/unit/test_chrome.py => testing/marionette/harness/marionette_harness/tests/unit/test_chrome.py rename : testing/marionette/harness/marionette/tests/unit/test_chrome_async_finish.js => testing/marionette/harness/marionette_harness/tests/unit/test_chrome_async_finish.js rename : testing/marionette/harness/marionette/tests/unit/test_chrome_element_css.py => testing/marionette/harness/marionette_harness/tests/unit/test_chrome_element_css.py rename : testing/marionette/harness/marionette/tests/unit/test_clearing.py => testing/marionette/harness/marionette_harness/tests/unit/test_clearing.py rename : testing/marionette/harness/marionette/tests/unit/test_click.py => testing/marionette/harness/marionette_harness/tests/unit/test_click.py rename : testing/marionette/harness/marionette/tests/unit/test_click_chrome.py => testing/marionette/harness/marionette_harness/tests/unit/test_click_chrome.py rename : testing/marionette/harness/marionette/tests/unit/test_click_scrolling.py => testing/marionette/harness/marionette_harness/tests/unit/test_click_scrolling.py rename : testing/marionette/harness/marionette/tests/unit/test_cookies.py => testing/marionette/harness/marionette_harness/tests/unit/test_cookies.py rename : testing/marionette/harness/marionette/tests/unit/test_crash.py => testing/marionette/harness/marionette_harness/tests/unit/test_crash.py rename : testing/marionette/harness/marionette/tests/unit/test_data_driven.py => testing/marionette/harness/marionette_harness/tests/unit/test_data_driven.py rename : testing/marionette/harness/marionette/tests/unit/test_date_time_value.py => testing/marionette/harness/marionette_harness/tests/unit/test_date_time_value.py rename : testing/marionette/harness/marionette/tests/unit/test_element_retrieval.py => testing/marionette/harness/marionette_harness/tests/unit/test_element_retrieval.py rename : testing/marionette/harness/marionette/tests/unit/test_element_state.py => testing/marionette/harness/marionette_harness/tests/unit/test_element_state.py rename : testing/marionette/harness/marionette/tests/unit/test_element_state_chrome.py => testing/marionette/harness/marionette_harness/tests/unit/test_element_state_chrome.py rename : testing/marionette/harness/marionette/tests/unit/test_elementsize.py => testing/marionette/harness/marionette_harness/tests/unit/test_elementsize.py rename : testing/marionette/harness/marionette/tests/unit/test_elementsize_chrome.py => testing/marionette/harness/marionette_harness/tests/unit/test_elementsize_chrome.py rename : testing/marionette/harness/marionette/tests/unit/test_errors.py => testing/marionette/harness/marionette_harness/tests/unit/test_errors.py rename : testing/marionette/harness/marionette/tests/unit/test_execute_async_script.py => testing/marionette/harness/marionette_harness/tests/unit/test_execute_async_script.py rename : testing/marionette/harness/marionette/tests/unit/test_execute_isolate.py => testing/marionette/harness/marionette_harness/tests/unit/test_execute_isolate.py rename : testing/marionette/harness/marionette/tests/unit/test_execute_sandboxes.py => testing/marionette/harness/marionette_harness/tests/unit/test_execute_sandboxes.py rename : testing/marionette/harness/marionette/tests/unit/test_execute_script.py => testing/marionette/harness/marionette_harness/tests/unit/test_execute_script.py rename : testing/marionette/harness/marionette/tests/unit/test_expected.py => testing/marionette/harness/marionette_harness/tests/unit/test_expected.py rename : testing/marionette/harness/marionette/tests/unit/test_expectedfail.py => testing/marionette/harness/marionette_harness/tests/unit/test_expectedfail.py rename : testing/marionette/harness/marionette/tests/unit/test_file_upload.py => testing/marionette/harness/marionette_harness/tests/unit/test_file_upload.py rename : testing/marionette/harness/marionette/tests/unit/test_findelement_chrome.py => testing/marionette/harness/marionette_harness/tests/unit/test_findelement_chrome.py rename : testing/marionette/harness/marionette/tests/unit/test_geckoinstance.py => testing/marionette/harness/marionette_harness/tests/unit/test_geckoinstance.py rename : testing/marionette/harness/marionette/tests/unit/test_getactiveframe_oop.py => testing/marionette/harness/marionette_harness/tests/unit/test_getactiveframe_oop.py rename : testing/marionette/harness/marionette/tests/unit/test_implicit_waits.py => testing/marionette/harness/marionette_harness/tests/unit/test_implicit_waits.py rename : testing/marionette/harness/marionette/tests/unit/test_import_script.py => testing/marionette/harness/marionette_harness/tests/unit/test_import_script.py rename : testing/marionette/harness/marionette/tests/unit/test_key_actions.py => testing/marionette/harness/marionette_harness/tests/unit/test_key_actions.py rename : testing/marionette/harness/marionette/tests/unit/test_localization.py => testing/marionette/harness/marionette_harness/tests/unit/test_localization.py rename : testing/marionette/harness/marionette/tests/unit/test_log.py => testing/marionette/harness/marionette_harness/tests/unit/test_log.py rename : testing/marionette/harness/marionette/tests/unit/test_marionette.py => testing/marionette/harness/marionette_harness/tests/unit/test_marionette.py rename : testing/marionette/harness/marionette/tests/unit/test_modal_dialogs.py => testing/marionette/harness/marionette_harness/tests/unit/test_modal_dialogs.py rename : testing/marionette/harness/marionette/tests/unit/test_mouse_action.py => testing/marionette/harness/marionette_harness/tests/unit/test_mouse_action.py rename : testing/marionette/harness/marionette/tests/unit/test_navigation.py => testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py rename : testing/marionette/harness/marionette/tests/unit/test_pagesource.py => testing/marionette/harness/marionette_harness/tests/unit/test_pagesource.py rename : testing/marionette/harness/marionette/tests/unit/test_pagesource_chrome.py => testing/marionette/harness/marionette_harness/tests/unit/test_pagesource_chrome.py rename : testing/marionette/harness/marionette/tests/unit/test_position.py => testing/marionette/harness/marionette_harness/tests/unit/test_position.py rename : testing/marionette/harness/marionette/tests/unit/test_prefs.py => testing/marionette/harness/marionette_harness/tests/unit/test_prefs.py rename : testing/marionette/harness/marionette/tests/unit/test_profile_management.py => testing/marionette/harness/marionette_harness/tests/unit/test_profile_management.py rename : testing/marionette/harness/marionette/tests/unit/test_proxy.py => testing/marionette/harness/marionette_harness/tests/unit/test_proxy.py rename : testing/marionette/harness/marionette/tests/unit/test_quit_restart.py => testing/marionette/harness/marionette_harness/tests/unit/test_quit_restart.py rename : testing/marionette/harness/marionette/tests/unit/test_rendered_element.py => testing/marionette/harness/marionette_harness/tests/unit/test_rendered_element.py rename : testing/marionette/harness/marionette/tests/unit/test_report.py => testing/marionette/harness/marionette_harness/tests/unit/test_report.py rename : testing/marionette/harness/marionette/tests/unit/test_run_js_test.py => testing/marionette/harness/marionette_harness/tests/unit/test_run_js_test.py rename : testing/marionette/harness/marionette/tests/unit/test_screen_orientation.py => testing/marionette/harness/marionette_harness/tests/unit/test_screen_orientation.py rename : testing/marionette/harness/marionette/tests/unit/test_screenshot.py => testing/marionette/harness/marionette_harness/tests/unit/test_screenshot.py rename : testing/marionette/harness/marionette/tests/unit/test_select.py => testing/marionette/harness/marionette_harness/tests/unit/test_select.py rename : testing/marionette/harness/marionette/tests/unit/test_session.py => testing/marionette/harness/marionette_harness/tests/unit/test_session.py rename : testing/marionette/harness/marionette/tests/unit/test_set_window_size.py => testing/marionette/harness/marionette_harness/tests/unit/test_set_window_size.py rename : testing/marionette/harness/marionette/tests/unit/test_shadow_dom.py => testing/marionette/harness/marionette_harness/tests/unit/test_shadow_dom.py rename : testing/marionette/harness/marionette/tests/unit/test_simpletest_chrome.js => testing/marionette/harness/marionette_harness/tests/unit/test_simpletest_chrome.js rename : testing/marionette/harness/marionette/tests/unit/test_simpletest_fail.js => testing/marionette/harness/marionette_harness/tests/unit/test_simpletest_fail.js rename : testing/marionette/harness/marionette/tests/unit/test_simpletest_pass.js => testing/marionette/harness/marionette_harness/tests/unit/test_simpletest_pass.js rename : testing/marionette/harness/marionette/tests/unit/test_simpletest_sanity.py => testing/marionette/harness/marionette_harness/tests/unit/test_simpletest_sanity.py rename : testing/marionette/harness/marionette/tests/unit/test_simpletest_timeout.js => testing/marionette/harness/marionette_harness/tests/unit/test_simpletest_timeout.js rename : testing/marionette/harness/marionette/tests/unit/test_single_finger_desktop.py => testing/marionette/harness/marionette_harness/tests/unit/test_single_finger_desktop.py rename : testing/marionette/harness/marionette/tests/unit/test_skip_setup.py => testing/marionette/harness/marionette_harness/tests/unit/test_skip_setup.py rename : testing/marionette/harness/marionette/tests/unit/test_switch_frame.py => testing/marionette/harness/marionette_harness/tests/unit/test_switch_frame.py rename : testing/marionette/harness/marionette/tests/unit/test_switch_frame_chrome.py => testing/marionette/harness/marionette_harness/tests/unit/test_switch_frame_chrome.py rename : testing/marionette/harness/marionette/tests/unit/test_switch_remote_frame.py => testing/marionette/harness/marionette_harness/tests/unit/test_switch_remote_frame.py rename : testing/marionette/harness/marionette/tests/unit/test_teardown_context_preserved.py => testing/marionette/harness/marionette_harness/tests/unit/test_teardown_context_preserved.py rename : testing/marionette/harness/marionette/tests/unit/test_text.py => testing/marionette/harness/marionette_harness/tests/unit/test_text.py rename : testing/marionette/harness/marionette/tests/unit/test_text_chrome.py => testing/marionette/harness/marionette_harness/tests/unit/test_text_chrome.py rename : testing/marionette/harness/marionette/tests/unit/test_timeouts.py => testing/marionette/harness/marionette_harness/tests/unit/test_timeouts.py rename : testing/marionette/harness/marionette/tests/unit/test_transport.py => testing/marionette/harness/marionette_harness/tests/unit/test_transport.py rename : testing/marionette/harness/marionette/tests/unit/test_typing.py => testing/marionette/harness/marionette_harness/tests/unit/test_typing.py rename : testing/marionette/harness/marionette/tests/unit/test_using_permissions.py => testing/marionette/harness/marionette_harness/tests/unit/test_using_permissions.py rename : testing/marionette/harness/marionette/tests/unit/test_visibility.py => testing/marionette/harness/marionette_harness/tests/unit/test_visibility.py rename : testing/marionette/harness/marionette/tests/unit/test_wait.py => testing/marionette/harness/marionette_harness/tests/unit/test_wait.py rename : testing/marionette/harness/marionette/tests/unit/test_window_handles.py => testing/marionette/harness/marionette_harness/tests/unit/test_window_handles.py rename : testing/marionette/harness/marionette/tests/unit/test_window_management.py => testing/marionette/harness/marionette_harness/tests/unit/test_window_management.py rename : testing/marionette/harness/marionette/tests/unit/test_window_position.py => testing/marionette/harness/marionette_harness/tests/unit/test_window_position.py rename : testing/marionette/harness/marionette/tests/unit/test_window_switching.py => testing/marionette/harness/marionette_harness/tests/unit/test_window_switching.py rename : testing/marionette/harness/marionette/tests/unit/test_window_title.py => testing/marionette/harness/marionette_harness/tests/unit/test_window_title.py rename : testing/marionette/harness/marionette/tests/unit/test_window_title_chrome.py => testing/marionette/harness/marionette_harness/tests/unit/test_window_title_chrome.py rename : testing/marionette/harness/marionette/tests/unit/test_window_type.py => testing/marionette/harness/marionette_harness/tests/unit/test_window_type.py rename : testing/marionette/harness/marionette/tests/unit/test_with_using_context.py => testing/marionette/harness/marionette_harness/tests/unit/test_with_using_context.py rename : testing/marionette/harness/marionette/tests/unit/unit-tests.ini => testing/marionette/harness/marionette_harness/tests/unit/unit-tests.ini rename : testing/marionette/harness/marionette/tests/webapi-tests.ini => testing/marionette/harness/marionette_harness/tests/webapi-tests.ini rename : testing/marionette/harness/marionette/www/bug814037.html => testing/marionette/harness/marionette_harness/www/bug814037.html rename : testing/marionette/harness/marionette/www/click_out_of_bounds_overflow.html => testing/marionette/harness/marionette_harness/www/click_out_of_bounds_overflow.html rename : testing/marionette/harness/marionette/www/clicks.html => testing/marionette/harness/marionette_harness/www/clicks.html rename : testing/marionette/harness/marionette/www/cssTransform.html => testing/marionette/harness/marionette_harness/www/cssTransform.html rename : testing/marionette/harness/marionette/www/cssTransform2.html => testing/marionette/harness/marionette_harness/www/cssTransform2.html rename : testing/marionette/harness/marionette/www/datetimePage.html => testing/marionette/harness/marionette_harness/www/datetimePage.html rename : testing/marionette/harness/marionette/www/deletingFrame.html => testing/marionette/harness/marionette_harness/www/deletingFrame.html rename : testing/marionette/harness/marionette/www/double_click.html => testing/marionette/harness/marionette_harness/www/double_click.html rename : testing/marionette/harness/marionette/www/element_bottom.html => testing/marionette/harness/marionette_harness/www/element_bottom.html rename : testing/marionette/harness/marionette/www/element_left.html => testing/marionette/harness/marionette_harness/www/element_left.html rename : testing/marionette/harness/marionette/www/element_outside_viewport.html => testing/marionette/harness/marionette_harness/www/element_outside_viewport.html rename : testing/marionette/harness/marionette/www/element_right.html => testing/marionette/harness/marionette_harness/www/element_right.html rename : testing/marionette/harness/marionette/www/element_top.html => testing/marionette/harness/marionette_harness/www/element_top.html rename : testing/marionette/harness/marionette/www/empty.html => testing/marionette/harness/marionette_harness/www/empty.html rename : testing/marionette/harness/marionette/www/formPage.html => testing/marionette/harness/marionette_harness/www/formPage.html rename : testing/marionette/harness/marionette/www/frameset.html => testing/marionette/harness/marionette_harness/www/frameset.html rename : testing/marionette/harness/marionette/www/framesetPage2.html => testing/marionette/harness/marionette_harness/www/framesetPage2.html rename : testing/marionette/harness/marionette/www/hidden.html => testing/marionette/harness/marionette_harness/www/hidden.html rename : testing/marionette/harness/marionette/www/html5/blue.jpg => testing/marionette/harness/marionette_harness/www/html5/blue.jpg rename : testing/marionette/harness/marionette/www/html5/boolean_attributes.html => testing/marionette/harness/marionette_harness/www/html5/boolean_attributes.html rename : testing/marionette/harness/marionette/www/html5/geolocation.js => testing/marionette/harness/marionette_harness/www/html5/geolocation.js rename : testing/marionette/harness/marionette/www/html5/green.jpg => testing/marionette/harness/marionette_harness/www/html5/green.jpg rename : testing/marionette/harness/marionette/www/html5/offline.html => testing/marionette/harness/marionette_harness/www/html5/offline.html rename : testing/marionette/harness/marionette/www/html5/red.jpg => testing/marionette/harness/marionette_harness/www/html5/red.jpg rename : testing/marionette/harness/marionette/www/html5/status.html => testing/marionette/harness/marionette_harness/www/html5/status.html rename : testing/marionette/harness/marionette/www/html5/test.appcache => testing/marionette/harness/marionette_harness/www/html5/test.appcache rename : testing/marionette/harness/marionette/www/html5/test_html_inputs.html => testing/marionette/harness/marionette_harness/www/html5/test_html_inputs.html rename : testing/marionette/harness/marionette/www/html5/yellow.jpg => testing/marionette/harness/marionette_harness/www/html5/yellow.jpg rename : testing/marionette/harness/marionette/www/html5Page.html => testing/marionette/harness/marionette_harness/www/html5Page.html rename : testing/marionette/harness/marionette/www/javascriptPage.html => testing/marionette/harness/marionette_harness/www/javascriptPage.html rename : testing/marionette/harness/marionette/www/macbeth.html => testing/marionette/harness/marionette_harness/www/macbeth.html rename : testing/marionette/harness/marionette/www/modal_dialogs.html => testing/marionette/harness/marionette_harness/www/modal_dialogs.html rename : testing/marionette/harness/marionette/www/nestedElements.html => testing/marionette/harness/marionette_harness/www/nestedElements.html rename : testing/marionette/harness/marionette/www/rectangles.html => testing/marionette/harness/marionette_harness/www/rectangles.html rename : testing/marionette/harness/marionette/www/resultPage.html => testing/marionette/harness/marionette_harness/www/resultPage.html rename : testing/marionette/harness/marionette/www/scroll.html => testing/marionette/harness/marionette_harness/www/scroll.html rename : testing/marionette/harness/marionette/www/scroll2.html => testing/marionette/harness/marionette_harness/www/scroll2.html rename : testing/marionette/harness/marionette/www/scroll3.html => testing/marionette/harness/marionette_harness/www/scroll3.html rename : testing/marionette/harness/marionette/www/scroll4.html => testing/marionette/harness/marionette_harness/www/scroll4.html rename : testing/marionette/harness/marionette/www/scroll5.html => testing/marionette/harness/marionette_harness/www/scroll5.html rename : testing/marionette/harness/marionette/www/shim.js => testing/marionette/harness/marionette_harness/www/shim.js rename : testing/marionette/harness/marionette/www/test.html => testing/marionette/harness/marionette_harness/www/test.html rename : testing/marionette/harness/marionette/www/testAction.html => testing/marionette/harness/marionette_harness/www/testAction.html rename : testing/marionette/harness/marionette/www/testPageSource.html => testing/marionette/harness/marionette_harness/www/testPageSource.html rename : testing/marionette/harness/marionette/www/testPageSource.xml => testing/marionette/harness/marionette_harness/www/testPageSource.xml rename : testing/marionette/harness/marionette/www/testPageSourceWithUnicodeChars.html => testing/marionette/harness/marionette_harness/www/testPageSourceWithUnicodeChars.html rename : testing/marionette/harness/marionette/www/testSize.html => testing/marionette/harness/marionette_harness/www/testSize.html rename : testing/marionette/harness/marionette/www/test_accessibility.html => testing/marionette/harness/marionette_harness/www/test_accessibility.html rename : testing/marionette/harness/marionette/www/test_carets_columns.html => testing/marionette/harness/marionette_harness/www/test_carets_columns.html rename : testing/marionette/harness/marionette/www/test_carets_cursor.html => testing/marionette/harness/marionette_harness/www/test_carets_cursor.html rename : testing/marionette/harness/marionette/www/test_carets_display_none.html => testing/marionette/harness/marionette_harness/www/test_carets_display_none.html rename : testing/marionette/harness/marionette/www/test_carets_iframe.html => testing/marionette/harness/marionette_harness/www/test_carets_iframe.html rename : testing/marionette/harness/marionette/www/test_carets_longtext.html => testing/marionette/harness/marionette_harness/www/test_carets_longtext.html rename : testing/marionette/harness/marionette/www/test_carets_multipleline.html => testing/marionette/harness/marionette_harness/www/test_carets_multipleline.html rename : testing/marionette/harness/marionette/www/test_carets_multiplerange.html => testing/marionette/harness/marionette_harness/www/test_carets_multiplerange.html rename : testing/marionette/harness/marionette/www/test_carets_selection.html => testing/marionette/harness/marionette_harness/www/test_carets_selection.html rename : testing/marionette/harness/marionette/www/test_clearing.html => testing/marionette/harness/marionette_harness/www/test_clearing.html rename : testing/marionette/harness/marionette/www/test_dynamic.html => testing/marionette/harness/marionette_harness/www/test_dynamic.html rename : testing/marionette/harness/marionette/www/test_iframe.html => testing/marionette/harness/marionette_harness/www/test_iframe.html rename : testing/marionette/harness/marionette/www/test_inner_iframe.html => testing/marionette/harness/marionette_harness/www/test_inner_iframe.html rename : testing/marionette/harness/marionette/www/test_nested_iframe.html => testing/marionette/harness/marionette_harness/www/test_nested_iframe.html rename : testing/marionette/harness/marionette/www/test_oop_1.html => testing/marionette/harness/marionette_harness/www/test_oop_1.html rename : testing/marionette/harness/marionette/www/test_oop_2.html => testing/marionette/harness/marionette_harness/www/test_oop_2.html rename : testing/marionette/harness/marionette/www/test_shadow_dom.html => testing/marionette/harness/marionette_harness/www/test_shadow_dom.html rename : testing/marionette/harness/marionette/www/test_windows.html => testing/marionette/harness/marionette_harness/www/test_windows.html rename : testing/marionette/harness/marionette/www/windowHandles.html => testing/marionette/harness/marionette_harness/www/windowHandles.html rename : testing/marionette/harness/marionette/www/xhtmlTest.html => testing/marionette/harness/marionette_harness/www/xhtmlTest.html extra : rebase_source : 67058d4aaa858732563fda6790c3176071c6bd60
2016-12-12 15:05:34 +03:00
from marionette_harness.marionette_test import (
MarionetteTestCase,
SkipTest,
parameterized
)
def skip_if_not_rotatable(target):
def wrapper(self, *args, **kwargs):
if not self.marionette.session_capabilities.get('rotatable'):
raise SkipTest('skipping due to device not rotatable')
return target(self, *args, **kwargs)
return wrapper
class AccessibleCaretSelectionModeTestCase(MarionetteTestCase):
'''Test cases for AccessibleCaret under selection mode.'''
# Element IDs.
_input_id = 'input'
_input_padding_id = 'input-padding'
_input_size_id = 'input-size'
_textarea_id = 'textarea'
_textarea2_id = 'textarea2'
_textarea_one_line_id = 'textarea-one-line'
_textarea_rtl_id = 'textarea-rtl'
_contenteditable_id = 'contenteditable'
_contenteditable2_id = 'contenteditable2'
_content_id = 'content'
_content2_id = 'content2'
_non_selectable_id = 'non-selectable'
# Test html files.
_selection_html = 'test_carets_selection.html'
_multipleline_html = 'test_carets_multipleline.html'
_multiplerange_html = 'test_carets_multiplerange.html'
_longtext_html = 'test_carets_longtext.html'
_iframe_html = 'test_carets_iframe.html'
_display_none_html = 'test_carets_display_none.html'
def setUp(self):
# Code to execute before every test is running.
super(AccessibleCaretSelectionModeTestCase, self).setUp()
self.carets_tested_pref = 'layout.accessiblecaret.enabled'
self.prefs = {
'layout.word_select.eat_space_to_next_word': False,
self.carets_tested_pref: True,
}
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))
def word_offset(self, text, ordinal):
'Get the character offset of the ordinal-th word in text.'
tokens = re.split(r'(\S+)', text) # both words and spaces
spaces = tokens[0::2] # collect spaces at odd indices
words = tokens[1::2] # collect word at even indices
if ordinal >= len(words):
raise IndexError('Only %d words in text, but got ordinal %d' %
(len(words), ordinal))
# Cursor position of the targeting word is behind the the first
# character in the word. For example, offset to 'def' in 'abc def' is
# between 'd' and 'e'.
offset = len(spaces[0]) + 1
offset += sum(len(words[i]) + len(spaces[i + 1]) for i in range(ordinal))
return offset
def test_word_offset(self):
text = ' ' * 3 + 'abc' + ' ' * 3 + 'def'
self.assertTrue(self.word_offset(text, 0), 4)
self.assertTrue(self.word_offset(text, 1), 10)
with self.assertRaises(IndexError):
self.word_offset(text, 2)
def word_location(self, el, ordinal):
'''Get the location (x, y) of the ordinal-th word in el.
The ordinal starts from 0.
Note: this function has a side effect which changes focus to the
target element el.
'''
sel = SelectionManager(el)
offset = self.word_offset(sel.content, ordinal)
# Move the blinking cursor to the word.
el.tap()
sel.move_cursor_to_front()
sel.move_cursor_by_offset(offset)
x, y = sel.cursor_location()
return x, y
def rect_relative_to_window(self, el):
'''Get element's bounding rectangle.
This function is similar to el.rect, but the coordinate is relative to
the top left corner of the window instead of the document.
'''
return self.marionette.execute_script('''
let rect = arguments[0].getBoundingClientRect();
return {x: rect.x, y:rect.y, width: rect.width, height: rect.height};
''', script_args=[el])
def long_press_on_location(self, el, x=None, y=None):
'''Long press the location (x, y) to select a word.
If no (x, y) are given, it will be targeted at the center of the
element. On Windows, those spaces after the word will also be selected.
This function sends synthesized eMouseLongTap to gecko.
'''
rect = self.rect_relative_to_window(el)
target_x = rect['x'] + (x if x is not None else rect['width'] // 2)
target_y = rect['y'] + (y if y is not None else rect['height'] // 2)
self.marionette.execute_script('''
let Ci = Components.interfaces;
let utils = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
utils.sendTouchEventToWindow('touchstart', [0],
[arguments[0]], [arguments[1]],
[1], [1], [0], [1], 1, 0);
utils.sendMouseEventToWindow('mouselongtap', arguments[0], arguments[1],
0, 1, 0);
utils.sendTouchEventToWindow('touchend', [0],
[arguments[0]], [arguments[1]],
[1], [1], [0], [1], 1, 0);
''', script_args=[target_x, target_y], sandbox='system')
def long_press_on_word(self, el, wordOrdinal):
x, y = self.word_location(el, wordOrdinal)
self.long_press_on_location(el, x, y)
def to_unix_line_ending(self, s):
"""Changes all Windows/Mac line endings in s to UNIX line endings."""
return s.replace('\r\n', '\n').replace('\r', '\n')
@parameterized(_input_id, el_id=_input_id)
@parameterized(_textarea_id, el_id=_textarea_id)
@parameterized(_textarea_rtl_id, el_id=_textarea_rtl_id)
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
@parameterized(_content_id, el_id=_content_id)
def test_long_press_to_select_a_word(self, el_id):
self.open_test_html(self._selection_html)
el = self.marionette.find_element(By.ID, el_id)
self._test_long_press_to_select_a_word(el)
def _test_long_press_to_select_a_word(self, el):
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 2, 'Expect at least two words in the content.')
target_content = words[0]
# Goal: Select the first word.
self.long_press_on_word(el, 0)
# Ignore extra spaces selected after the word.
self.assertEqual(target_content, sel.selected_content)
@parameterized(_input_id, el_id=_input_id)
@parameterized(_textarea_id, el_id=_textarea_id)
@parameterized(_textarea_rtl_id, el_id=_textarea_rtl_id)
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
@parameterized(_content_id, el_id=_content_id)
def test_drag_carets(self, el_id):
self.open_test_html(self._selection_html)
el = self.marionette.find_element(By.ID, el_id)
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 1, 'Expect at least one word in the content.')
# Goal: Select all text after the first word.
target_content = original_content[len(words[0]):]
# Get the location of the carets at the end of the content for later
# use.
el.tap()
sel.select_all()
end_caret_x, end_caret_y = sel.second_caret_location()
self.long_press_on_word(el, 0)
# Drag the second caret to the end of the content.
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.carets_location()
self.actions.flick(el, caret2_x, caret2_y, end_caret_x, end_caret_y).perform()
# Drag the first caret to the previous position of the second caret.
self.actions.flick(el, caret1_x, caret1_y, caret2_x, caret2_y).perform()
self.assertEqual(target_content, sel.selected_content)
@parameterized(_input_id, el_id=_input_id)
@parameterized(_textarea_id, el_id=_textarea_id)
@parameterized(_textarea_rtl_id, el_id=_textarea_rtl_id)
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
@parameterized(_content_id, el_id=_content_id)
def test_drag_swappable_carets(self, el_id):
self.open_test_html(self._selection_html)
el = self.marionette.find_element(By.ID, el_id)
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 1, 'Expect at least one word in the content.')
target_content1 = words[0]
target_content2 = original_content[len(words[0]):]
# Get the location of the carets at the end of the content for later
# use.
el.tap()
sel.select_all()
end_caret_x, end_caret_y = sel.second_caret_location()
self.long_press_on_word(el, 0)
# Drag the first caret to the end and back to where it was
# immediately. The selection range should not be collapsed.
caret1_x, caret1_y = sel.first_caret_location()
self.actions.flick(el, caret1_x, caret1_y, end_caret_x, end_caret_y)\
.flick(el, end_caret_x, end_caret_y, caret1_x, caret1_y).perform()
self.assertEqual(target_content1, sel.selected_content)
# Drag the first caret to the end.
caret1_x, caret1_y = sel.first_caret_location()
self.actions.flick(el, caret1_x, caret1_y, end_caret_x, end_caret_y).perform()
self.assertEqual(target_content2, sel.selected_content)
@parameterized(_input_id, el_id=_input_id)
@parameterized(_textarea_id, el_id=_textarea_id)
@parameterized(_textarea_rtl_id, el_id=_textarea_rtl_id)
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
@parameterized(_content_id, el_id=_content_id)
def test_minimum_select_one_character(self, el_id):
self.open_test_html(self._selection_html)
el = self.marionette.find_element(By.ID, el_id)
self._test_minimum_select_one_character(el)
@parameterized(_textarea2_id, el_id=_textarea2_id)
@parameterized(_contenteditable2_id, el_id=_contenteditable2_id)
@parameterized(_content2_id, el_id=_content2_id)
def test_minimum_select_one_character2(self, el_id):
self.open_test_html(self._multipleline_html)
el = self.marionette.find_element(By.ID, el_id)
self._test_minimum_select_one_character(el)
def _test_minimum_select_one_character(self, el, x=None, y=None):
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 1, 'Expect at least one word in the content.')
# Get the location of the carets at the end of the content for later
# use.
sel.select_all()
end_caret_x, end_caret_y = sel.second_caret_location()
el.tap()
# 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.word_location(el, 0)
self.long_press_on_location(el, x, y)
# Drag the second caret to the end of the content.
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.carets_location()
self.actions.flick(el, caret2_x, caret2_y, end_caret_x, end_caret_y).perform()
# Drag the second caret to the position of the first caret.
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.carets_location()
self.actions.flick(el, caret2_x, caret2_y, caret1_x, caret1_y).perform()
self.assertEqual(target_content, sel.selected_content)
@parameterized(_input_id + '_to_' + _textarea_id,
el1_id=_input_id, el2_id=_textarea_id)
@parameterized(_input_id + '_to_' + _contenteditable_id,
el1_id=_input_id, el2_id=_contenteditable_id)
@parameterized(_input_id + '_to_' + _content_id,
el1_id=_input_id, el2_id=_content_id)
@parameterized(_textarea_id + '_to_' + _input_id,
el1_id=_textarea_id, el2_id=_input_id)
@parameterized(_textarea_id + '_to_' + _contenteditable_id,
el1_id=_textarea_id, el2_id=_contenteditable_id)
@parameterized(_textarea_id + '_to_' + _content_id,
el1_id=_textarea_id, el2_id=_content_id)
@parameterized(_contenteditable_id + '_to_' + _input_id,
el1_id=_contenteditable_id, el2_id=_input_id)
@parameterized(_contenteditable_id + '_to_' + _textarea_id,
el1_id=_contenteditable_id, el2_id=_textarea_id)
@parameterized(_contenteditable_id + '_to_' + _content_id,
el1_id=_contenteditable_id, el2_id=_content_id)
@parameterized(_content_id + '_to_' + _input_id,
el1_id=_content_id, el2_id=_input_id)
@parameterized(_content_id + '_to_' + _textarea_id,
el1_id=_content_id, el2_id=_textarea_id)
@parameterized(_content_id + '_to_' + _contenteditable_id,
el1_id=_content_id, el2_id=_contenteditable_id)
def test_long_press_changes_focus_from(self, el1_id, el2_id):
self.open_test_html(self._selection_html)
el1 = self.marionette.find_element(By.ID, el1_id)
el2 = self.marionette.find_element(By.ID, el2_id)
# Compute the content of the first word in el2.
sel = SelectionManager(el2)
original_content = sel.content
words = original_content.split()
target_content = words[0]
# Goal: Tap to focus el1, and then select the first word on el2.
# We want to collect the location of the first word in el2 here
# since self.word_location() has the side effect which would
# change the focus.
x, y = self.word_location(el2, 0)
el1.tap()
self.long_press_on_location(el2, x, y)
self.assertEqual(target_content, sel.selected_content)
@parameterized(_input_id, el_id=_input_id)
@parameterized(_textarea_id, el_id=_textarea_id)
@parameterized(_textarea_rtl_id, el_id=_textarea_rtl_id)
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
def test_focus_not_changed_by_long_press_on_non_selectable(self, el_id):
self.open_test_html(self._selection_html)
el = self.marionette.find_element(By.ID, el_id)
non_selectable = self.marionette.find_element(By.ID, self._non_selectable_id)
# Goal: Focus remains on the editable element el after long pressing on
# the non-selectable element.
sel = SelectionManager(el)
self.long_press_on_word(el, 0)
self.long_press_on_location(non_selectable)
active_sel = SelectionManager(self.marionette.get_active_element())
self.assertEqual(sel.content, active_sel.content)
@parameterized(_input_id, el_id=_input_id)
@parameterized(_textarea_id, el_id=_textarea_id)
@parameterized(_textarea_rtl_id, el_id=_textarea_rtl_id)
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
@parameterized(_content_id, el_id=_content_id)
def test_handle_tilt_when_carets_overlap_each_other(self, el_id):
'''Test tilt handling when carets overlap to each other.
Let the two carets overlap each other. If they are set to tilted
successfully, tapping the tilted carets should not cause the selection
to be collapsed and the carets should be draggable.
'''
self.open_test_html(self._selection_html)
el = self.marionette.find_element(By.ID, el_id)
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 1, 'Expect at least one word in the content.')
# Goal: Select the first word.
self.long_press_on_word(el, 0)
target_content = sel.selected_content
# Drag the first caret to the position of the second caret to trigger
# carets overlapping.
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.carets_location()
self.actions.flick(el, caret1_x, caret1_y, caret2_x, caret2_y).perform()
# We make two hit tests targeting the left edge of the left tilted caret
# and the right edge of the right tilted caret. If either of the hits is
# missed, selection would be collapsed and both carets should not be
# draggable.
(caret3_x, caret3_y), (caret4_x, caret4_y) = sel.carets_location()
# The following values are from ua.css and all.js
caret_width = float(self.marionette.get_pref('layout.accessiblecaret.width'))
caret_margin_left = float(self.marionette.get_pref('layout.accessiblecaret.margin-left'))
tilt_right_margin_left = 0.41 * caret_width
tilt_left_margin_left = -0.39 * caret_width
left_caret_left_edge_x = caret3_x + caret_margin_left + tilt_left_margin_left
el.tap(left_caret_left_edge_x + 2, caret3_y)
right_caret_right_edge_x = (caret4_x + caret_margin_left +
tilt_right_margin_left + caret_width)
el.tap(right_caret_right_edge_x - 2, caret4_y)
# Drag the first caret back to the initial selection, the first word.
self.actions.flick(el, caret3_x, caret3_y, caret1_x, caret1_y).perform()
self.assertEqual(target_content, sel.selected_content)
def test_drag_caret_over_non_selectable_field(self):
'''Test dragging the caret over a non-selectable field.
The selected content should exclude non-selectable elements and the
second caret should appear in last range's position.
'''
self.open_test_html(self._multiplerange_html)
body = self.marionette.find_element(By.ID, 'bd')
sel3 = self.marionette.find_element(By.ID, 'sel3')
sel4 = self.marionette.find_element(By.ID, 'sel4')
sel6 = self.marionette.find_element(By.ID, 'sel6')
# Select target element and get target caret location
self.long_press_on_word(sel4, 3)
sel = SelectionManager(body)
end_caret_x, end_caret_y = sel.second_caret_location()
self.long_press_on_word(sel6, 0)
end_caret2_x, end_caret2_y = sel.second_caret_location()
# Select start element
self.long_press_on_word(sel3, 3)
# Drag end caret to target location
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.carets_location()
self.actions.flick(body, caret2_x, caret2_y, end_caret_x, end_caret_y, 1).perform()
self.assertEqual(self.to_unix_line_ending(sel.selected_content.strip()),
'this 3\nuser can select this')
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.carets_location()
self.actions.flick(body, caret2_x, caret2_y, end_caret2_x, end_caret2_y, 1).perform()
self.assertEqual(self.to_unix_line_ending(sel.selected_content.strip()),
'this 3\nuser can select this 4\nuser can select this 5\nuser')
# Drag first caret to target location
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.carets_location()
self.actions.flick(body, caret1_x, caret1_y, end_caret_x, end_caret_y, 1).perform()
self.assertEqual(self.to_unix_line_ending(sel.selected_content.strip()),
'4\nuser can select this 5\nuser')
def test_drag_swappable_caret_over_non_selectable_field(self):
self.open_test_html(self._multiplerange_html)
body = self.marionette.find_element(By.ID, 'bd')
sel3 = self.marionette.find_element(By.ID, 'sel3')
sel4 = self.marionette.find_element(By.ID, 'sel4')
sel = SelectionManager(body)
self.long_press_on_word(sel4, 3)
(end_caret1_x, end_caret1_y), (end_caret2_x, end_caret2_y) = sel.carets_location()
self.long_press_on_word(sel3, 3)
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.carets_location()
# Drag the first caret down, which will across the second caret.
self.actions.flick(body, caret1_x, caret1_y, end_caret1_x, end_caret1_y).perform()
self.assertEqual(self.to_unix_line_ending(sel.selected_content.strip()),
'3\nuser can select')
# The old second caret becomes the first caret. Drag it down again.
self.actions.flick(body, caret2_x, caret2_y, end_caret2_x, end_caret2_y).perform()
self.assertEqual(self.to_unix_line_ending(sel.selected_content.strip()),
'this')
def test_drag_caret_to_beginning_of_a_line(self):
'''Bug 1094056
Test caret visibility when caret is dragged to beginning of a line
'''
self.open_test_html(self._multiplerange_html)
body = self.marionette.find_element(By.ID, 'bd')
sel1 = self.marionette.find_element(By.ID, 'sel1')
sel2 = self.marionette.find_element(By.ID, 'sel2')
# Select the first word in the second line
self.long_press_on_word(sel2, 0)
sel = SelectionManager(body)
(start_caret_x, start_caret_y), (end_caret_x, end_caret_y) = sel.carets_location()
# Select target word in the first line
self.long_press_on_word(sel1, 2)
# Drag end caret to the beginning of the second line
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.carets_location()
self.actions.flick(body, caret2_x, caret2_y, start_caret_x, start_caret_y).perform()
# Drag end caret back to the target word
self.actions.flick(body, start_caret_x, start_caret_y, caret2_x, caret2_y).perform()
self.assertEqual(self.to_unix_line_ending(sel.selected_content), 'select')
@skip_if_not_rotatable
def test_caret_position_after_changing_orientation_of_device(self):
'''Bug 1094072
If positions of carets are updated correctly, they should be draggable.
'''
self.open_test_html(self._longtext_html)
body = self.marionette.find_element(By.ID, 'bd')
longtext = self.marionette.find_element(By.ID, 'longtext')
# Select word in portrait mode, then change to landscape mode
self.marionette.set_orientation('portrait')
self.long_press_on_word(longtext, 12)
sel = SelectionManager(body)
(p_start_caret_x, p_start_caret_y), (p_end_caret_x, p_end_caret_y) = sel.carets_location()
self.marionette.set_orientation('landscape')
(l_start_caret_x, l_start_caret_y), (l_end_caret_x, l_end_caret_y) = sel.carets_location()
# Drag end caret to the start caret to change the selected content
self.actions.flick(body, l_end_caret_x, l_end_caret_y,
l_start_caret_x, l_start_caret_y).perform()
# Change orientation back to portrait mode to prevent affecting
# other tests
self.marionette.set_orientation('portrait')
self.assertEqual(self.to_unix_line_ending(sel.selected_content), 'o')
def test_select_word_inside_an_iframe(self):
'''Bug 1088552
The scroll offset in iframe should be taken into consideration properly.
In this test, we scroll content in the iframe to the bottom to cause a
huge offset. If we use the right coordinate system, selection should
work. Otherwise, it would be hard to trigger select word.
'''
self.open_test_html(self._iframe_html)
iframe = self.marionette.find_element(By.ID, 'frame')
# switch to inner iframe and scroll to the bottom
self.marionette.switch_to_frame(iframe)
self.marionette.execute_script(
'document.getElementById("bd").scrollTop += 999')
# long press to select bottom text
body = self.marionette.find_element(By.ID, 'bd')
sel = SelectionManager(body)
self._bottomtext = self.marionette.find_element(By.ID, 'bottomtext')
self.long_press_on_location(self._bottomtext)
self.assertNotEqual(self.to_unix_line_ending(sel.selected_content), '')
def test_carets_initialized_in_display_none(self):
'''Test AccessibleCaretEventHub is properly initialized on a <html> with
display: none.
'''
self.open_test_html(self._display_none_html)
html = self.marionette.find_element(By.ID, 'html')
content = self.marionette.find_element(By.ID, 'content')
# Remove 'display: none' from <html>
self.marionette.execute_script(
'arguments[0].style.display = "unset";',
script_args=[html]
)
# If AccessibleCaretEventHub is initialized successfully, select a word
# should work.
self._test_long_press_to_select_a_word(content)
def test_long_press_to_select_when_partial_visible_word_is_selected(self):
self.open_test_html(self._selection_html)
el = self.marionette.find_element(By.ID, self._input_size_id)
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
# We cannot use self.long_press_on_word() for the second long press
# on the first word because it has side effect that changes the
# cursor position. We need to save the location of the first word to
# be used later.
word0_x, word0_y = self.word_location(el, 0)
# Long press on the second word.
self.long_press_on_word(el, 1)
self.assertEqual(words[1], sel.selected_content)
# Long press on the first word.
self.long_press_on_location(el, word0_x, word0_y)
self.assertEqual(words[0], sel.selected_content)
# If the second caret is visible, it can be dragged to the position
# of the first caret. After that, selection will contain only the
# first character.
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.carets_location()
self.actions.flick(el, caret2_x, caret2_y, caret1_x, caret1_y).perform()
self.assertEqual(words[0][0], sel.selected_content)
@parameterized(_input_id, el_id=_input_id)
@parameterized(_input_padding_id, el_id=_input_padding_id)
@parameterized(_textarea_one_line_id, el_id=_textarea_one_line_id)
@parameterized(_contenteditable_id, el_id=_contenteditable_id)
def test_carets_not_jump_when_dragging_to_editable_content_boundary(self, el_id):
self.open_test_html(self._selection_html)
el = self.marionette.find_element(By.ID, el_id)
sel = SelectionManager(el)
original_content = sel.content
words = original_content.split()
self.assertTrue(len(words) >= 3, 'Expect at least three words in the content.')
# Goal: the selection is not changed after dragging the caret on the
# Y-axis.
target_content = words[1]
self.long_press_on_word(el, 1)
(caret1_x, caret1_y), (caret2_x, caret2_y) = sel.carets_location()
# Drag the first caret up by 50px.
self.actions.flick(el, caret1_x, caret1_y, caret1_x, caret1_y - 50).perform()
self.assertEqual(target_content, sel.selected_content)
# Drag the second caret down by 50px.
self.actions.flick(el, caret2_x, caret2_y, caret2_x, caret2_y + 50).perform()
self.assertEqual(target_content, sel.selected_content)