• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2013 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4import re
5import urllib2
6
7from telemetry.core.backends.webdriver import webdriver_browser_backend
8
9class WebDriverIEBackend(webdriver_browser_backend.WebDriverBrowserBackend):
10  # For unsupported functions. pylint: disable=W0223
11
12  def __init__(self, platform_backend, driver_creator, browser_options):
13    super(WebDriverIEBackend, self).__init__(
14        driver_creator=driver_creator,
15        supports_extensions=False,
16        browser_options=browser_options)
17    self._platform_backend = platform_backend
18
19  def GetProcessName(self, cmd_line):
20    if re.search('SCODEF:\d+ CREDAT:\d+', cmd_line, re.IGNORECASE):
21      return 'Content'
22    else:
23      return 'Manager'
24
25  @property
26  def pid(self):
27    for pi in self._platform_backend.GetSystemProcessInfo():
28      if (pi['ParentProcessId'] == self.driver.iedriver.process.pid and
29          pi['Name'].lower() == 'iexplore.exe'):
30        return pi['ProcessId']
31    return None
32
33  def Close(self):
34    try:
35      super(WebDriverIEBackend, self).Close()
36    except urllib2.URLError:
37      # CTRL + C makes IEDriverServer exits while leaving IE still running.
38      for pi in self._platform_backend.GetSystemProcessInfo():
39        if (pi['ParentProcessId'] == self.driver.iedriver.process.pid):
40          self._platform_backend.KillProcess(pi['ProcessId'], True)
41
42  def IsBrowserRunning(self):
43    return self.pid is not None
44