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.
8 from telemetry.core import util
9 from telemetry.unittest import tab_test_case
12 class TabConsoleTest(tab_test_case.TabTestCase):
13 def testConsoleOutputStream(self):
14 stream = StringIO.StringIO()
15 self._tab.message_output_stream = stream
17 self.Navigate('page_that_logs_to_console.html')
19 initial = self._tab.EvaluateJavaScript('window.__logCount')
21 current = self._tab.EvaluateJavaScript('window.__logCount')
22 return current > initial
23 util.WaitFor(GotLog, 5)
25 lines = [l for l in stream.getvalue().split('\n') if len(l)]
27 self.assertTrue(len(lines) >= 1)
29 prefix = 'http://(.+)/page_that_logs_to_console.html:9'
30 expected_line = 'At %s: Hello, world' % prefix
31 self.assertTrue(re.match(expected_line, line))