Bug 1206545 - Add a marionette test case. r=roc

Test AccessibleCaretEventHub is properly initialized if <html> has
"display: none" initially.
This commit is contained in:
Ting-Yu Lin 2015-11-16 18:16:43 +08:00
parent 621c636afa
commit cdf85d3b0f
2 changed files with 35 additions and 0 deletions

View File

@ -79,6 +79,14 @@ class CommonCaretsTestCase(object):
self._iframe = self.marionette.find_element(By.ID, 'frame')
def open_test_html_display_none(self):
'Open html for testing html with display: none.'
test_html = self.marionette.absolute_url('test_carets_display_none.html')
self.marionette.navigate(test_html)
self._html = self.marionette.find_element(By.ID, 'html')
self._content = self.marionette.find_element(By.ID, 'content')
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
@ -437,6 +445,23 @@ class CommonCaretsTestCase(object):
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_display_none()
# Remove 'display: none' from <html>
self.marionette.execute_script(
'arguments[0].style.display = "unset";',
script_args=[self._html]
)
# If AccessibleCaretEventHub is initialized successfully, select a word
# should work.
self._test_long_press_to_select_a_word(self._content, self.assertEqual)
########################################################################
# <input> test cases with selection carets enabled
########################################################################

View File

@ -0,0 +1,10 @@
<!-- 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/. -->
<!DOCTYPE html>
<html id="html" style="display: none">
<body>
<div id="content">ABC DEF GHI</div>
</body>
</html>