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 5 from telemetry import decorators 6 from telemetry.testing import tab_test_case 7 8 9 class InspectorMemoryTest(tab_test_case.TabTestCase): 10 11 @decorators.Enabled('has tabs') 12 def testGetDOMStats(self): 13 # Due to an issue with CrOS, we create a new tab here rather than 14 # using the existing tab to get a consistent starting page on all platforms. 15 self._tab = self._browser.tabs.New() 16 17 self.Navigate('dom_counter_sample.html') 18 19 self._tab.ExecuteJavaScript('gc();') 20 21 # Document_count > 1 indicates that WebCore::Document loaded in Chrome 22 # is leaking! The baseline should exactly match the numbers on: 23 # internal/testing/dom_counter_sample.html 24 # Please contact kouhei@, hajimehoshi@ when rebaselining. 25 counts = self._tab.dom_stats 26 self.assertEqual(counts['document_count'], 1, 27 'Document leak is detected! '+ 28 'The previous document is likely retained unexpectedly.') 29 self.assertEqual(counts['node_count'], 14, 30 'Node leak is detected!') 31 self.assertEqual(counts['event_listener_count'], 2, 32 'EventListener leak is detected!') 33 34 @classmethod 35 def CustomizeBrowserOptions(cls, options): 36 options.AppendExtraBrowserArgs('--js-flags=--expose-gc') 37