Class: Ferrum::Page::Tracing
- Inherits:
-
Object
- Object
- Ferrum::Page::Tracing
- Defined in:
- lib/ferrum/page/tracing.rb
Constant Summary collapse
- EXCLUDED_CATEGORIES =
%w[*].freeze
- SCREENSHOT_CATEGORIES =
%w[disabled-by-default-devtools.screenshot].freeze
- INCLUDED_CATEGORIES =
%w[devtools.timeline v8.execute disabled-by-default-devtools.timeline disabled-by-default-devtools.timeline.frame toplevel blink.console blink.user_timing latencyInfo disabled-by-default-devtools.timeline.stack disabled-by-default-v8.cpu_profiler disabled-by-default-v8.cpu_profiler.hires].freeze
- DEFAULT_TRACE_CONFIG =
{ includedCategories: INCLUDED_CATEGORIES, excludedCategories: EXCLUDED_CATEGORIES }.freeze
Instance Method Summary collapse
-
#initialize(page) ⇒ Tracing
constructor
A new instance of Tracing.
-
#record(path: nil, encoding: :binary, timeout: nil, trace_config: nil, screenshots: false) ⇒ String, true
Accepts block, records trace and by default returns trace data from ‘Tracing.tracingComplete` event as output.
Constructor Details
#initialize(page) ⇒ Tracing
Returns a new instance of Tracing.
17 18 19 20 |
# File 'lib/ferrum/page/tracing.rb', line 17 def initialize(page) @page = page @subscribed_tracing_complete = false end |
Instance Method Details
#record(path: nil, encoding: :binary, timeout: nil, trace_config: nil, screenshots: false) ⇒ String, true
Accepts block, records trace and by default returns trace data from ‘Tracing.tracingComplete` event as output.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ferrum/page/tracing.rb', line 48 def record(path: nil, encoding: :binary, timeout: nil, trace_config: nil, screenshots: false) @path = path @encoding = encoding @pending = Concurrent::IVar.new trace_config ||= DEFAULT_TRACE_CONFIG.dup if screenshots included = trace_config.fetch(:includedCategories, []) trace_config.merge!(includedCategories: included | SCREENSHOT_CATEGORIES) end subscribe_tracing_complete start(trace_config) yield stop @pending.value!(timeout || @page.timeout) end |