- add sources.
[platform/framework/web/crosswalk.git] / src / tools / telemetry / telemetry / core / backends / chrome / inspector_runtime_unittest.py
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.
4 from telemetry.core import exceptions
5 from telemetry.unittest import tab_test_case
6
7 class InspectorRuntimeTest(tab_test_case.TabTestCase):
8   def testRuntimeEvaluateSimple(self):
9     res = self._tab.EvaluateJavaScript('1+1')
10     assert res == 2
11
12   def testRuntimeEvaluateThatFails(self):
13     self.assertRaises(exceptions.EvaluateException,
14                       lambda: self._tab.EvaluateJavaScript('fsdfsdfsf'))
15
16   def testRuntimeEvaluateOfSomethingThatCantJSONize(self):
17
18     def test():
19       self._tab.EvaluateJavaScript("""
20         var cur = {};
21         var root = {next: cur};
22         for (var i = 0; i < 1000; i++) {
23           next = {};
24           cur.next = next;
25           cur = next;
26         }
27         root;""")
28     self.assertRaises(exceptions.EvaluateException, test)
29
30   def testRuntimeExecuteOfSomethingThatCantJSONize(self):
31     self._tab.ExecuteJavaScript('window')