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

Unified Diff: chrome/test/chromedriver/test/run_py_tests.py

Issue 1669453002: [chromedriver] Apply page load timeout to slow cross-process navigations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pure virtual Created 4 years, 8 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
« no previous file with comments | « chrome/test/chromedriver/session_commands.cc ('k') | chrome/test/chromedriver/test/webserver.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/test/run_py_tests.py
diff --git a/chrome/test/chromedriver/test/run_py_tests.py b/chrome/test/chromedriver/test/run_py_tests.py
index 279e474d65e3c098c985714077888075668d0f32..da77056f035eb9cc139d326b3bbe8b58b7ee4d76 100755
--- a/chrome/test/chromedriver/test/run_py_tests.py
+++ b/chrome/test/chromedriver/test/run_py_tests.py
@@ -255,13 +255,28 @@ class ChromeDriverBaseTest(unittest.TestCase):
return False
-class ChromeDriverTest(ChromeDriverBaseTest):
+class ChromeDriverBaseTestWithWebServer(ChromeDriverBaseTest):
+
+ @staticmethod
+ def GlobalSetUp():
+ ChromeDriverBaseTestWithWebServer._http_server = webserver.WebServer(
+ chrome_paths.GetTestData())
+
+ @staticmethod
+ def GlobalTearDown():
+ ChromeDriverBaseTestWithWebServer._http_server.Shutdown()
+
+ @staticmethod
+ def GetHttpUrlForFile(file_path):
+ return ChromeDriverBaseTestWithWebServer._http_server.GetUrl() + file_path
+
+
+class ChromeDriverTest(ChromeDriverBaseTestWithWebServer):
"""End to end tests for ChromeDriver."""
@staticmethod
def GlobalSetUp():
- ChromeDriverTest._http_server = webserver.WebServer(
- chrome_paths.GetTestData())
+ ChromeDriverBaseTestWithWebServer.GlobalSetUp()
ChromeDriverTest._sync_server = webserver.SyncWebServer()
if _ANDROID_PACKAGE_KEY:
ChromeDriverTest._device = device_utils.DeviceUtils.HealthyDevices()[0]
@@ -275,11 +290,7 @@ class ChromeDriverTest(ChromeDriverBaseTest):
def GlobalTearDown():
if _ANDROID_PACKAGE_KEY:
forwarder.Forwarder.UnmapAllDevicePorts(ChromeDriverTest._device)
- ChromeDriverTest._http_server.Shutdown()
-
- @staticmethod
- def GetHttpUrlForFile(file_path):
- return ChromeDriverTest._http_server.GetUrl() + file_path
+ ChromeDriverBaseTestWithWebServer.GlobalTearDown()
def setUp(self):
self._driver = self.CreateDriver()
@@ -1243,6 +1254,48 @@ class ChromeDriverTest(ChromeDriverBaseTest):
self._driver.HandleAlert(True)
+class ChromeDriverPageLoadTimeoutTest(ChromeDriverBaseTestWithWebServer):
+
+ def _CheckPageLoadTimeout(self, driver, host=None):
+ initial_url = self.GetHttpUrlForFile('/chromedriver/empty.html')
+ driver.Load(initial_url)
+
+ request_received_event = threading.Event()
+ send_response_event = threading.Event()
+ def hang(request):
+ request_received_event.set()
+ # Don't hang infinitely, 10 seconds are enough.
+ send_response_event.wait(10)
+ return {}, 'Hi!'
+
+ try:
+ self._http_server.SetCallbackForPath('/hang', hang)
+ # NB: With a too small timeout chromedriver might not send the
+ # Navigate command at all.
+ driver.SetTimeout('page load', 500) # 500 ms
+ driver.Load(self._http_server.GetUrl(host) + '/hang')
+ except chromedriver.ChromeDriverException as e:
+ self.assertNotEqual(-1, e.message.find('timeout'))
+ # Verify that the browser actually made that request.
+ self.assertTrue(request_received_event.wait(1))
+ finally:
+ send_response_event.set()
+ pass
+
+ self.assertEquals(initial_url, driver.GetCurrentUrl())
+
+ def testPageLoadTimeout(self):
+ self._CheckPageLoadTimeout(self.CreateDriver())
+
+ def testPageLoadTimeoutCrossDomain(self):
+ driver = self.CreateDriver(
+ chrome_switches=['host-resolver-rules=MAP * 127.0.0.1'])
+ # Cross-domain navigation is likely to be a cross-process one. In this case
+ # DevToolsAgentHost behaves quite differently and does not send command
+ # responses if the navigation hangs, so this case deserves a dedicated test.
+ self._CheckPageLoadTimeout(driver, 'foo.bar')
+
+
class ChromeDriverAndroidTest(ChromeDriverBaseTest):
"""End to end tests for Android-specific tests."""
« no previous file with comments | « chrome/test/chromedriver/session_commands.cc ('k') | chrome/test/chromedriver/test/webserver.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698