File tree Expand file tree Collapse file tree 2 files changed +21
-11
lines changed
lib/selenium/webdriver/common
spec/integration/selenium/webdriver Expand file tree Collapse file tree 2 files changed +21
-11
lines changed Original file line number Diff line number Diff line change 2222module Selenium
2323 module WebDriver
2424 class WebSocketConnection
25+ CONNECTION_ERRORS = [
26+ Errno ::ECONNRESET , # connection is aborted (browser process was killed)
27+ Errno ::EPIPE # broken pipe (browser process was killed)
28+ ] . freeze
29+
2530 RESPONSE_WAIT_TIMEOUT = 30
2631 RESPONSE_WAIT_INTERVAL = 0.1
2732
@@ -90,6 +95,8 @@ def attach_socket_listener
9095 end
9196 end
9297 end
98+ rescue *CONNECTION_ERRORS
99+ Thread . stop
93100 end
94101 end
95102
@@ -122,6 +129,8 @@ def callback_thread(params)
122129 Thread . current . report_on_exception = true
123130
124131 yield params
132+ rescue *CONNECTION_ERRORS
133+ Thread . stop
125134 end
126135 end
127136
Original file line number Diff line number Diff line change @@ -30,20 +30,21 @@ module WebDriver
3030 end
3131
3232 it 'supports events' do
33- callback = instance_double ( Proc , call : nil )
34-
35- driver . devtools . page . enable
36- driver . devtools . page . on ( :load_event_fired ) { callback . call }
37- driver . navigate . to url_for ( 'xhtmlTest.html' )
38- sleep 0.5
39-
40- expect ( callback ) . to have_received ( :call ) . at_least ( :once )
33+ expect { |block |
34+ driver . devtools . page . enable
35+ driver . devtools . page . on ( :load_event_fired , &block )
36+ driver . navigate . to url_for ( 'xhtmlTest.html' )
37+ sleep 0.5
38+ } . to yield_control
4139 end
4240
4341 it 'propagates errors in events' do
44- driver . devtools . page . enable
45- driver . devtools . page . on ( :load_event_fired ) { raise "This is fine!" }
46- expect { driver . navigate . to url_for ( 'xhtmlTest.html' ) } . to raise_error ( RuntimeError , "This is fine!" )
42+ expect {
43+ driver . devtools . page . enable
44+ driver . devtools . page . on ( :load_event_fired ) { raise "This is fine!" }
45+ driver . navigate . to url_for ( 'xhtmlTest.html' )
46+ sleep 0.5
47+ } . to raise_error ( RuntimeError , "This is fine!" )
4748 end
4849
4950 context 'authentication' , except : { browser : %i[ firefox firefox_nightly ] ,
You can’t perform that action at this time.
0 commit comments