Bug 1206545 - Add a marionette test case. r=roc
authorTing-Yu Lin <tlin@mozilla.com>
Mon, 16 Nov 2015 18:16:43 +0800
changeset 272916 a56e745bf9fe5ee9aaa22b8176e5d4852e7db955
parent 272915 89921d2c8dc400f4087df025c86023dfab335037
child 272917 5160a4dfba49bde4a8af379a2e1320766560df8c
push id29688
push userkwierso@gmail.com
push dateTue, 17 Nov 2015 21:10:09 +0000
treeherdermozilla-central@eed903a7e4e7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1206545
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1206545 - Add a marionette test case. r=roc Test AccessibleCaretEventHub is properly initialized if <html> has "display: none" initially.
layout/base/tests/marionette/test_selectioncarets.py
testing/marionette/client/marionette/www/test_carets_display_none.html
--- a/layout/base/tests/marionette/test_selectioncarets.py
+++ b/layout/base/tests/marionette/test_selectioncarets.py
@@ -74,16 +74,24 @@ class CommonCaretsTestCase(object):
 
     def open_test_html_iframe(self):
         'Open html for testing iframe.'
         test_html = self.marionette.absolute_url('test_selectioncarets_iframe.html')
         self.marionette.navigate(test_html)
 
         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
         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' %
@@ -432,16 +440,33 @@ class CommonCaretsTestCase(object):
         # long press to select bottom text
         self._body = self.marionette.find_element(By.ID, 'bd')
         sel = SelectionManager(self._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_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
     ########################################################################
     def test_input_long_press_to_select_a_word(self):
         self.open_test_html()
         self._test_long_press_to_select_a_word(self._input, self.assertEqual)
 
     def test_input_move_selection_carets(self):
new file mode 100644
--- /dev/null
+++ b/testing/marionette/client/marionette/www/test_carets_display_none.html
@@ -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>