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

7 8 9 10 11 12
Then /^I see the Unsafe Browser start notification and wait for it to close$/ do
  next if @skip_steps_while_restoring_background
  @screen.wait("UnsafeBrowserStartNotification.png", 30)
  @screen.waitVanish("UnsafeBrowserStartNotification.png", 10)
end

13
Then /^the Unsafe Browser has started$/ do
14
  next if @skip_steps_while_restoring_background
15
  @screen.wait("UnsafeBrowserHomepage.png", 360)
16 17 18
end

Then /^the Unsafe Browser has a red theme$/ do
19
  next if @skip_steps_while_restoring_background
20 21 22 23
  @screen.wait("UnsafeBrowserRedTheme.png", 10)
end

Then /^the Unsafe Browser shows a warning as its start page$/ do
24
  next if @skip_steps_while_restoring_background
25 26 27 28
  @screen.wait("UnsafeBrowserStartPage.png", 10)
end

When /^I start the Unsafe Browser$/ do
29
  next if @skip_steps_while_restoring_background
30 31 32 33 34 35 36 37
  @screen.wait_and_click("GnomeApplicationsMenu.png", 10)
  @screen.wait_and_click("GnomeApplicationsInternet.png", 10)
  @screen.wait_and_click("GnomeApplicationsUnsafeBrowser.png", 20)
end

When /^I successfully start the Unsafe Browser$/ do
  next if @skip_steps_while_restoring_background
  step "I start the Unsafe Browser"
38
  step "I see and accept the Unsafe Browser start verification"
39
  step "I see the Unsafe Browser start notification and wait for it to close"
40
  step "the Unsafe Browser has started"
41 42 43
end

Then /^I see a warning about another instance already running$/ do
44
  next if @skip_steps_while_restoring_background
45 46 47
  @screen.wait('UnsafeBrowserWarnAlreadyRunning.png', 10)
end

Tails developers's avatar
Tails developers committed
48
When /^I close the Unsafe Browser$/ do
49
  next if @skip_steps_while_restoring_background
50
  @screen.type("q", Sikuli::KeyModifier.CTRL)
51 52
end

53 54 55 56 57 58
Then /^I see the Unsafe Browser stop notification$/ do
  next if @skip_steps_while_restoring_background
  @screen.wait('UnsafeBrowserStopNotification.png', 20)
  @screen.waitVanish('UnsafeBrowserStopNotification.png', 10)
end

59
Then /^I can start the Unsafe Browser again$/ do
60
  next if @skip_steps_while_restoring_background
61 62 63 64 65
  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
66
  @screen.wait_and_click("UnsafeBrowserWindow.png", 10)
67
  @screen.type("t", Sikuli::KeyModifier.CTRL)
68 69 70 71 72
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"
73
  @screen.type("l", Sikuli::KeyModifier.CTRL)
74
  sleep 0.5
75
  @screen.type(address + Sikuli::Key.ENTER)
76
end
77 78

Then /^I cannot configure the Unsafe Browser to use any local proxies$/ do
79
  next if @skip_steps_while_restoring_background
80
  @screen.wait_and_click("UnsafeBrowserWindow.png", 10)
Tails developers's avatar
Tails developers committed
81
  sleep 0.5
82 83
  # First we open the proxy settings page to prepare it with the
  # correct open tabs for the loop below.
84
  @screen.type("e", Sikuli::KeyModifier.ALT)
85 86
  @screen.type("n")
  @screen.wait('UnsafeBrowserPreferences.png', 10)
87 88
  @screen.wait_and_click('UnsafeBrowserAdvancedSettings.png', 10)
  @screen.wait_and_click('UnsafeBrowserNetworkTab.png', 10)
89
  sleep 0.5
90
  @screen.type(Sikuli::Key.ESC)
91 92
#  @screen.waitVanish('UnsafeBrowserPreferences.png', 10)
  sleep 0.5
93 94 95 96 97 98 99 100 101 102 103

  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],
104
             [socks_proxy, 9150],
105 106 107 108 109 110 111 112
             [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
113
    @screen.type("e", Sikuli::KeyModifier.ALT)
114 115
    @screen.type("n")
    @screen.wait('UnsafeBrowserPreferences.png', 10)
116
    @screen.type("e", Sikuli::KeyModifier.ALT)
117
    @screen.wait('UnsafeBrowserProxySettings.png', 10)
118
    @screen.type("m", Sikuli::KeyModifier.ALT)
119 120

    # Configure the proxy
121 122
    @screen.type(proxy_type, Sikuli::KeyModifier.ALT)  # Select correct proxy type
    @screen.type("127.0.0.1" + Sikuli::Key.TAB + "#{proxy_port}") if proxy_type != no_proxy
123
    # For http proxy we set "Use this proxy server for all protocols"
124
    @screen.type("s", Sikuli::KeyModifier.ALT) if proxy_type == http_proxy
125

Tails developers's avatar
Tails developers committed
126
    # Close settings
127
    @screen.type(Sikuli::Key.ENTER)
128 129
#    @screen.waitVanish('UnsafeBrowserProxySettings.png', 10)
    sleep 0.5
130
    @screen.type(Sikuli::Key.ESC)
131 132
#    @screen.waitVanish('UnsafeBrowserPreferences.png', 10)
    sleep 0.5
133 134 135 136 137 138 139 140 141 142

    # 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