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

Side by Side Diff: tools/telemetry/telemetry/core/webdriver/webdriver_tab_list_backend.py

Issue 20672002: [telemetry] Add a webdriver backend with support for IE. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright (c) 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.
4
5 from telemetry.core.webdriver import webdriver_tab_backend
6
7 class WebDriverTabListBackend(object):
8 def __init__(self, browser_backend):
9 self._browser_backend = browser_backend
10 # Stores the window handles.
11 self._tab_list = []
12
13 def Init(self):
14 self._UpdateTabList()
15
16 def New(self, timeout=None):
17 raise NotImplementedError()
18
19 def __iter__(self):
20 self._UpdateTabList()
21 return self._tab_list.__iter__()
22
23 def __len__(self):
24 self._UpdateTabList()
25 return len(self._tab_list)
26
27 def __getitem__(self, index):
28 self._UpdateTabList()
29 if len(self._tab_list) <= index:
30 raise IndexError('list index out of range')
31 return self._tab_list[index]
32
33 def _UpdateTabList(self):
34 window_handles = self._browser_backend.driver.window_handles
35 old_tab_list = self._tab_list
36 self._tab_list = []
37 for window_handle in window_handles:
38 tab = None
39 for old_tab in old_tab_list:
40 if old_tab.window_handle == window_handle:
41 tab = old_tab
42 break
43 else:
44 tab = webdriver_tab_backend.WebDriverTabBackend(
45 self._browser_backend, window_handle)
46 self._tab_list.append(tab)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698