Bug 1353074 - Use mutable sandboxes for selection API; r=maja_zf, a=test-only FENNEC_54_0b8_BUILD1 FENNEC_54_0b8_RELEASE FIREFOX_54_0b8_BUILD1 FIREFOX_54_0b8_RELEASE
authorAndreas Tolfsen <ato@mozilla.com>
Mon, 17 Apr 2017 14:47:28 +0100
changeset 578967 9bef2dfbd584c0f3ae52953bfc3aed64e308960d
parent 578966 6f07c769efddb3071fbd5a8730d8f651c6a9b967
child 578968 8bf3d5c1b4b0de2673a74d56c7399a80c5431243
push id59105
push userfelipc@gmail.com
push dateTue, 16 May 2017 19:21:34 +0000
reviewersmaja_zf, test-only
bugs1353074
milestone54.0
Bug 1353074 - Use mutable sandboxes for selection API; r=maja_zf, a=test-only Injected script in the Marionette caret selection API used the "default" immutable sandbox, but we want to run them in the mutable sandbox. MozReview-Commit-ID: BpbHdDhDtg4
testing/marionette/client/marionette_driver/selection.py
--- a/testing/marionette/client/marionette_driver/selection.py
+++ b/testing/marionette/client/marionette_driver/selection.py
@@ -54,60 +54,60 @@ class SelectionManager(object):
         '''
         cmd = self.js_selection_cmd() + '''
               for (let i = 0; i < {0}; ++i) {{
                   sel.modify("move", "{1}", "character");
               }}
               '''.format(offset, 'backward' if backward else 'forward')
 
         self.element.marionette.execute_script(
-            cmd, script_args=[self.element], sandbox='system')
+            cmd, script_args=(self.element,), sandbox='system')
 
     def move_cursor_to_front(self):
         '''Move cursor in the element to the front of the content.'''
         if self._input_or_textarea():
             cmd = '''arguments[0].setSelectionRange(0, 0);'''
         else:
             cmd = '''var sel = window.getSelection();
                   sel.collapse(arguments[0].firstChild, 0);'''
 
-        self.element.marionette.execute_script(cmd, script_args=[self.element])
+        self.element.marionette.execute_script(
+            cmd, script_args=(self.element,), sandbox=None)
 
     def move_cursor_to_end(self):
         '''Move cursor in the element to the end of the content.'''
         if self._input_or_textarea():
             cmd = '''var len = arguments[0].value.length;
                   arguments[0].setSelectionRange(len, len);'''
         else:
             cmd = '''var sel = window.getSelection();
                   sel.collapse(arguments[0].lastChild, arguments[0].lastChild.length);'''
 
-        self.element.marionette.execute_script(cmd, script_args=[self.element])
+        self.element.marionette.execute_script(
+            cmd, script_args=(self.element,), sandbox=None)
 
     def selection_rect_list(self, idx):
         '''Return the selection's DOMRectList object for the range at given idx.
 
         If the element is either <input> or <textarea>, return the DOMRectList of
         the range at given idx of the selection within the element. Otherwise,
         return the DOMRectList of the of the range at given idx of current selection.
 
         '''
         cmd = self.js_selection_cmd() +\
             '''return sel.getRangeAt({}).getClientRects();'''.format(idx)
-        return self.element.marionette.execute_script(cmd,
-                                                      script_args=[self.element],
-                                                      sandbox='system')
+        return self.element.marionette.execute_script(
+            cmd, script_args=(self.element,), sandbox='system')
 
     def range_count(self):
         '''Get selection's range count'''
         cmd = self.js_selection_cmd() +\
             '''return sel.rangeCount;'''
-        return self.element.marionette.execute_script(cmd,
-                                                      script_args=[self.element],
-                                                      sandbox='system')
+        return self.element.marionette.execute_script(
+            cmd, script_args=(self.element,), sandbox='system')
 
     def _selection_location_helper(self, location_type):
         '''Return the start and end location of the selection in the element.
 
         Return a tuple containing two pairs of (x, y) coordinates of the start
         and end locations in the element. The coordinates are relative to the
         top left-hand corner of the element. Both ltr and rtl directions are
         considered.
@@ -202,26 +202,26 @@ class SelectionManager(object):
         else:
             cmd = '''var range = document.createRange();
                   range.setStart(arguments[0].firstChild, 0);
                   range.setEnd(arguments[0].lastChild, arguments[0].lastChild.length);
                   var sel = window.getSelection();
                   sel.removeAllRanges();
                   sel.addRange(range);'''
 
-        self.element.marionette.execute_script(cmd, script_args=[self.element])
+        self.element.marionette.execute_script(
+            cmd, script_args=(self.element,), sandbox=None)
 
     @property
     def content(self):
         '''Return all the content of the element.'''
         if self._input_or_textarea():
             return self.element.get_property('value')
         else:
             return self.element.text
 
     @property
     def selected_content(self):
         '''Return the selected portion of the content in the element.'''
         cmd = self.js_selection_cmd() +\
             '''return sel.toString();'''
-        return self.element.marionette.execute_script(cmd,
-                                                      script_args=[self.element],
-                                                      sandbox='system')
+        return self.element.marionette.execute_script(
+            cmd, script_args=(self.element,), sandbox='system')