Class: JsshSocket

Inherits:
FirefoxSocket show all
Defined in:
lib/vapir-firefox/firefox_socket/jssh.rb

Overview

A JsshSocket represents a connection to Firefox over a socket opened to the JSSH extension.

Constant Summary

Constants inherited from FirefoxSocket

FirefoxSocket::PrototypeFile

Instance Attribute Summary

Attributes inherited from FirefoxSocket

#temp_object

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FirefoxSocket

#Components, #assert_socket, #assign, #assign_json, #call, #call_function, #call_json, #configuration_parent, #function, #handle, #handle_json, #handling_connection_error, #host, #initialize, #inspect, #instanceof, #object, #object_in_temp, #parse_json, #port, #root, to_javascript, #typeof, #value, #value_json

Constructor Details

This class inherits a constructor from FirefoxSocket

Class Method Details

.command_line_flags(options = {}) ⇒ Object

returns an array of command line flags that should be used to invoke firefox for jssh



11
12
13
14
# File 'lib/vapir-firefox/firefox_socket/jssh.rb', line 11

def self.command_line_flags(options={})
  options = config.defined_hash.merge(options)
  ['-jssh', '-jssh-port', options['port']]
end

Instance Method Details

#eat_welcome_messageObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vapir-firefox/firefox_socket/jssh.rb', line 16

def eat_welcome_message
  @prompt="\n> "
  welcome="Welcome to the Mozilla JavaScript Shell!\n"
  read=read_value
  if !read
    @expecting_extra_maybe=true
    raise FirefoxSocketUnableToStart, "Something went wrong initializing - no response" 
  elsif read != welcome
    @expecting_extra_maybe=true
    raise FirefoxSocketUnableToStart, "Something went wrong initializing - message #{read.inspect} != #{welcome.inspect}" 
  end
end

#getWindowsObject

returns a JavascriptObject representing the return value of JSSH’s builtin getWindows() function.



46
47
48
# File 'lib/vapir-firefox/firefox_socket/jssh.rb', line 46

def getWindows
  root.getWindows
end

#initialize_environmentObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/vapir-firefox/firefox_socket/jssh.rb', line 28

def initialize_environment
  # set up objects that are needed: nativeJSON_encode_length, VapirTemp, and Vapir
  ret=send_and_read(%Q((function()
  { nativeJSON_encode_length=function(object)
    { var encoded=JSON.stringify(object);
      return encoded.length.toString()+"\\n"+encoded;
    }
    VapirTemp = {};
    Vapir = {};
    return 'done!';
  })()))
  if ret != "done!"
    @expecting_extra_maybe=true
    raise FirefoxSocketError, "Something went wrong initializing environment - message #{ret.inspect}"
  end
end