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

Unified Diff: tools/chrome_remote_control/chrome_remote_control/tab_runtime.py

Issue 10875044: Basic framework for devtools-based scrolling tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: with the added files Created 8 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: tools/chrome_remote_control/chrome_remote_control/tab_runtime.py
diff --git a/tools/chrome_remote_control/chrome_remote_control/tab_runtime.py b/tools/chrome_remote_control/chrome_remote_control/tab_runtime.py
new file mode 100644
index 0000000000000000000000000000000000000000..c78b123d1cf41d55a4ae38a786edb0c84798b176
--- /dev/null
+++ b/tools/chrome_remote_control/chrome_remote_control/tab_runtime.py
@@ -0,0 +1,41 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+class EvaluateException(Exception):
+ pass
+
+class TabRuntime(object):
+ def __init__(self, inspector_backend):
+ self._inspector_backend = inspector_backend
+ self._inspector_backend.RegisterDomain(
+ 'Runtime',
+ self._OnNotification,
+ self._OnClose)
+
+ def _OnNotification(self, msg):
+ pass
+
+ def _OnClose(self):
+ pass
+
+ def Evaluate(self, expr):
+ request = {
+ "method": "Runtime.evaluate",
+ "params": {
+ "expression": expr,
+ "returnByValue": True
+ }
+ }
+ res = self._inspector_backend.SyncRequest(request)
+ if "error" in res:
+ raise EvaluateException(res["error"]["message"])
+
+ if res["result"]["wasThrown"]:
+ # TODO(nduca): propagate stacks from javascript up to the python
+ # exception.
+ raise EvaluateException(res["result"]["result"]["description"])
+ if res["result"]["result"]["type"] == 'undefined':
+ return None
+ return res["result"]["result"]["value"]
+

Powered by Google App Engine
This is Rietveld 408576698