Class: Selenium::WebDriver::Tor::Driver

Inherits:
DriverDelegate show all
Extended by:
LibxulPatchable
Defined in:
lib/tor/driver.rb

Overview

tor driver

Constant Summary collapse

TORRC =
'torrc'
PREF_BROWSER_SECURITY_LEVEL =
'browser.security_level.security_slider'
PREF_TORRC_PATH =
'extensions.torlauncher.torrc_path'
PREF_SOCKS_PORT =
'network.proxy.socks_port'
DOMAIN_ISOLATOR =

ES6 module

'TorDomainIsolator'
NEW_CIRCUIT =

js function

'newCircuitForDomain'
TB_SEC_LEVELS =
{ 'standard' => 4, 'safer' => 2, 'safest' => 1 }.freeze
LOCALHOST_PORT_REGEXP =
/127\.0\.0\.1:(\d+)/

Constants included from LibxulPatchable

LibxulPatchable::INVALID, LibxulPatchable::ISSUES_URL, LibxulPatchable::LIBXUL_CHECKSUMS_FILE, LibxulPatchable::NO_PATCH_MSG, LibxulPatchable::PATCH_REPO_PATCHES_URL, LibxulPatchable::PATCH_REPO_URL, LibxulPatchable::REPO_LIBXUL_CHECKSUMS, LibxulPatchable::THIS_REPO

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LibxulPatchable

libxul_patched?, patch_libxul, unpatch_libxul

Methods included from Firefox::FirefoxPrefs

#pref

Methods included from Firefox::FirefoxJsHelpers

#es6_const_call, #es6_function_call, #execute_script_in_chrome_context

Constructor Details

#initialize(options: nil) ⇒ Driver

Returns a new instance of Driver.



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/tor/driver.rb', line 36

def initialize(options: nil, **)
  @data_dir = Dir.mktmpdir
  @options = options || Options.new # fix for issue #11, 'tis a puzzlement
  @options.add_argument '-remote-allow-system-access' # FF 138+
  add_torrc_path_to_options
  @instance = DriverDelegate.new(options: @options, **)
  install_extensions @instance
  pid = create_tor_process_and_start_tor(@options.tor_opts)
  @instance.pref[PREF_SOCKS_PORT] = socks_port(pid)
  super(@instance)
end

Instance Attribute Details

#tor_processObject (readonly)

Returns the value of attribute tor_process.



34
35
36
# File 'lib/tor/driver.rb', line 34

def tor_process
  @tor_process
end

Instance Method Details

#browserObject



48
49
50
# File 'lib/tor/driver.rb', line 48

def browser
  :tor # overides :firefox
end

#new_circuit_for_siteObject Also known as: new_circuit_for_page

pref = int end



69
70
71
# File 'lib/tor/driver.rb', line 69

def new_circuit_for_site
  execute_script_in_chrome_context es6_function_call(es6: DOMAIN_ISOLATOR, func: NEW_CIRCUIT, args: domain)
end

#quitObject



52
53
54
55
56
# File 'lib/tor/driver.rb', line 52

def quit
  @tor_process&.stop_tor
  FileUtils.rm_rf @data_dir
  super
end

#security_levelObject



58
59
60
# File 'lib/tor/driver.rb', line 58

def security_level
  pref[PREF_BROWSER_SECURITY_LEVEL]
end