Bug 1163490 - Remove SpecialPowers from marionette carets test. r=jgriffin
authorTing-Yu Lin <tlin@mozilla.com>
Mon, 11 May 2015 02:17:00 +0800
changeset 243636 33a09170386b045838d52218e1c9b13856b4b7cc
parent 243635 8ce6c874592a2a70c152c931a48353615b60cb0b
child 243637 3cfde06d952aafa82f9ba248e1b5493f2aa5900e
push id28744
push userkwierso@gmail.com
push dateWed, 13 May 2015 18:12:16 +0000
treeherdermozilla-central@324c3423deaf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgriffin
bugs1163490
milestone41.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 1163490 - Remove SpecialPowers from marionette carets test. r=jgriffin
layout/base/tests/marionette/test_selectioncarets.py
layout/base/tests/marionette/test_selectioncarets2.py
layout/base/tests/marionette/test_touchcaret.py
--- a/layout/base/tests/marionette/test_selectioncarets.py
+++ b/layout/base/tests/marionette/test_selectioncarets.py
@@ -43,25 +43,27 @@ class CommonCaretsTestCase(object):
 
         For example:
         >>> set_pref('layout.accessiblecaret.enabled', True)
 
         '''
         pref_name = repr(pref_name)
         if isinstance(value, bool):
             value = 'true' if value else 'false'
+            func = 'setBoolPref'
         elif isinstance(value, int):
             value = str(value)
+            func = 'setIntPref'
         else:
             value = repr(value)
+            func = 'setCharPref'
 
-        script = '''SpecialPowers.pushPrefEnv({"set": [[%s, %s]]}, marionetteScriptFinished);''' % (
-            pref_name, value)
-
-        self.marionette.execute_async_script(script)
+        with self.marionette.using_context('chrome'):
+            script = 'Services.prefs.%s(%s, %s)' % (func, pref_name, value)
+            self.marionette.execute_script(script)
 
     def open_test_html(self, enabled=True):
         '''Open html for testing and locate elements, and enable/disable touch
         caret.'''
         self.set_pref(self.carets_tested_pref, enabled)
         self.set_pref(self.carets_disabled_pref, False)
 
         test_html = self.marionette.absolute_url('test_selectioncarets.html')
--- a/layout/base/tests/marionette/test_selectioncarets2.py
+++ b/layout/base/tests/marionette/test_selectioncarets2.py
@@ -43,25 +43,27 @@ class CommonCaretsTestCase2(object):
 
         For example:
         >>> set_pref('layout.accessiblecaret.enabled', True)
 
         '''
         pref_name = repr(pref_name)
         if isinstance(value, bool):
             value = 'true' if value else 'false'
+            func = 'setBoolPref'
         elif isinstance(value, int):
             value = str(value)
+            func = 'setIntPref'
         else:
             value = repr(value)
+            func = 'setCharPref'
 
-        script = '''SpecialPowers.pushPrefEnv({"set": [[%s, %s]]}, marionetteScriptFinished);''' % (
-            pref_name, value)
-
-        self.marionette.execute_async_script(script)
+        with self.marionette.using_context('chrome'):
+            script = 'Services.prefs.%s(%s, %s)' % (func, pref_name, value)
+            self.marionette.execute_script(script)
 
     def open_test_html(self, enabled=True):
         'Open html for testing and enable selectioncaret and non-editable support'
         self.set_pref(self.carets_tested_pref, enabled)
         self.set_pref(self.carets_disabled_pref, False)
 
         test_html = self.marionette.absolute_url('test_selectioncarets_multiplerange.html')
         self.marionette.navigate(test_html)
--- a/layout/base/tests/marionette/test_touchcaret.py
+++ b/layout/base/tests/marionette/test_touchcaret.py
@@ -37,30 +37,33 @@ class CommonCaretTestCase(object):
 
         For example:
         >>> set_pref('layout.accessiblecaret.enabled', True)
 
         '''
         pref_name = repr(pref_name)
         if isinstance(value, bool):
             value = 'true' if value else 'false'
+            func = 'setBoolPref'
         elif isinstance(value, int):
             value = str(value)
+            func = 'setIntPref'
         else:
             value = repr(value)
+            func = 'setCharPref'
 
-        script = '''SpecialPowers.pushPrefEnv({"set": [[%s, %s]]}, marionetteScriptFinished);''' % (
-            pref_name, value)
-
-        self.marionette.execute_async_script(script)
+        with self.marionette.using_context('chrome'):
+            script = 'Services.prefs.%s(%s, %s)' % (func, pref_name, value)
+            self.marionette.execute_script(script)
 
     def timeout_ms(self):
         'Return touch caret expiration time in milliseconds.'
-        return self.marionette.execute_script(
-            'return SpecialPowers.getIntPref("%s");' % self.caret_timeout_ms_pref)
+        with self.marionette.using_context('chrome'):
+            return self.marionette.execute_script(
+                'return Services.prefs.getIntPref("%s");' % self.caret_timeout_ms_pref)
 
     def open_test_html(self, enabled=True, timeout_ms=0):
         '''Open html for testing and locate elements, enable/disable touch caret, and
         set touch caret expiration time in milliseconds).
 
         '''
         self.set_pref(self.caret_tested_pref, enabled)
         self.set_pref(self.caret_disabled_pref, False)
@@ -183,21 +186,25 @@ class CommonCaretTestCase(object):
 
         # Send an arbitrary scroll-down-10px wheel event to the center of the
         # input box to hide touch caret. Then pretend to move it to the top-left
         # corner of the input box.
         src_x, src_y = sel.touch_caret_location()
         dest_x, dest_y = 0, 0
         el_center_x, el_center_y = el.rect['x'], el.rect['y']
         self.marionette.execute_script(
-            '''var utils = SpecialPowers.getDOMWindowUtils(window);
+            '''
+            var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+                              .getInterface(Components.interfaces.nsIDOMWindowUtils);
             utils.sendWheelEvent(arguments[0], arguments[1],
                                  0, 10, 0, WheelEvent.DOM_DELTA_PIXEL,
-                                 0, 0, 0, 0);''',
-            script_args=[el_center_x, el_center_y]
+                                 0, 0, 0, 0);
+            ''',
+            script_args=[el_center_x, el_center_y],
+            sandbox='system'
         )
         self.actions.flick(el, src_x, src_y, dest_x, dest_y).perform()
 
         el.send_keys(content_to_add)
         assertFunc(non_target_content, sel.content)
 
     ########################################################################
     # <input> test cases with touch caret enabled