Skip to content

Commit 27c7cd6

Browse files
committed
feat: Add Ferrum::Network::Exchange#blob?
1 parent 7f8e712 commit 27c7cd6

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### Added
44

5+
- `Ferrum::Network::Exchange#blob?` determines if the exchange is blob [#516]
56
- `Ferrum::Network::Request#headers` are enhanced and supplemented with `Network.requestWillBeSentExtraInfo` [#506]
67
- `Ferrum::Page#off` to unsubscribe from CDP events [#455]
78
- `Ferrum::Mouse#scroll_by` to be able to scroll by, as alternative to `scroll_to` [#514]
@@ -12,6 +13,7 @@
1213

1314
- Correctly set mouse events buttons property [#509]
1415
- Prevent 'Hash#[]=': can't add a new key into hash during iteration [#513]
16+
- `Ferrum::Network::Exchange#finished?` and `Ferrum::Network#wait_for_idle` take into account that request can be a blob [#496]
1517

1618
### Removed
1719

lib/ferrum/network/exchange.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def blocked?
8383
# @return [Boolean]
8484
#
8585
def finished?
86-
blocked? || response&.loaded? || !error.nil? || ping? || !!url&.start_with?("blob:")
86+
blocked? || response&.loaded? || !error.nil? || ping? || blob?
8787
end
8888

8989
#
@@ -131,6 +131,15 @@ def ping?
131131
!!request&.ping?
132132
end
133133

134+
#
135+
# Determines if the exchange is blob.
136+
#
137+
# @return [Boolean]
138+
#
139+
def blob?
140+
!!url&.start_with?("blob:")
141+
end
142+
134143
#
135144
# Returns request's URL.
136145
#

spec/network/exchange_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139

140140
it "returns true for blob requests" do
141141
exchange = Ferrum::Network::Exchange.new(page, "1")
142+
expect(exchange.blob?).to be false
142143
expect(exchange.finished?).to be false
143144

144145
exchange.request = Ferrum::Network::Request.new(
@@ -149,6 +150,7 @@
149150
}
150151
}
151152
)
153+
expect(exchange.blob?).to be true
152154
expect(exchange.finished?).to be true
153155
end
154156
end

0 commit comments

Comments
 (0)