From a6f41c35e337db192e612ee6e1545fcae4c69ac7 Mon Sep 17 00:00:00 2001 From: Philip Hands Date: Thu, 29 Jun 2017 22:11:09 +0200 Subject: lvc: grab updates from tails (01371c19bd..6ae59c49e5) Signed-off-by: Holger Levsen --- cucumber/features/step_definitions/browser.rb | 100 ++++++++++++++++---------- 1 file changed, 62 insertions(+), 38 deletions(-) (limited to 'cucumber/features/step_definitions/browser.rb') diff --git a/cucumber/features/step_definitions/browser.rb b/cucumber/features/step_definitions/browser.rb index 84ef1d35..68d1bca4 100644 --- a/cucumber/features/step_definitions/browser.rb +++ b/cucumber/features/step_definitions/browser.rb @@ -1,41 +1,28 @@ -Then /^I see the (Unsafe|I2P) Browser start notification and wait for it to close$/ do |browser_type| - robust_notification_wait("#{browser_type}BrowserStartNotification.png", 60) +Then /^the Unsafe Browser has started$/ do + @screen.wait("UnsafeBrowserHomepage.png", 360) end -Then /^the (Unsafe|I2P) Browser has started$/ do |browser_type| - case browser_type - when 'Unsafe' - @screen.wait("UnsafeBrowserHomepage.png", 360) - when 'I2P' - step 'the I2P router console is displayed in I2P Browser' - end -end - -When /^I start the (Unsafe|I2P) Browser(?: through the GNOME menu)?$/ do |browser_type| - step "I start \"#{browser_type}Browser\" via the GNOME \"Internet\" applications menu" +When /^I start the Unsafe Browser(?: through the GNOME menu)?$/ do + step "I start \"Unsafe Browser\" via GNOME Activities Overview" end -When /^I successfully start the (Unsafe|I2P) Browser$/ do |browser_type| - step "I start the #{browser_type} Browser" - step "I see and accept the Unsafe Browser start verification" unless browser_type == 'I2P' - step "I see the #{browser_type} Browser start notification and wait for it to close" - step "the #{browser_type} Browser has started" +When /^I successfully start the Unsafe Browser$/ do + step "I start the Unsafe Browser" + step "I see and accept the Unsafe Browser start verification" + step "I see the \"Starting the Unsafe Browser...\" notification after at most 60 seconds" + step "the Unsafe Browser has started" end -When /^I close the (?:Unsafe|I2P) Browser$/ do +When /^I close the Unsafe Browser$/ do @screen.type("q", Sikuli::KeyModifier.CTRL) end -Then /^I see the (Unsafe|I2P) Browser stop notification$/ do |browser_type| - robust_notification_wait("#{browser_type}BrowserStopNotification.png", 60) -end - def xul_application_info(application) binary = $vm.execute_successfully( 'echo ${TBB_INSTALL}/firefox', :libs => 'tor-browser' ).stdout.chomp address_bar_image = "BrowserAddressBar.png" - unused_tbb_libs = ['libnssdbm3.so'] + unused_tbb_libs = ['libnssdbm3.so', "libmozavcodec.so", "libmozavutil.so"] case application when "Tor Browser" user = LIVE_USER @@ -47,11 +34,6 @@ def xul_application_info(application) cmd_regex = "#{binary} .* -profile /home/#{user}/\.unsafe-browser/profile\.default" chroot = "/var/lib/unsafe-browser/chroot" new_tab_button_image = "UnsafeBrowserNewTabButton.png" - when "I2P Browser" - user = "i2pbrowser" - cmd_regex = "#{binary} .* -profile /home/#{user}/\.i2p-browser/profile\.default" - chroot = "/var/lib/i2p-browser/chroot" - new_tab_button_image = "I2PBrowserNewTabButton.png" when "Tor Launcher" user = "tor-launcher" # We do not enable AppArmor confinement for the Tor Launcher. @@ -100,19 +82,41 @@ When /^I open the address "([^"]*)" in the (.*)$/ do |address, browser| @screen.type('v', Sikuli::KeyModifier.CTRL) @screen.type(Sikuli::Key.ENTER) end - open_address.call + recovery_on_failure = Proc.new do + @screen.type(Sikuli::Key.ESC) + @screen.waitVanish('BrowserReloadButton.png', 3) + open_address.call + end if browser == "Tor Browser" - recovery_on_failure = Proc.new do - @screen.type(Sikuli::Key.ESC) - @screen.waitVanish('BrowserReloadButton.png', 3) - open_address.call - end - retry_tor(recovery_on_failure) do - @screen.wait('BrowserReloadButton.png', 120) - end + retry_method = method(:retry_tor) + else + retry_method = Proc.new { |p, &b| retry_action(10, recovery_proc: p, &b) } + end + open_address.call + retry_method.call(recovery_on_failure) do + @screen.wait('BrowserReloadButton.png', 120) end end +# This step is limited to the Tor Browser due to #7502 since dogtail +# uses the same interface. +Then /^"([^"]+)" has loaded in the Tor Browser$/ do |title| + if @language == 'German' + browser_name = 'Tor-Browser' + reload_action = 'Aktuelle Seite neu laden' + else + browser_name = 'Tor Browser' + reload_action = 'Reload current page' + end + expected_title = "#{title} - #{browser_name}" + try_for(60) { @torbrowser.child(expected_title, roleName: 'frame') } + # The 'Reload current page' button (graphically shown as a looping + # arrow) is only shown when a page has loaded, so once we see the + # expected title *and* this button has appeared, then we can be sure + # that the page has fully loaded. + try_for(60) { @torbrowser.child(reload_action, roleName: 'push button') } +end + Then /^the (.*) has no plugins installed$/ do |browser| step "I open the address \"about:plugins\" in the #{browser}" step "I see \"TorBrowserNoPlugins.png\" after at most 30 seconds" @@ -193,3 +197,23 @@ Then /^the file is saved to the default Tor Browser download directory$/ do expected_path = "/home/#{LIVE_USER}/Tor Browser/#{@some_file}" try_for(10) { $vm.file_exist?(expected_path) } end + +When /^I open Tails homepage in the (.+)$/ do |browser| + step "I open the address \"https://tails.boum.org\" in the #{browser}" +end + +Then /^Tails homepage loads in the Tor Browser$/ do + title = 'Tails - Privacy for anyone anywhere' + step "\"#{title}\" has loaded in the Tor Browser" +end + +Then /^Tails homepage loads in the Unsafe Browser$/ do + @screen.wait('TailsHomepage.png', 60) +end + +Then /^the Tor Browser shows the "([^"]+)" error$/ do |error| + page = @torbrowser.child("Problem loading page", roleName: "document frame") + headers = page.children(roleName: "heading") + found = headers.any? { |heading| heading.text == error } + raise "Could not find the '#{error}' error in the Tor Browser" unless found +end -- cgit v1.2.3-70-g09d2