Skip to content

Commit

Permalink
Correct changes in #445
Browse files Browse the repository at this point in the history
#445 was an ad hoc solution and this commit fixes it correctly

The reason of the bug is that the debugger doesn't call 'Page.enable'
  • Loading branch information
ono-max committed Dec 18, 2021
1 parent a41ce34 commit 41aaaf1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/debug/server_cdp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def setup_chrome addr
ws_client.handshake port, path
ws_client.send id: 1, method: 'Target.getTargets'

4.times do
loop do
res = ws_client.extract_data
case
when res['id'] == 1 && target_info = res.dig('result', 'targetInfos')
Expand All @@ -39,12 +39,17 @@ def setup_chrome addr
}
when res['id'] == 2
s_id = res.dig('result', 'sessionId')
sleep 0.1
ws_client.send sessionId: s_id, id: 1,
ws_client.send sessionId: s_id, id: 3,
method: 'Page.enable'
when res['id'] == 3
s_id = res['sessionId']
ws_client.send sessionId: s_id, id: 4,
method: 'Page.navigate',
params: {
url: "devtools://devtools/bundled/inspector.html?ws=#{addr}"
}
when res['method'] == 'Page.loadEventFired'
break
end
end
pid
Expand Down

0 comments on commit 41aaaf1

Please sign in to comment.