Class: Puppeteer::ExecutionContext

Inherits:
Object
  • Object
show all
Includes:
EventCallbackable, IfPresent
Defined in:
lib/puppeteer/execution_context.rb,
sig/puppeteer/execution_context.rbs

Overview

rbs_inline: enabled

Defined Under Namespace

Classes: EvaluationError, JavaScriptExpression, JavaScriptFunction

Constant Summary collapse

EVALUATION_SCRIPT_URL =

Returns:

  • (::String)
'pprt://__puppeteer_evaluation_script__'
SOURCE_URL_REGEX =

Returns:

  • (::Regexp)
/^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from EventCallbackable

#add_event_listener, #emit_event, #observe_first, #off, #on_event, #remove_event_listener

Methods included from IfPresent

#if_present

Constructor Details

#initialize(client, context_payload, world) ⇒ Object

Parameters:



14
15
16
17
18
19
# File 'lib/puppeteer/execution_context.rb', line 14

def initialize(client, context_payload, world)
  @client = client
  @world = world
  @context_id = context_payload['id']
  @context_name = context_payload['name']
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.

Returns:

  • (Object)


21
22
23
# File 'lib/puppeteer/execution_context.rb', line 21

def client
  @client
end

#worldObject (readonly)

Returns the value of attribute world.

Returns:

  • (Object)


21
22
23
# File 'lib/puppeteer/execution_context.rb', line 21

def world
  @world
end

Instance Method Details

#disposevoid

This method returns an undefined value.



24
25
26
# File 'lib/puppeteer/execution_context.rb', line 24

def dispose
  emit_event('disposed')
end

#evaluate(page_function, *args) ⇒ Object

Parameters:

  • page_function (String)
  • args (Object)

Returns:

  • (Object)


40
41
42
# File 'lib/puppeteer/execution_context.rb', line 40

def evaluate(page_function, *args)
  evaluate_internal(true, page_function, *args)
end

#evaluate_handle(page_function, *args) ⇒ Puppeteer::JSHandle

Parameters:

  • page_function (String)
  • args (Object)

Returns:



46
47
48
# File 'lib/puppeteer/execution_context.rb', line 46

def evaluate_handle(page_function, *args)
  evaluate_internal(false, page_function, *args)
end