Skip to content

Commit 152874a

Browse files
committed
Add support for browser.on(:response).
* This adds an additional callback for the `Network.responseReceived` event when a response is received. It will look up the `Ferrum::Network::Exchange` object with the matching `requestId` and passes it back to the block, once a response has been received for a request.
1 parent d6e8c22 commit 152874a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/ferrum/page.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,14 @@ def on(name, &block)
204204
exchange.intercepted_request = request
205205
block.call(request, index, total)
206206
end
207+
when :response
208+
@client.on('Network.responseReceived') do |params, index, total|
209+
exchange = select(params["requestId"]).last
210+
211+
if exchange
212+
block.call(exchange, index, total)
213+
end
214+
end
207215
when :auth
208216
@client.on("Fetch.authRequired") do |params, index, total|
209217
request = Network::AuthRequest.new(self, params)

0 commit comments

Comments
 (0)