Class: Google::Chrome::Tab

Inherits:
Object
  • Object
show all
Defined in:
lib/google/chrome/client.rb

Constant Summary collapse

@@seq =
1

Instance Method Summary collapse

Constructor Details

#initialize(client, number) ⇒ Tab

Returns a new instance of Tab.



110
111
112
113
# File 'lib/google/chrome/client.rb', line 110

def initialize(client, number)
  @client = client
  @number = number
end

Instance Method Details

#attachObject



120
121
122
123
124
125
126
127
128
129
# File 'lib/google/chrome/client.rb', line 120

def attach
  request({ 'command' => 'attach' })
  return unless block_given?

  begin
    yield
  ensure
    detach
  end
end

#debugger_command(command, arguments) ⇒ Object



135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/google/chrome/client.rb', line 135

def debugger_command(command, arguments)
  h, r = request({
                   'command' => 'debugger_command',
                   'data' => {
                     'seq' => @@seq,
                     'type' => 'request',
                     'command' => command,
                     'arguments' => arguments,
                   }
                 })
  @@seq += 1

  return h, r
end

#detachObject



131
132
133
# File 'lib/google/chrome/client.rb', line 131

def detach
  request({ 'command' => 'attach' })
end

#request(body) ⇒ Object



115
116
117
118
# File 'lib/google/chrome/client.rb', line 115

def request(body)
  @client.request({ 'Tool' => 'V8Debugger', 'Destination' => @number },
                  body)
end