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 import test
9 from telemetry.core import util
10 from telemetry.unittest import tab_test_case
13 class TabConsoleTest(tab_test_case.TabTestCase):
14 @test.Disabled('chromeos')
15 def testConsoleOutputStream(self):
16 self._browser.SetHTTPServerDirectories(util.GetUnittestDataDir())
18 stream = StringIO.StringIO()
19 self._tab.message_output_stream = stream
22 self._browser.http_server.UrlOf('page_that_logs_to_console.html'))
23 self._tab.WaitForDocumentReadyStateToBeComplete()
25 initial = self._tab.EvaluateJavaScript('window.__logCount')
27 current = self._tab.EvaluateJavaScript('window.__logCount')
28 return current > initial
29 util.WaitFor(GotLog, 5)
31 lines = [l for l in stream.getvalue().split('\n') if len(l)]
33 self.assertTrue(len(lines) >= 1)
35 prefix = 'http://(.+)/page_that_logs_to_console.html:9'
36 expected_line = 'At %s: Hello, world' % prefix
37 self.assertTrue(re.match(expected_line, line))