Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1096)

Unified Diff: chrome/test/webdriver/test/chromedriver_tests.py

Issue 7648053: [chromedriver] Add chrome.detach option for configuring Chrome not to quit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: put in initializer Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/webdriver/test/chromedriver_tests.py
diff --git a/chrome/test/webdriver/test/chromedriver_tests.py b/chrome/test/webdriver/test/chromedriver_tests.py
index f5a5d2892bcb691ef88d20bd390565d7c56a94a5..9b209e0456a7b726c3e2f1b43c9bfbc1f65b9c26 100644
--- a/chrome/test/webdriver/test/chromedriver_tests.py
+++ b/chrome/test/webdriver/test/chromedriver_tests.py
@@ -14,6 +14,7 @@ from distutils import archive_util
import hashlib
import os
import platform
+import signal
import subprocess
import sys
import tempfile
@@ -71,6 +72,14 @@ def IsMac():
return sys.platform.startswith('darwin')
+def Kill(pid):
+ """Terminate the given pid."""
+ if IsWindows():
+ subprocess.call(['taskkill.exe', '/T', '/F', '/PID', str(pid)])
+ else:
+ os.kill(pid, signal.SIGTERM)
+
+
class Request(urllib2.Request):
"""Extends urllib2.Request to support all HTTP request types."""
@@ -324,6 +333,30 @@ class DesiredCapabilitiesTest(ChromeDriverTest):
self.assertNotEqual(-1, driver.page_source.find('ExtTest2'))
driver.quit()
+
+class DetachProcessTest(unittest.TestCase):
+
+ def setUp(self):
+ self._server = ChromeDriverLauncher(test_paths.CHROMEDRIVER_EXE).Launch()
+ self._factory = ChromeDriverFactory(self._server)
+
+ def tearDown(self):
+ self._server.Kill()
+
+ # TODO(kkania): Remove this when Chrome 15 is stable.
+ def testDetachProcess(self):
+ # This is a weak test. Its purpose is to just make sure we can start
+ # Chrome successfully in detached mode. There's not an easy way to know
+ # if Chrome is shutting down due to the channel error when the client
+ # disconnects.
+ driver = self._factory.GetNewDriver({'chrome.detach': True})
+ driver.get('about:memory')
+ pid = int(driver.find_elements_by_xpath('//*[@jscontent="pid"]')[0].text)
+ self._server.Kill()
+ os.kill(pid, 0) # Would throw if process no longer exists
Huyen 2011/08/18 23:54:49 Maybe assert process exists and fail to be more ob
kkania 2011/08/19 18:28:32 Done.
+ Kill(pid)
+
+
class CookieTest(ChromeDriverTest):
"""Cookie test for the json webdriver protocol"""

Powered by Google App Engine
This is Rietveld 408576698