Class: Minibidi::Realm

Inherits:
Object
  • Object
show all
Defined in:
lib/minibidi/realm.rb

Defined Under Namespace

Classes: ScriptEvaluationError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(browsing_context:, id:, origin:, type: nil) ⇒ Realm

Returns a new instance of Realm.



3
4
5
6
7
8
# File 'lib/minibidi/realm.rb', line 3

def initialize(browsing_context:, id:, origin:, type: nil)
  @browsing_context = browsing_context
  @id = id
  @origin = origin
  @type = type
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



26
27
28
# File 'lib/minibidi/realm.rb', line 26

def type
  @type
end

Instance Method Details

#script_evaluate(expression) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/minibidi/realm.rb', line 12

def script_evaluate(expression)
  result = @browsing_context.send(:bidi_call_async, 'script.evaluate', {
    expression: expression,
    target: { realm: @id },
    awaitPromise: true,
  }).wait

  if result[:type] == 'exception'
    raise ScriptEvaluationError.new(result[:exceptionDetails][:text])
  end

  deserialize(result[:result])
end