<commit_before>module Selenium
  module WebDriver
    module Firefox

      # @private
      class Binary

        WAIT_TIMEOUT = 90
        NO_FOCUS_LIBRARY_NAME = "x_ignore_nofocus.so"
        NO_FOCUS_LIBRARIES = [
          ["#{WebDriver.root}/selenium/webdriver/firefox/native/linux/amd64/#{NO_FOCUS_LIBRARY_NAME}", "amd64/#{NO_FOCUS_LIBRARY_NAME}"],
          ["#{WebDriver.root}/selenium/webdriver/firefox/native/linux/x86/#{NO_FOCUS_LIBRARY_NAME}", "x86/#{NO_FOCUS_LIBRARY_NAME}"],
        ]

        def start_with(profile, profile_path, *args)
          profile_path = profile_path.gsub("/", "\\") if Platform.win?

          ENV['XRE_PROFILE_PATH'] = profile_path
          ENV['MOZ_NO_REMOTE'] = '1' # able to launch multiple instances

          if Platform.linux? && (profile.native_events? || profile.load_no_focus_lib?)
            modify_link_library_path profile_path
          end

          ENV['XRE_CONSOLE_LOG'] = profile.log_file if profile.log_file

          execute(*args)
          cope_with_mac_strangeness(args) if Platform.mac?
        end

        def execute(*extra_args)
          args = [self.class.path, "-no-remote", "--verbose"] + extra_args
          @process = ChildProcess.build(*args).start
        end

        def cope_with_mac_strangeness(args)
          sleep 0.3

          if @process.crashed?
            # ok, trying a restart
            sleep 7
            execute(*args)
          end

          # ensure we're ok
          sleep 0.3
          if @process.crashed?
            raise Error::WebDriverError, "unable to start Firefox cleanly, args: #{args.inspect}"
          end
        end

        def quit
          return unless @process
          @process.poll_for_exit 5
        rescue ChildProcess::TimeoutError
          # ok, force quit
          @process.stop 5
        end

        def wait
          @process.poll_for_exit(WAIT_TIMEOUT) if @process
        end

        private

        def modify_link_library_path(profile_path)<commit_msg>JariBakken: Fix method visibility in Firefox::Binary<commit_after>module Selenium
  module WebDriver
    module Firefox

      # @private
      class Binary

        NO_FOCUS_LIBRARY_NAME = "x_ignore_nofocus.so"
        NO_FOCUS_LIBRARIES    = [
          ["#{WebDriver.root}/selenium/webdriver/firefox/native/linux/amd64/#{NO_FOCUS_LIBRARY_NAME}", "amd64/#{NO_FOCUS_LIBRARY_NAME}"],
          ["#{WebDriver.root}/selenium/webdriver/firefox/native/linux/x86/#{NO_FOCUS_LIBRARY_NAME}", "x86/#{NO_FOCUS_LIBRARY_NAME}"],
        ]

        WAIT_TIMEOUT          = 90

        def start_with(profile, profile_path, *args)
          profile_path = profile_path.gsub("/", "\\") if Platform.win?

          ENV['XRE_PROFILE_PATH'] = profile_path
          ENV['MOZ_NO_REMOTE'] = '1' # able to launch multiple instances

          if Platform.linux? && (profile.native_events? || profile.load_no_focus_lib?)
            modify_link_library_path profile_path
          end

          ENV['XRE_CONSOLE_LOG'] = profile.log_file if profile.log_file

          execute(*args)
          cope_with_mac_strangeness(args) if Platform.mac?
        end

        def quit
          return unless @process
          @process.poll_for_exit 5
        rescue ChildProcess::TimeoutError
          # ok, force quit
          @process.stop 5
        end

        def wait
          @process.poll_for_exit(WAIT_TIMEOUT) if @process
        end

        private

        def execute(*extra_args)
          args = [self.class.path, "-no-remote", "--verbose"] + extra_args
          @process = ChildProcess.build(*args).start
        end

        def cope_with_mac_strangeness(args)
          sleep 0.3

          if @process.crashed?
            # ok, trying a restart
            sleep 7
            execute(*args)
          end

          # ensure we're ok
          sleep 0.3
          if @process.crashed?
            raise Error::WebDriverError, "unable to start Firefox cleanly, args: #{args.inspect}"
          end
        end

        def modify_link_library_path(profile_path)
{'fraction_non_alphanumeric': 0.09586002957121735, 'fraction_numerical': 0.008871365204534253, 'mean_word_length': 2.072672218016654, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6709329', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1221, 'n_words': 238}