old_contents: # Copyright (c) 2013 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.
  import os
  
  from telemetry.test import tab_test_case
  
  class InspectorMemoryTest(tab_test_case.TabTestCase):
    def testGetDOMStats(self):
      unittest_data_dir = os.path.join(os.path.dirname(__file__),
                                       '..', '..', '..', 'unittest_data')
      self._browser.SetHTTPServerDirectories(unittest_data_dir)
  
      self._tab.Navigate(
        self._browser.http_server.UrlOf('dom_counter_sample.html'))
      self._tab.WaitForDocumentReadyStateToBeComplete()
  
      counts = self._tab.dom_stats
      self.assertEqual(counts['document_count'], 1)
      self.assertEqual(counts['node_count'], 14)
      self.assertEqual(counts['event_listener_count'], 2)
  
new_contents: # Copyright (c) 2013 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.
  import os
  
  from telemetry.test import tab_test_case
  
  class InspectorMemoryTest(tab_test_case.TabTestCase):
    def testGetDOMStats(self):
      unittest_data_dir = os.path.join(os.path.dirname(__file__),
                                       '..', '..', '..', 'unittest_data')
      self._browser.SetHTTPServerDirectories(unittest_data_dir)
  
      # Due to an issue with CrOS, we create a new tab here rather than
      # using self._tab to get a consistent starting page on all platforms
      tab = self._browser.tabs.New()
  
      tab.Navigate(
        self._browser.http_server.UrlOf('dom_counter_sample.html'))
      tab.WaitForDocumentReadyStateToBeComplete()
  
      counts = tab.dom_stats
      self.assertEqual(counts['document_count'], 2)
      self.assertEqual(counts['node_count'], 18)
      self.assertEqual(counts['event_listener_count'], 2)
  
subject: Fix InspectorMemoryTest.testGetDOMStats to have consistent behaviour on CrOS and desktop versions of Chrome. Starting the browser in CrOS requires navigating through an initial setup that does not leave us with a tab at "chrome://newtab". This workaround runs the test in a new tab on all platforms for consistency.