lib/puppeteer/page.rb in puppeteer-ruby-0.40.3 vs lib/puppeteer/page.rb in puppeteer-ruby-0.40.4
- old
+ new
@@ -506,10 +506,11 @@
# err.stack = ''; // Don't report clientside error with a node stack attached
emit_event(PageEmittedEvents::PageError, err)
end
private def handle_console_api(event)
+ puts "~~~~~~~~~~~~~~#{event}"
if event['executionContextId'] == 0
# DevTools protocol stores the last 1000 console messages. These
# messages are always reported even for removed execution contexts. In
# this case, they are marked with executionContextId = 0 and are
# reported upon enabling Runtime agent.
@@ -580,21 +581,22 @@
end
private def add_console_message(type, args, stack_trace)
text_tokens = args.map { |arg| arg.remote_object.value }
- call_frame = stack_trace['callFrames']&.first
- location =
- if call_frame
- Puppeteer::ConsoleMessage::Location.new(
- url: call_frame['url'],
- line_number: call_frame['lineNumber'],
- column_number: call_frame['columnNumber'],
- )
+ stack_trace_locations =
+ if stack_trace && stack_trace['callFrames']
+ stack_trace['callFrames'].map do |call_frame|
+ Puppeteer::ConsoleMessage::Location.new(
+ url: call_frame['url'],
+ line_number: call_frame['lineNumber'],
+ column_number: call_frame['columnNumber'],
+ )
+ end
else
- nil
+ []
end
- console_message = Puppeteer::ConsoleMessage.new(type, text_tokens.join(' '), args, location)
+ console_message = Puppeteer::ConsoleMessage.new(type, text_tokens.join(' '), args, stack_trace_locations)
emit_event(PageEmittedEvents::Console, console_message)
end
private def handle_dialog_opening(event)
dialog_type = event['type']