Module: Capybara::Lightpanda::Browser::Console
- Included in:
- Capybara::Lightpanda::Browser
- Defined in:
- lib/capybara/lightpanda/browser/console.rb
Overview
Runtime.consoleAPICalled consumers: the user-facing console_logs ring buffer, the optional IO-logger stream, and the Turbo busy/idle sentinel tracking behind Browser#wait_for_idle.
Instance Method Summary collapse
- #clear_console_logs ⇒ Object
- #clear_page_errors ⇒ Object
-
#console_logs ⇒ Object
Console messages captured from
Runtime.consoleAPICalledsince the lastreset(Turbo-tracker sentinels excluded). -
#page_errors ⇒ Object
Uncaught page exceptions and unhandled promise rejections since the last
reset:{kind:, message:, url:, line:, column:, stack:, timestamp:}, wherekindis "error" or "unhandledrejection".
Instance Method Details
#clear_console_logs ⇒ Object
22 23 24 |
# File 'lib/capybara/lightpanda/browser/console.rb', line 22 def clear_console_logs @console_logs_mutex.synchronize { @console_logs.clear } end |
#clear_page_errors ⇒ Object
50 51 52 |
# File 'lib/capybara/lightpanda/browser/console.rb', line 50 def clear_page_errors @page_errors_mutex.synchronize { @page_errors.clear } end |
#console_logs ⇒ Object
Console messages captured from Runtime.consoleAPICalled since the
last reset (Turbo-tracker sentinels excluded). Loose hashes, like
Network#traffic: {type:, text:, timestamp:, args:} where type is
the console method name ("log", "error", "warning", ...), text joins
the arguments' primitive values/descriptions, and args keeps the raw
CDP RemoteObjects. Lets suites assert on JS console errors
(browser.console_logs.select { |m| m[:type] == "error" }) the way
peer drivers do via custom Ferrum loggers.
18 19 20 |
# File 'lib/capybara/lightpanda/browser/console.rb', line 18 def console_logs @console_logs_mutex.synchronize { @console_logs.dup } end |
#page_errors ⇒ Object
Uncaught page exceptions and unhandled promise rejections since the
last reset: {kind:, message:, url:, line:, column:, stack:, timestamp:}, where kind is "error" or "unhandledrejection".
Deliberately NOT folded into #console_logs. Chrome reports an
uncaught exception through Runtime.exceptionThrown rather than
consoleAPICalled, and Playwright/Puppeteer expose it as pageerror
separately from console — so a suite that greps console_logs for
errors on those stacks doesn't see exceptions there either. Merging
them would also start failing every suite that already asserts
console_logs holds no errors.
Lightpanda emits no Runtime.exceptionThrown at all, so the source is
a passive listener pair in javascripts/errors.js reporting over the
console.debug sentinel channel. It sees what reaches window:
exceptions a framework catches itself (Stimulus's handleError, any
try/catch) never arrive, and a cross-origin script collapses to
"Script error." with no detail. Partial by construction — but the
alternative is the zero visibility that made the solidus taxon-tree
failure take a hand-injected listener to explain.
46 47 48 |
# File 'lib/capybara/lightpanda/browser/console.rb', line 46 def page_errors @page_errors_mutex.synchronize { @page_errors.dup } end |