Bug 1271758 - Ensure that execute_script does not fail on closed chrome windows. r=ato

MozReview-Commit-ID: 7SMV36KuFCe

--HG--
extra : rebase_source : a15078b9f40c845945fbd6061cac0711a792e342
This commit is contained in:
Henrik Skupin 2016-05-11 22:10:51 +02:00
parent c17f3a2733
commit a3814775bf
2 changed files with 13 additions and 1 deletions

View File

@ -8,6 +8,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/Timer.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("chrome://marionette/content/error.js");
@ -133,7 +134,7 @@ evaluate.sandbox = function(sb, script, args = [], opts = {}) {
}
// timeout and unload handlers
timeoutId = sb.window.setTimeout(
timeoutId = setTimeout(
timeoutHandler, opts.timeout || DEFAULT_TIMEOUT);
sb.window.addEventListener("unload", unloadHandler);

View File

@ -266,3 +266,14 @@ class TestExecuteChrome(TestExecuteContent):
var cb = arguments[arguments.length - 1];
setTimeout(function() { cb() }, 250);
""", script_timeout=100)
def test_invalid_chrome_handle(self):
# Close second chrome window and don't switch back to the original one
self.marionette.close_chrome_window()
self.assertEqual(len(self.marionette.chrome_window_handles), 1)
# Call execute_script on an invalid chrome handle
with self.marionette.using_context('chrome'):
self.marionette.execute_script("""
return true;
""")