1
0

Binary.pm 835 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package Selenium::Firefox::Binary;
  2. # ABSTRACT: Portable handler to start the firefox binary
  3. use File::Which qw/which/;
  4. require Exporter;
  5. our @ISA = qw/Exporter/;
  6. our @EXPORT_OK = qw/path/;
  7. sub _windows_path {
  8. # TODO: make this slightly less dumb
  9. return which('firefox');
  10. }
  11. sub _darwin_path {
  12. my $default_firefox = '/Applications/Firefox.app/Contents/MacOS/firefox-bin';
  13. if (-e $default_firefox) {
  14. return $default_firefox
  15. }
  16. else {
  17. return which('firefox-bin');
  18. }
  19. }
  20. sub _unix_path {
  21. # TODO: maybe which('firefox3'), which('firefox2') ?
  22. return which('firefox') || '/usr/bin/firefox';
  23. }
  24. sub path {
  25. if ($^O eq 'MSWin32') {
  26. return _windows_path();
  27. }
  28. elsif ($^O eq 'darwin') {
  29. return _darwin_path();
  30. }
  31. else {
  32. return _unix_path;
  33. }
  34. }
  35. 1;