Эх сурвалжийг харах

Fiddle with Firefox profile scope to keep temp dir around

Previously, when the $profile var in setup_firefox_env_vars went out of
scope at the end of the function, its File::Temp->newdir also went out
of scope and was getting automatically cleaned up. However, we need to
keep the profile directory around until the end of the script since
Firefox needs to be using it the entire time.

So, we've moved profile out of the function so it isn't DESTROY'd until
the end of the script's life time. However, we're running into a race
condition where the Firefox binary is still running while Perl is
DESTROYing everything - so the files in the tempdir are locked. We can't
delete them until after the Firefox process dies...
Daniel Gempesaw 10 жил өмнө
parent
commit
99eae0b979

+ 4 - 1
lib/Selenium/Firefox/Binary.pm

@@ -60,11 +60,14 @@ sub firefox_path {
     return $path;
 }
 
+# We want the profile to persist to the end of the session, not just
+# the end of this function.
+my $profile;
 sub setup_firefox_binary_env {
     my ($port) = @_;
 
     # TODO: respect the user's profile instead of overwriting it
-    my $profile = Selenium::Firefox::Profile->new;
+    $profile = Selenium::Firefox::Profile->new;
     $profile->add_webdriver($port);
 
     $ENV{'XRE_PROFILE_PATH'} = $profile->_layout_on_disk;