Skip to content

Commit

Permalink
Add query parameters to URL to use debugger easily
Browse files Browse the repository at this point in the history
  • Loading branch information
ono-max committed Feb 1, 2022
1 parent 089ae90 commit 1bd7209
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
6 changes: 3 additions & 3 deletions lib/debug/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def greeting
self.extend(UI_DAP)
@repl = false
dap_setup @sock.read($1.to_i)
when /^GET \/ HTTP\/1.1/
when /^GET \/.* HTTP\/1.1/
require_relative 'server_cdp'

self.extend(UI_CDP)
Expand Down Expand Up @@ -349,8 +349,8 @@ def chrome_setup
unless @chrome_pid = UI_CDP.setup_chrome(@addr)
DEBUGGER__.warn <<~EOS if CONFIG[:open_frontend] == 'chrome'
With Chrome browser, type the following URL in the address-bar:
devtools://devtools/bundled/inspector.html?ws=#{@addr}
devtools://devtools/bundled/inspector.html?v8only=true&panel=sources&ws=#{@addr}/#{SecureRandom.uuid}
EOS
end
Expand Down
34 changes: 15 additions & 19 deletions lib/debug/server_cdp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def setup_chrome addr
ws_client.send sessionId: s_id, id: 5,
method: 'Page.navigate',
params: {
url: "devtools://devtools/bundled/inspector.html?ws=#{addr}",
url: "devtools://devtools/bundled/inspector.html?v8only=true&panel=sources&ws=#{addr}/#{SecureRandom.uuid}",
frameId: f_id
}
when res['method'] == 'Page.loadEventFired'
Expand Down Expand Up @@ -281,21 +281,17 @@ def process
case req['method']

## boot/configuration
when 'Page.getResourceTree'
when 'Debugger.getScriptSource'
s_id = req.dig('params', 'scriptId')
src = get_source_code s_id
send_response req, scriptSource: src
@q_msg << req
when 'Debugger.enable'
send_response req
@q_msg << req
path = File.absolute_path($0)
src = File.read(path)
@src_map[path] = src
send_response req,
frameTree: {
frame: {
id: SecureRandom.hex(16),
loaderId: SecureRandom.hex(16),
url: 'http://debuggee/',
securityOrigin: 'http://debuggee',
mimeType: 'text/plain' },
resources: [
]
}
send_event 'Debugger.scriptParsed',
scriptId: path,
url: "http://debuggee#{path}",
Expand All @@ -305,17 +301,17 @@ def process
endColumn: 0,
executionContextId: 1,
hash: src.hash
when 'Runtime.enable'
send_response req
send_event 'Runtime.executionContextCreated',
context: {
id: SecureRandom.hex(16),
origin: "http://#{@addr}",
name: ''
}
when 'Debugger.getScriptSource'
s_id = req.dig('params', 'scriptId')
src = get_source_code s_id
send_response req, scriptSource: src
@q_msg << req
when 'Runtime.getIsolateId'
send_response req,
id: SecureRandom.hex
when 'Page.startScreencast', 'Emulation.setTouchEmulationEnabled', 'Emulation.setEmitTouchEventsForMouse',
'Runtime.compileScript', 'Page.getResourceContent', 'Overlay.setPausedInDebuggerMessage',
'Runtime.releaseObjectGroup', 'Runtime.discardConsoleEntries', 'Log.clear'
Expand Down Expand Up @@ -531,7 +527,7 @@ def fail_response req, **result

def process_protocol_request req
case req['method']
when 'Debugger.stepOver', 'Debugger.stepInto', 'Debugger.stepOut', 'Debugger.resume', 'Debugger.getScriptSource'
when 'Debugger.stepOver', 'Debugger.stepInto', 'Debugger.stepOut', 'Debugger.resume', 'Debugger.getScriptSource', 'Debugger.enable'
@tc << [:cdp, :backtrace, req]
when 'Debugger.evaluateOnCallFrame'
frame_id = req.dig('params', 'callFrameId')
Expand Down

0 comments on commit 1bd7209

Please sign in to comment.