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

Side by Side Diff: tools/telemetry_auto/telemetry_auto/webui_page.py

Issue 11412238: Proof of concept for running extension API stack through dev tools. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « tools/telemetry_auto/telemetry_auto/oobe_page.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2012 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 import os
5 import sys
6
7 import telemetry
8 from telemetry import util
9
10 class TestException(Exception):
11 def __init__(self, message):
12 self.message = message
13 super(TestException, self).__init__()
14
15 def __str__(self):
16 return repr(self.message)
17
18 class WebUIPage(object):
19 def __init__(self, browser):
20 self.browser = browser
21 self.page = None
22
23 def __enter__(self):
24 return self
25
26 def __exit__(self, *args):
27 self.Close()
28
29 def AddTestHelperMethods(self):
30 next_command = """
31 var _raiseMouseEvent = function(target, var_args) {
32 var event = document.createEvent('MouseEvents');
33 event.initEvent.apply(event, Array.prototype.slice.call(arguments, 1));
34 target.dispatchEvent(event);
35 };
36 """
37 self.page.runtime.Execute(next_command)
38
39 def ConnectToFirstPage(self, pages):
40 try:
41 self.Close()
42 except Exception:
43 # Ignore exceptions here since the page might be gone by now.
44 pass
45
46 for page in pages:
47 self.page = self.browser.tabs.FindByUrl(page)
48 if not self.page is None:
49 print 'Connected to %s' % page
50 return True
51
52 return False
53
54 def WaitForPageToLoad(self, pages):
55 util.WaitFor(
56 lambda: self.ConnectToFirstPage(pages),
57 timeout=10)
58 if self.page is None:
59 raise TestException('Cannot connect to page(s)')
60
61 def WaitUnitGone(self):
62 util.WaitFor(
63 lambda: not self.ConnectToFirstPage(self.page_urls),
64 timeout=30)
65 if not self.page is None:
66 raise TestException('Cannot disconnect from the current page')
67
68 def ClickOnButton(self, button_id):
69 self.page.runtime.Execute("""
70 _raiseMouseEvent($('%s'), 'click', true, true);
71 """ % button_id)
72
73 def Close(self):
74 if not self.page is None:
75 self.page.Close()
76 self.page = None
77
OLDNEW
« no previous file with comments | « tools/telemetry_auto/telemetry_auto/oobe_page.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698