Binary.pm 951 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. my $path;
  26. if ($^O eq 'MSWin32') {
  27. $path =_windows_path();
  28. }
  29. elsif ($^O eq 'darwin') {
  30. $path =_darwin_path();
  31. }
  32. else {
  33. $path = _unix_path;
  34. }
  35. if (not -x $path) {
  36. die $path . ' is not an executable file.';
  37. }
  38. return $path;
  39. }
  40. 1;