ferrum 0.19.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ferrum/browser/options/chrome.rb +0 -1
- data/lib/ferrum/client/web_socket.rb +5 -6
- data/lib/ferrum/client.rb +2 -1
- data/lib/ferrum/frame/dom.rb +2 -1
- data/lib/ferrum/mouse.rb +6 -0
- data/lib/ferrum/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 07c9e2d0d81f6b0919d937f91e2432ce2a64890b78981d2088d606f8ce088d8f
|
|
4
|
+
data.tar.gz: 595a3850a55afed99b8a537b9c544fc706c8ca66f6531b4233b0f5adfa637500
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2c8f277c645602793e5c9f63e89f12c810668ba9fd8d45585c090a220343abb4ea40769e5c03baa4c59d1aed530282db5bcaa30d151a7662f85142556dcfdd49
|
|
7
|
+
data.tar.gz: a4113a1261c436899348992e3514796c3dccffd425003e2d10da7d398bd743f6b864cbc85d8fd48efc33d42f8ce5e4c3546fcc209b813c5417982c4f8dca893e
|
|
@@ -16,6 +16,7 @@ module Ferrum
|
|
|
16
16
|
WEBSOCKET_BUG_SLEEP = 0.05
|
|
17
17
|
DEFAULT_PORTS = { "ws" => 80, "wss" => 443 }.freeze
|
|
18
18
|
SKIP_LOGGING_SCREENSHOTS = !ENV["FERRUM_LOGGING_SCREENSHOTS"]
|
|
19
|
+
ESCAPE_OR_LONE_SURROGATE = /\\u[dD][89abAB]\h{2}\\u[dD][c-fC-F]\h{2}|\\u([dD][89a-fA-F]\h{2})|\\./
|
|
19
20
|
|
|
20
21
|
attr_reader :url, :messages
|
|
21
22
|
|
|
@@ -223,14 +224,12 @@ module Ferrum
|
|
|
223
224
|
rescue JSON::NestingError
|
|
224
225
|
# nop
|
|
225
226
|
rescue JSON::ParserError
|
|
226
|
-
|
|
227
|
+
safely_parse_lone_surrogates(data)
|
|
227
228
|
end
|
|
228
229
|
|
|
229
|
-
def
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
escaped_data = unescaped_unicode.encode("UTF-8", "UTF-8", undef: :replace, invalid: :replace, replace: "?")
|
|
233
|
-
JSON.parse(escaped_data, max_nesting: false)
|
|
230
|
+
def safely_parse_lone_surrogates(data)
|
|
231
|
+
replaced = data.gsub(ESCAPE_OR_LONE_SURROGATE) { |escape| ::Regexp.last_match(1) ? "\\ufffd" : escape }
|
|
232
|
+
JSON.parse(replaced, max_nesting: false)
|
|
234
233
|
rescue JSON::ParserError
|
|
235
234
|
# nop
|
|
236
235
|
end
|
data/lib/ferrum/client.rb
CHANGED
|
@@ -376,7 +376,8 @@ module Ferrum
|
|
|
376
376
|
# Node has disappeared while we were trying to get it
|
|
377
377
|
when "No node with given id found",
|
|
378
378
|
"Could not find node with given id",
|
|
379
|
-
"Inspected target navigated or closed"
|
|
379
|
+
"Inspected target navigated or closed",
|
|
380
|
+
"Argument should belong to the same JavaScript world as target object"
|
|
380
381
|
raise NodeNotFoundError, error
|
|
381
382
|
# Context is lost, page is reloading
|
|
382
383
|
when "Cannot find context with specified id"
|
data/lib/ferrum/frame/dom.rb
CHANGED
|
@@ -116,7 +116,8 @@ module Ferrum
|
|
|
116
116
|
# Returns the element in which the window is embedded.
|
|
117
117
|
#
|
|
118
118
|
# @return [Node, nil]
|
|
119
|
-
# The element in which the window is embedded
|
|
119
|
+
# The element in which the window is embedded, `nil` for the main frame
|
|
120
|
+
# and for a frame from a different origin than its parent.
|
|
120
121
|
#
|
|
121
122
|
# @example
|
|
122
123
|
# browser.go_to("https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe")
|
data/lib/ferrum/mouse.rb
CHANGED
|
@@ -152,6 +152,7 @@ module Ferrum
|
|
|
152
152
|
from_y = @y
|
|
153
153
|
@x = x
|
|
154
154
|
@y = y
|
|
155
|
+
button = pressed_button
|
|
155
156
|
|
|
156
157
|
steps.times do |i|
|
|
157
158
|
new_x = from_x + ((@x - from_x) * ((i + 1) / steps.to_f))
|
|
@@ -162,6 +163,7 @@ module Ferrum
|
|
|
162
163
|
type: "mouseMoved",
|
|
163
164
|
x: new_x,
|
|
164
165
|
y: new_y,
|
|
166
|
+
button: button,
|
|
165
167
|
buttons: @buttons)
|
|
166
168
|
end
|
|
167
169
|
|
|
@@ -185,6 +187,10 @@ module Ferrum
|
|
|
185
187
|
button
|
|
186
188
|
end
|
|
187
189
|
|
|
190
|
+
def pressed_button
|
|
191
|
+
BUTTON_MASKS.find { |_name, mask| mask.positive? && @buttons.anybits?(mask) }&.first || "none"
|
|
192
|
+
end
|
|
193
|
+
|
|
188
194
|
def register_event_button(type, button)
|
|
189
195
|
case type
|
|
190
196
|
when "mousePressed"
|
data/lib/ferrum/version.rb
CHANGED