зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 8 changesets (bug 1353074) for Marionette crashes in test_accessiblecaret_selection_mode.py and timeouts in test_click.py
CLOSED TREE Backed out changeset 824c46ad23f9 (bug 1353074) Backed out changeset a6249ce2b09e (bug 1353074) Backed out changeset 56027ec27fb8 (bug 1353074) Backed out changeset c8d2b2c701a6 (bug 1353074) Backed out changeset 28eb1c784875 (bug 1353074) Backed out changeset 811a3e45bf11 (bug 1353074) Backed out changeset 764220600b06 (bug 1353074) Backed out changeset d7af70f65c2c (bug 1353074)
This commit is contained in:
Родитель
0422dfb12d
Коммит
13057a9bc3
|
@ -59,7 +59,7 @@ class SelectionManager(object):
|
|||
'''.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.'''
|
||||
|
@ -69,8 +69,7 @@ class SelectionManager(object):
|
|||
cmd = '''var sel = window.getSelection();
|
||||
sel.collapse(arguments[0].firstChild, 0);'''
|
||||
|
||||
self.element.marionette.execute_script(
|
||||
cmd, script_args=(self.element,), sandbox=None)
|
||||
self.element.marionette.execute_script(cmd, script_args=[self.element])
|
||||
|
||||
def move_cursor_to_end(self):
|
||||
'''Move cursor in the element to the end of the content.'''
|
||||
|
@ -81,8 +80,7 @@ class SelectionManager(object):
|
|||
cmd = '''var sel = window.getSelection();
|
||||
sel.collapse(arguments[0].lastChild, arguments[0].lastChild.length);'''
|
||||
|
||||
self.element.marionette.execute_script(
|
||||
cmd, script_args=(self.element,), sandbox=None)
|
||||
self.element.marionette.execute_script(cmd, script_args=[self.element])
|
||||
|
||||
def selection_rect_list(self, idx):
|
||||
'''Return the selection's DOMRectList object for the range at given idx.
|
||||
|
@ -94,15 +92,17 @@ class SelectionManager(object):
|
|||
'''
|
||||
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.
|
||||
|
@ -207,8 +207,7 @@ class SelectionManager(object):
|
|||
sel.removeAllRanges();
|
||||
sel.addRange(range);'''
|
||||
|
||||
self.element.marionette.execute_script(
|
||||
cmd, script_args=(self.element,), sandbox=None)
|
||||
self.element.marionette.execute_script(cmd, script_args=[self.element])
|
||||
|
||||
@property
|
||||
def content(self):
|
||||
|
@ -223,5 +222,6 @@ class SelectionManager(object):
|
|||
'''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')
|
||||
|
|
|
@ -105,9 +105,8 @@ evaluate.sandbox = function (sb, script, args = [], opts = {}) {
|
|||
let src = "";
|
||||
sb[COMPLETE] = resolve;
|
||||
timeoutHandler = () => reject(new ScriptTimeoutError("Timed out"));
|
||||
unloadHandler = sandbox.cloneInto(
|
||||
() => reject(new JavaScriptError("Document was unloaded during execution")),
|
||||
sb);
|
||||
unloadHandler = () => reject(
|
||||
new JavaScriptError("Document was unloaded during execution"));
|
||||
|
||||
// wrap in function
|
||||
if (!opts.directInject) {
|
||||
|
@ -146,7 +145,7 @@ evaluate.sandbox = function (sb, script, args = [], opts = {}) {
|
|||
|
||||
// timeout and unload handlers
|
||||
scriptTimeoutID = setTimeout(timeoutHandler, opts.timeout || DEFAULT_TIMEOUT);
|
||||
sb.window.addEventListener("unload", unloadHandler);
|
||||
sb.window.onunload = sandbox.cloneInto(unloadHandler, sb);
|
||||
|
||||
let res;
|
||||
try {
|
||||
|
|
|
@ -92,62 +92,40 @@ class TestExecuteContent(MarionetteTestCase):
|
|||
self.assertIsNone(self.marionette.execute_script("true"))
|
||||
|
||||
def test_argument_null(self):
|
||||
self.assertIsNone(self.marionette.execute_script(
|
||||
"return arguments[0]",
|
||||
script_args=(None,),
|
||||
sandbox="default"))
|
||||
self.assertIsNone(self.marionette.execute_script(
|
||||
"return arguments[0]",
|
||||
script_args=(None,),
|
||||
sandbox="system"))
|
||||
self.assertIsNone(self.marionette.execute_script(
|
||||
"return arguments[0]",
|
||||
script_args=(None,),
|
||||
sandbox=None))
|
||||
self.assertIsNone(self.marionette.execute_script("return arguments[0]", [None]))
|
||||
|
||||
def test_argument_number(self):
|
||||
self.assertEqual(
|
||||
1, self.marionette.execute_script("return arguments[0]", (1,)))
|
||||
1, self.marionette.execute_script("return arguments[0]", [1]))
|
||||
self.assertEqual(
|
||||
1.5, self.marionette.execute_script("return arguments[0]", (1.5,)))
|
||||
1.5, self.marionette.execute_script("return arguments[0]", [1.5]))
|
||||
|
||||
def test_argument_boolean(self):
|
||||
self.assertTrue(self.marionette.execute_script("return arguments[0]", (True,)))
|
||||
self.assertTrue(self.marionette.execute_script("return arguments[0]", [True]))
|
||||
|
||||
def test_argument_string(self):
|
||||
self.assertEqual(
|
||||
"foo", self.marionette.execute_script("return arguments[0]", ("foo",)))
|
||||
"foo", self.marionette.execute_script("return arguments[0]", ["foo"]))
|
||||
|
||||
def test_argument_array(self):
|
||||
self.assertEqual(
|
||||
[1, 2], self.marionette.execute_script("return arguments[0]", ([1, 2],)))
|
||||
[1, 2], self.marionette.execute_script("return arguments[0]", [[1, 2]]))
|
||||
|
||||
def test_argument_object(self):
|
||||
self.assertEqual({"foo": 1}, self.marionette.execute_script(
|
||||
"return arguments[0]", ({"foo": 1},)))
|
||||
"return arguments[0]", [{"foo": 1}]))
|
||||
|
||||
def test_default_sandbox_globals(self):
|
||||
def test_globals(self):
|
||||
for property in globals:
|
||||
self.assert_is_defined(property, sandbox="default")
|
||||
|
||||
self.assert_is_defined(property)
|
||||
self.assert_is_defined("Components")
|
||||
self.assert_is_defined("window.wrappedJSObject")
|
||||
|
||||
def test_system_globals(self):
|
||||
for property in globals:
|
||||
self.assert_is_defined(property, sandbox="system")
|
||||
|
||||
self.assert_is_defined("Components", sandbox="system")
|
||||
self.assert_is_defined("window.wrappedJSObject", sandbox="system")
|
||||
|
||||
def test_mutable_sandbox_globals(self):
|
||||
for property in globals:
|
||||
self.assert_is_defined(property, sandbox=None)
|
||||
|
||||
# Components is there, but will be removed soon
|
||||
self.assert_is_defined("Components", sandbox=None)
|
||||
# wrappedJSObject is always there in sandboxes
|
||||
self.assert_is_defined("window.wrappedJSObject", sandbox=None)
|
||||
self.assert_is_defined("window.wrappedJSObject")
|
||||
|
||||
def test_exception(self):
|
||||
self.assertRaises(errors.JavascriptException,
|
||||
|
@ -164,10 +142,10 @@ class TestExecuteContent(MarionetteTestCase):
|
|||
self.assertIn("return b", cm.exception.stacktrace)
|
||||
|
||||
def test_permission(self):
|
||||
for sandbox in ["default", None]:
|
||||
with self.assertRaises(errors.JavascriptException):
|
||||
self.marionette.execute_script(
|
||||
"Components.classes['@mozilla.org/preferences-service;1']")
|
||||
self.marionette.execute_script("""
|
||||
var c = Components.classes["@mozilla.org/preferences-service;1"];
|
||||
""")
|
||||
|
||||
def test_return_web_element(self):
|
||||
self.marionette.navigate(elements)
|
||||
|
@ -210,34 +188,21 @@ class TestExecuteContent(MarionetteTestCase):
|
|||
self.assertEqual(self.marionette.execute_script(
|
||||
"return this.foobar", new_sandbox=False), [23, 42])
|
||||
|
||||
def test_mutable_sandbox_wrappedjsobject(self):
|
||||
self.assert_is_defined("window.wrappedJSObject")
|
||||
with self.assertRaises(errors.JavascriptException):
|
||||
self.marionette.execute_script("window.wrappedJSObject.foo = 1", sandbox=None)
|
||||
|
||||
def test_default_sandbox_wrappedjsobject(self):
|
||||
self.assert_is_defined("window.wrappedJSObject", sandbox="default")
|
||||
|
||||
def test_wrappedjsobject(self):
|
||||
try:
|
||||
self.marionette.execute_script(
|
||||
"window.wrappedJSObject.foo = 4", sandbox="default")
|
||||
self.assertEqual(self.marionette.execute_script(
|
||||
"return window.wrappedJSObject.foo", sandbox="default"), 4)
|
||||
self.marionette.execute_script("window.wrappedJSObject.foo = 3")
|
||||
self.assertEqual(
|
||||
self.marionette.execute_script("return window.wrappedJSObject.foo"), 3)
|
||||
finally:
|
||||
self.marionette.execute_script(
|
||||
"delete window.wrappedJSObject.foo", sandbox="default")
|
||||
self.marionette.execute_script("delete window.wrappedJSObject.foo")
|
||||
|
||||
def test_system_sandbox_wrappedjsobject(self):
|
||||
self.assert_is_defined("window.wrappedJSObject", sandbox="system")
|
||||
|
||||
self.marionette.execute_script(
|
||||
"window.wrappedJSObject.foo = 4", sandbox="system")
|
||||
self.assertEqual(self.marionette.execute_script(
|
||||
"return window.wrappedJSObject.foo", sandbox="system"), 4)
|
||||
|
||||
def test_system_dead_object(self):
|
||||
self.assert_is_defined("window.wrappedJSObject", sandbox="system")
|
||||
|
||||
self.marionette.execute_script(
|
||||
"window.wrappedJSObject.foo = function() { return 'yo' }",
|
||||
sandbox="system")
|
||||
|
@ -298,40 +263,18 @@ class TestExecuteContent(MarionetteTestCase):
|
|||
content_timeout_triggered,
|
||||
message="Scheduled setTimeout event was cancelled by call to execute_script")
|
||||
|
||||
def test_access_chrome_objects_in_event_listeners(self):
|
||||
# sandbox.window.addEventListener/removeEventListener
|
||||
# is used by Marionette for installing the unloadHandler which
|
||||
# is used to return an error when a document is unloaded during
|
||||
# script execution.
|
||||
#
|
||||
# Certain web frameworks, notably Angular, override
|
||||
# window.addEventListener/removeEventListener and introspects
|
||||
# objects passed to them. If these objects originates from chrome
|
||||
# without having been cloned, a permission denied error is thrown
|
||||
# as part of the security precautions put in place by the sandbox.
|
||||
|
||||
# addEventListener is called when script is injected
|
||||
def test_privileged_code_inspection(self):
|
||||
# test permission denied on toString of unload event handler
|
||||
self.marionette.navigate(inline("""
|
||||
<script>
|
||||
window.addEventListener = (event, listener) => listener.toString();
|
||||
</script>
|
||||
"""))
|
||||
window.addEventListener = (type, handler) => handler.toString();
|
||||
</script>"""))
|
||||
self.marionette.execute_script("", sandbox=None)
|
||||
|
||||
# removeEventListener is called when sandbox is unloaded
|
||||
self.marionette.navigate(inline("""
|
||||
<script>
|
||||
window.removeEventListener = (event, listener) => listener.toString();
|
||||
</script>
|
||||
"""))
|
||||
self.marionette.execute_script("", sandbox=None)
|
||||
|
||||
def test_access_global_objects_from_chrome(self):
|
||||
# test inspection of arguments
|
||||
self.marionette.execute_script("__webDriverArguments.toString()")
|
||||
|
||||
|
||||
|
||||
class TestExecuteChrome(WindowManagerMixin, TestExecuteContent):
|
||||
|
||||
def setUp(self):
|
||||
|
@ -343,8 +286,8 @@ class TestExecuteChrome(WindowManagerMixin, TestExecuteContent):
|
|||
super(TestExecuteChrome, self).tearDown()
|
||||
|
||||
def test_permission(self):
|
||||
self.marionette.execute_script(
|
||||
"Components.classes['@mozilla.org/preferences-service;1']")
|
||||
self.assertEqual(1, self.marionette.execute_script("""
|
||||
var c = Components.classes["@mozilla.org/preferences-service;1"]; return 1;"""))
|
||||
|
||||
@skip_if_mobile("New windows not supported in Fennec")
|
||||
def test_unmarshal_element_collection(self):
|
||||
|
@ -387,16 +330,7 @@ class TestExecuteChrome(WindowManagerMixin, TestExecuteContent):
|
|||
def test_window_set_timeout_is_not_cancelled(self):
|
||||
pass
|
||||
|
||||
def test_mutable_sandbox_wrappedjsobject(self):
|
||||
pass
|
||||
|
||||
def test_default_sandbox_wrappedjsobject(self):
|
||||
pass
|
||||
|
||||
def test_system_sandbox_wrappedjsobject(self):
|
||||
pass
|
||||
|
||||
def test_access_chrome_objects_in_event_listeners(self):
|
||||
def test_privileged_code_inspection(self):
|
||||
pass
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче