Bug 1206545 - Add a marionette test case. r=roc draft
authorTing-Yu Lin <tlin@mozilla.com>
Mon, 16 Nov 2015 18:16:43 +0800
changeset 308989 9c767b200a63777b3f20e85ebc3f83272e979bc9
parent 308988 0edef7db8004da2e2cde3d4510bb23f1e9cee61e
child 511234 ed9ddb7dbec0a8681f4cd53ff200733bc30397cb
push id7548
push usertlin@mozilla.com
push dateMon, 16 Nov 2015 10:17:13 +0000
reviewersroc
bugs1206545
milestone45.0a1
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>