Skip to content

Commit f9e888a

Browse files
committed
Fix executionContextId should be called always in retry block, because it might have been changed
1 parent 237d991 commit f9e888a

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/ferrum/frame/runtime.rb

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,27 +118,24 @@ def add_style_tag(url: nil, path: nil, content: nil)
118118
private
119119

120120
def call(expression:, arguments: [], on: nil, wait: 0, handle: true, **options)
121-
params = options.dup
122121
errors = [NodeNotFoundError, NoExecutionContextError]
123122
attempts, sleep = INTERMITTENT_ATTEMPTS, INTERMITTENT_SLEEP
124123

125124
Ferrum.with_attempts(errors: errors, max: attempts, wait: sleep) do
126125
if on
127126
response = @page.command("DOM.resolveNode", nodeId: on.node_id)
128127
object_id = response.dig("object", "objectId")
129-
params.merge!(objectId: object_id)
130-
elsif params[:executionContextId].nil?
131-
params.merge!(executionContextId: execution_id)
128+
options.merge!(objectId: object_id)
132129
else
133-
# executionContextId is passed, nop
130+
options.merge!(executionContextId: execution_id)
134131
end
135132

136-
params.merge!(functionDeclaration: expression,
137-
arguments: prepare_args(arguments))
133+
options.merge!(functionDeclaration: expression,
134+
arguments: prepare_args(arguments))
138135

139136
response = @page.command("Runtime.callFunctionOn",
140137
wait: wait, slowmoable: true,
141-
**params)
138+
**options)
142139
handle_error(response)
143140
response = response["result"]
144141

0 commit comments

Comments
 (0)