EranMes on behalf of RicardoSantos: Clean up after the Python FirefoxDriver by deleting the temporary folder after the driver quits.

git-svn-id: http://selenium.googlecode.com/svn/trunk/py@18340 07704840-8298-11de-bf8c-fd130f914ac9
diff --git a/selenium/webdriver/firefox/firefox_profile.py b/selenium/webdriver/firefox/firefox_profile.py
index eb9bb53..0102c43 100644
--- a/selenium/webdriver/firefox/firefox_profile.py
+++ b/selenium/webdriver/firefox/firefox_profile.py
@@ -100,10 +100,12 @@
         self.default_preferences = copy.deepcopy(
             FirefoxProfile.DEFAULT_PREFERENCES)
         self.profile_dir = profile_directory
+        self.tempfolder = None
         if self.profile_dir is None:
             self.profile_dir = self._create_tempfolder()
         else:
-            newprof = os.path.join(tempfile.mkdtemp(),
+            self.tempfolder = tempfile.mkdtemp()
+            newprof = os.path.join(self.tempfolder,
                 "webdriver-py-profilecopy")
             shutil.copytree(self.profile_dir, newprof,
                 ignore=shutil.ignore_patterns("parent.lock", "lock", ".parentlock"))
diff --git a/selenium/webdriver/firefox/webdriver.py b/selenium/webdriver/firefox/webdriver.py
index 680a15d..624fd17 100644
--- a/selenium/webdriver/firefox/webdriver.py
+++ b/selenium/webdriver/firefox/webdriver.py
@@ -74,6 +74,8 @@
         self.binary.kill()
         try:
             shutil.rmtree(self.profile.path)
+            if self.profile.tempfolder is not None:
+                shutil.rmtree(self.profile.tempfolder)
         except Exception, e:
             print str(e)