Class: Browserctl::PageSession

Inherits:
Object
  • Object
show all
Defined in:
lib/browserctl/server/page_session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page_or_driver) ⇒ PageSession

Returns a new instance of PageSession.

Parameters:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/browserctl/server/page_session.rb', line 14

def initialize(page_or_driver)
  @driver = if page_or_driver.is_a?(Browserctl::Driver::PageDriver)
              page_or_driver
            else
              Browserctl::Driver::FerrumPageDriver.new(page_or_driver)
            end
  @mutex             = Mutex.new
  @pause_cv          = ConditionVariable.new
  @ref_registry      = {}
  @fingerprint_index = {}
  @snapshot_id       = nil
  @prev_snapshot     = nil
  @paused            = false
end

Instance Attribute Details

#driverObject (readonly)

Returns the value of attribute driver.



7
8
9
# File 'lib/browserctl/server/page_session.rb', line 7

def driver
  @driver
end

#fingerprint_indexObject

Returns the value of attribute fingerprint_index.



8
9
10
# File 'lib/browserctl/server/page_session.rb', line 8

def fingerprint_index
  @fingerprint_index
end

#mutexObject (readonly)

Returns the value of attribute mutex.



7
8
9
# File 'lib/browserctl/server/page_session.rb', line 7

def mutex
  @mutex
end

#pause_cvObject (readonly)

Returns the value of attribute pause_cv.



7
8
9
# File 'lib/browserctl/server/page_session.rb', line 7

def pause_cv
  @pause_cv
end

#prev_snapshotObject

Returns the value of attribute prev_snapshot.



8
9
10
# File 'lib/browserctl/server/page_session.rb', line 8

def prev_snapshot
  @prev_snapshot
end

#ref_registryObject

Returns the value of attribute ref_registry.



8
9
10
# File 'lib/browserctl/server/page_session.rb', line 8

def ref_registry
  @ref_registry
end

#snapshot_idObject

Returns the value of attribute snapshot_id.



8
9
10
# File 'lib/browserctl/server/page_session.rb', line 8

def snapshot_id
  @snapshot_id
end

Instance Method Details

#pageObject

Back-compat accessor. New handler code calls #driver directly; this returns the underlying Ferrum/CDP page for legacy callers (the CDP driver’s ‘devtools_info`, the page-lifecycle close path, and a unit spec).



33
34
35
# File 'lib/browserctl/server/page_session.rb', line 33

def page
  @driver.respond_to?(:raw_page) ? @driver.raw_page : @driver
end

#pause!Object



38
# File 'lib/browserctl/server/page_session.rb', line 38

def pause!  = (@paused = true)

#paused?Boolean

Returns:

  • (Boolean)


37
# File 'lib/browserctl/server/page_session.rb', line 37

def paused? = @paused

#resume!Object



39
# File 'lib/browserctl/server/page_session.rb', line 39

def resume! = (@paused = false)