зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 7 changesets (bug 1353074) for crashes in test_accessiblecaret_selection_mode.py
Backed out changeset 0c075043bc43 (bug 1353074) Backed out changeset 001f220710a2 (bug 1353074) Backed out changeset 9c1ca76fba9b (bug 1353074) Backed out changeset 8dcd190a0a59 (bug 1353074) Backed out changeset 23409efe536f (bug 1353074) Backed out changeset 8112153e0793 (bug 1353074) Backed out changeset 2670eec1ed8a (bug 1353074)
This commit is contained in:
Родитель
b62601b4b1
Коммит
3d24dfb690
|
@ -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']")
|
||||
with self.assertRaises(errors.JavascriptException):
|
||||
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
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче