test_execute_isolate.py (1561B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 from marionette_driver.errors import ScriptTimeoutException 6 7 from marionette_harness import MarionetteTestCase 8 9 10 class TestExecuteIsolationContent(MarionetteTestCase): 11 def setUp(self): 12 super(TestExecuteIsolationContent, self).setUp() 13 self.content = True 14 15 def test_execute_async_isolate(self): 16 # Results from one execute call that has timed out should not 17 # contaminate a future call. 18 multiplier = "*3" if self.content else "*1" 19 self.marionette.timeout.script = 0.5 20 self.assertRaises( 21 ScriptTimeoutException, 22 self.marionette.execute_async_script, 23 ( 24 "setTimeout(function() {{ arguments[0](5{}); }}, 3000);".format( 25 multiplier 26 ) 27 ), 28 ) 29 30 self.marionette.timeout.script = 6 31 result = self.marionette.execute_async_script( 32 """ 33 let [resolve] = arguments; 34 setTimeout(function() {{ resolve(10{}); }}, 5000); 35 """.format( 36 multiplier 37 ) 38 ) 39 self.assertEqual(result, 30 if self.content else 10) 40 41 42 class TestExecuteIsolationChrome(TestExecuteIsolationContent): 43 def setUp(self): 44 super(TestExecuteIsolationChrome, self).setUp() 45 self.marionette.set_context("chrome") 46 self.content = False