unsafe_browser.rb 4.51 KB
Newer Older
1
When /^I see and accept the Unsafe Browser start verification$/ do
Tails developers's avatar
Tails developers committed
2
  @screen.wait("UnsafeBrowserStartVerification.png", 30)
3 4 5 6
  @screen.type("l", Sikuli::KEY_ALT)
end

Then /^I see and close the Unsafe Browser start notification$/ do
7
  @screen.wait_and_click("UnsafeBrowserStartNotification.png", 30)
8 9 10
end

Then /^the Unsafe Browser has started$/ do
Tails developers's avatar
Tails developers committed
11
  @screen.wait("UnsafeBrowserWindow.png", 360)
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
end

Then /^the Unsafe Browser has a red theme$/ do
  @screen.wait("UnsafeBrowserRedTheme.png", 10)
end

Then /^the Unsafe Browser has Wikipedia pre-selected in the search bar$/ do
  @screen.wait("UnsafeBrowserSearchBar.png", 10)
end

Then /^the Unsafe Browser shows a warning as its start page$/ do
  @screen.wait("UnsafeBrowserStartPage.png", 10)
end

When /^I start the Unsafe Browser$/ do
27 28 29 30 31 32 33
  unsafe_browser_cmd = nil
  @vm.execute("cat /usr/share/applications/unsafe-browser.desktop").stdout.chomp.each_line { |line|
    next if ! line.start_with? "Exec="
    unsafe_browser_cmd = line[/^Exec=(.*)/,1]
  }
  assert(!unsafe_browser_cmd.nil?, "failed to extract the unsafe browser command")
  step "I run \"#{unsafe_browser_cmd}\""
34 35 36 37 38 39 40 41
  step "I see and accept the Unsafe Browser start verification"
  step "I see and close the Unsafe Browser start notification"
end

Then /^I see a warning about another instance already running$/ do
  @screen.wait('UnsafeBrowserWarnAlreadyRunning.png', 10)
end

Tails developers's avatar
Tails developers committed
42
When /^I close the Unsafe Browser$/ do
43 44 45 46 47 48 49 50 51 52 53 54 55 56
  @screen.type("q", Sikuli::KEY_CTRL)
end

Then /^I see the Unsafe Browser stop notification$/ do
  @screen.wait('UnsafeBrowserStopNotification.png', 20)
  @screen.waitVanish('UnsafeBrowserStopNotification.png', 20)
end

Then /^I can start the Unsafe Browser again$/ do
  step "I start the Unsafe Browser"
end

When /^I open a new tab in the Unsafe Browser$/ do
  next if @skip_steps_while_restoring_background
57
  @screen.wait_and_click("UnsafeBrowserWindow.png", 10)
58 59 60 61 62 63 64 65 66
  @screen.type("t", Sikuli::KEY_CTRL)
end

When /^I open the address "([^"]*)" in the Unsafe Browser$/ do |address|
  next if @skip_steps_while_restoring_background
  step "I open a new tab in the Unsafe Browser"
  @screen.type("l", Sikuli::KEY_CTRL)
  @screen.type(address + Sikuli::KEY_RETURN)
end
67 68

Then /^I cannot configure the Unsafe Browser to use any local proxies$/ do
69
  @screen.wait_and_click("UnsafeBrowserWindow.png", 10)
Tails developers's avatar
Tails developers committed
70
  sleep 0.5
71 72 73 74 75
  # First we open the proxy settings page to prepare it with the
  # correct open tabs for the loop below.
  @screen.type("e", Sikuli::KEY_ALT)
  @screen.type("n")
  @screen.wait('UnsafeBrowserPreferences.png', 10)
76 77
  @screen.wait_and_click('UnsafeBrowserAdvancedSettings.png', 10)
  @screen.wait_and_click('UnsafeBrowserNetworkTab.png', 10)
78 79
  sleep 0.5
  @screen.type(Sikuli::KEY_ESC)
80 81
#  @screen.waitVanish('UnsafeBrowserPreferences.png', 10)
  sleep 0.5
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110

  http_proxy  = 'x' # Alt+x is the shortcut to select http proxy
  socks_proxy = 'c' # Alt+c for socks proxy
  no_proxy    = 'y' # Alt+y for no proxy

  # Note: the loop below depends on that http_proxy is done after any
  # other proxy types since it will set "Use this proxy server for all
  # protocols", which will make the other proxy types unselectable.
  proxies = [[socks_proxy, 9050],
             [socks_proxy, 9061],
             [socks_proxy, 9062],
             [socks_proxy, 9063],
             [http_proxy,  8118],
             [no_proxy,       0]]

  proxies.each do |proxy|
    proxy_type = proxy[0]
    proxy_port = proxy[1]

    # Open proxy settings and select manual proxy configuration
    @screen.type("e", Sikuli::KEY_ALT)
    @screen.type("n")
    @screen.wait('UnsafeBrowserPreferences.png', 10)
    @screen.type("e", Sikuli::KEY_ALT)
    @screen.wait('UnsafeBrowserProxySettings.png', 10)
    @screen.type("m", Sikuli::KEY_ALT)

    # Configure the proxy
    @screen.type(proxy_type, Sikuli::KEY_ALT)  # Select correct proxy type
Tails developers's avatar
Tails developers committed
111
    @screen.type("127.0.0.1\t#{proxy_port}") if proxy_type != no_proxy
112 113 114 115 116
    # For http proxy we set "Use this proxy server for all protocols"
    @screen.type("s", Sikuli::KEY_ALT) if proxy_type == http_proxy

    # Close settings settings
    @screen.type(Sikuli::KEY_RETURN)
117 118
#    @screen.waitVanish('UnsafeBrowserProxySettings.png', 10)
    sleep 0.5
119
    @screen.type(Sikuli::KEY_ESC)
120 121
#    @screen.waitVanish('UnsafeBrowserPreferences.png', 10)
    sleep 0.5
122 123 124 125 126 127 128 129 130 131

    # Test that the proxy settings work as they should
    step "I open the address \"https://check.torproject.org\" in the Unsafe Browser"
    if proxy_type == no_proxy
      @screen.wait('UnsafeBrowserTorCheckFail.png', 60)
    else
      @screen.wait('UnsafeBrowserProxyRefused.png', 60)
    end
  end
end