More accurate JS behavior timeout

If you use a JS behavior timeout smaller than 7 sec, the JS behavior
will always need 7 sec because `sleep(7)` is hard-coded there.

We make a minor addition to use `min(timeout, 7)` for sleep so it will
finish faster when using a smaller JS behavior timeout.
This commit is contained in:
Vangelis Banos 2019-08-22 21:15:44 +00:00
parent 16f886259d
commit 0b28a4a57f

View File

@ -617,6 +617,7 @@ class Browser:
method='Runtime.evaluate', suppress_logging=True,
params={'expression': behavior_script})
check_interval = min(timeout, 7)
start = time.time()
while True:
elapsed = time.time() - start
@ -625,7 +626,7 @@ class Browser:
'behavior reached hard timeout after %.1fs', elapsed)
return
brozzler.sleep(7)
brozzler.sleep(check_interval)
self.websock_thread.expect_result(self._command_id.peek())
msg_id = self.send_to_chrome(