Bug 1452483 - Strip whitespace from injected scripts. r?maja_zf
The injected script may contain a lot of whitespace padding on
either side of the string when using multi-line strings ("""foo""")
in Python. To improve readability of the trace log we can strip
it off before sending it to Marionette.
MozReview-Commit-ID: 2cNlwVzqWTK
--- a/testing/marionette/client/marionette_driver/marionette.py
+++ b/testing/marionette/client/marionette_driver/marionette.py
@@ -1701,17 +1701,17 @@ class Marionette(object):
marionette.execute_script("global.test1 = 'foo';")
result = self.marionette.execute_script("return global.test1;", new_sandbox=False)
assert result == "foo"
"""
args = self._to_json(script_args)
stack = traceback.extract_stack()
frame = stack[-2:-1][0] # grab the second-to-last frame
- body = {"script": script,
+ body = {"script": script.strip(),
"args": args,
"newSandbox": new_sandbox,
"sandbox": sandbox,
"scriptTimeout": script_timeout,
"line": int(frame[1]),
"filename": os.path.basename(frame[0])}
rv = self._send_message("WebDriver:ExecuteScript",
@@ -1751,17 +1751,17 @@ class Marionette(object):
marionetteScriptFinished(1);
}, 5000);
''')
assert result == 1
"""
args = self._to_json(script_args)
stack = traceback.extract_stack()
frame = stack[-2:-1][0] # grab the second-to-last frame
- body = {"script": script,
+ body = {"script": script.strip(),
"args": args,
"newSandbox": new_sandbox,
"sandbox": sandbox,
"scriptTimeout": script_timeout,
"line": int(frame[1]),
"filename": os.path.basename(frame[0]),
"debug_script": debug_script}