<commit_before>defmodule WebDriver.Firefox.Port do
  use GenServer.Behaviour
  use WebDriver.Browser

  @moduledoc """
    This module is a server that controls the running of the Firefox browser.
    It uses an Erlang port to communicate with the browser.

    None of the functions here are user facing and are controlled by the
    BrowserSup.
  """

  @osx_path "/Applications/Firefox.app/Contents/MacOS/firefox-bin"
  @win_path "%PROGRAMFILES%\\Mozilla Firefox\\firefox.exe"
  @start_wait_timeout 10000

  alias WebDriver.Firefox.Profile

  defrecord State, port: nil,
                   root_url: "",
                   program_name: "",
                   supervisor: nil,
                   session_supervisor: nil,
                   firefox_temp_dir: "",
                   kill_command: "",
                   http_port: nil

  def program_name _state do
    Path.join [ __DIR__, "shim.sh"]
  end

  def installed? do
    [f|_] = arguments("")
    IO.puts(f)
    File.exists?(f)
  end

  # Because we are using a shim the Firefox program name becomes the argument.
  defp arguments _state do
    [ case platform do
        :osx ->     :os.find_executable('firefox-bin') or @osx_path
        # Windows is not actually supported yet, the startup shim wont work.
        :windows -> :os.find_executable('firefox') or @win_path
        :unix ->    :os.find_executable('firefox3') or
                    :os.find_executable('firefox2') or
                    :os.find_executable('firefox')
     end ]
  end

  defp platform do
    case :os.type do
      { :unix, :darwin } -> :osx
      { :unix,  _ }      -> :unix
      { :win32, _ }      -> :windows<commit_msg>Add sessions list to Firefox port state<commit_after>defmodule WebDriver.Firefox.Port do
  use GenServer.Behaviour
  use WebDriver.Browser

  @moduledoc """
    This module is a server that controls the running of the Firefox browser.
    It uses an Erlang port to communicate with the browser.

    None of the functions here are user facing and are controlled by the
    BrowserSup.
  """

  @osx_path "/Applications/Firefox.app/Contents/MacOS/firefox-bin"
  @win_path "%PROGRAMFILES%\\Mozilla Firefox\\firefox.exe"
  @start_wait_timeout 10000

  alias WebDriver.Firefox.Profile

  defrecord State, port: nil,
                   root_url: "",
                   program_name: "",
                   supervisor: nil,
                   session_supervisor: nil,
                   firefox_temp_dir: "",
                   kill_command: "",
                   sessions: [],
                   http_port: nil

  def program_name _state do
    Path.join [ __DIR__, "shim.sh"]
  end

  def installed? do
    [f|_] = arguments("")
    IO.puts(f)
    File.exists?(f)
  end

  # Because we are using a shim the Firefox program name becomes the argument.
  defp arguments _state do
    [ case platform do
        :osx ->     :os.find_executable('firefox-bin') or @osx_path
        # Windows is not actually supported yet, the startup shim wont work.
        :windows -> :os.find_executable('firefox') or @win_path
        :unix ->    :os.find_executable('firefox3') or
                    :os.find_executable('firefox2') or
                    :os.find_executable('firefox')
     end ]
  end

  defp platform do
    case :os.type do
      { :unix, :darwin } -> :osx
      { :unix,  _ }      -> :unix
      { :win32, _ }      -> :windows
{'fraction_non_alphanumeric': 0.09537827494848396, 'fraction_numerical': 0.005298793052693553, 'mean_word_length': 2.0778985507246377, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '6175065', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1002, 'n_words': 294}