
from telemetry import benchmark
from telemetry.unittest import tab_test_case


class InspectorMemoryTest(tab_test_case.TabTestCase):

  @benchmark.Enabled('has tabs')
  def testGetDOMStats(self):
    # Due to an issue with CrOS, we create a new tab here rather than
    # using the existing tab to get a consistent starting page on all platforms.
    self._tab = self._browser.tabs.New()

    self.Navigate('dom_counter_sample.html')

    counts = self._tab.dom_stats
    self.assertEqual(counts['document_count'], 1)
    self.assertEqual(counts['node_count'], 14)
    self.assertEqual(counts['event_listener_count'], 2)


from telemetry import benchmark
from telemetry.unittest import tab_test_case


class InspectorMemoryTest(tab_test_case.TabTestCase):

  @benchmark.Enabled('has tabs')
  def testGetDOMStats(self):
    # Due to an issue with CrOS, we create a new tab here rather than
    # using the existing tab to get a consistent starting page on all platforms.
    self._tab = self._browser.tabs.New()

    self.Navigate('dom_counter_sample.html')

    # Document_count > 1 indicates that WebCore::Document loaded in Chrome
    # is leaking! The baseline should exactly match the numbers on:
    # unittest_data/dom_counter_sample.html
    # Please contact kouhei@, hajimehoshi@ when rebaselining.
    counts = self._tab.dom_stats
    self.assertEqual(counts['document_count'], 1,
        'Document leak is detected! '+
        'The previous document is likely retained unexpectedly.')
    self.assertEqual(counts['node_count'], 14,
        'Node leak is detected!')
    self.assertEqual(counts['event_listener_count'], 2,
        'EventListener leak is detected!')

Add warnings to inspector DOM count unittest baselines.
Add warnings to inspector DOM count unittest baselines.

The unit test failure indicates a serious Document leak, where all
WebCore::Document loaded in Chrome is leaking.
This CL adds warning comments to the baseline to avoid regressions.

BUG=392121
NOTRY=true

Review URL: https://codereview.chromium.org/393123003

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@284653 0039d316-1c4b-4281-b951-d872f2087c98

  
  from telemetry import benchmark
  from telemetry.unittest import tab_test_case
  
  
  class InspectorMemoryTest(tab_test_case.TabTestCase):
  
    @benchmark.Enabled('has tabs')
    def testGetDOMStats(self):
      # Due to an issue with CrOS, we create a new tab here rather than
      # using the existing tab to get a consistent starting page on all platforms.
      self._tab = self._browser.tabs.New()
  
      self.Navigate('dom_counter_sample.html')
  
+     # Document_count > 1 indicates that WebCore::Document loaded in Chrome
+     # is leaking! The baseline should exactly match the numbers on:
+     # unittest_data/dom_counter_sample.html
+     # Please contact kouhei@, hajimehoshi@ when rebaselining.
      counts = self._tab.dom_stats
-     self.assertEqual(counts['document_count'], 1)
+     self.assertEqual(counts['document_count'], 1,
+         'Document leak is detected! '+
+         'The previous document is likely retained unexpectedly.')
-     self.assertEqual(counts['node_count'], 14)
+     self.assertEqual(counts['node_count'], 14,
+         'Node leak is detected!')
-     self.assertEqual(counts['event_listener_count'], 2)
+     self.assertEqual(counts['event_listener_count'], 2,
+         'EventListener leak is detected!')
  
Add warnings to inspector DOM count unittest baselines.
## Code Before:

from telemetry import benchmark
from telemetry.unittest import tab_test_case


class InspectorMemoryTest(tab_test_case.TabTestCase):

  @benchmark.Enabled('has tabs')
  def testGetDOMStats(self):
    # Due to an issue with CrOS, we create a new tab here rather than
    # using the existing tab to get a consistent starting page on all platforms.
    self._tab = self._browser.tabs.New()

    self.Navigate('dom_counter_sample.html')

    counts = self._tab.dom_stats
    self.assertEqual(counts['document_count'], 1)
    self.assertEqual(counts['node_count'], 14)
    self.assertEqual(counts['event_listener_count'], 2)

## Instruction:
Add warnings to inspector DOM count unittest baselines.
## Code After:

from telemetry import benchmark
from telemetry.unittest import tab_test_case


class InspectorMemoryTest(tab_test_case.TabTestCase):

  @benchmark.Enabled('has tabs')
  def testGetDOMStats(self):
    # Due to an issue with CrOS, we create a new tab here rather than
    # using the existing tab to get a consistent starting page on all platforms.
    self._tab = self._browser.tabs.New()

    self.Navigate('dom_counter_sample.html')

    # Document_count > 1 indicates that WebCore::Document loaded in Chrome
    # is leaking! The baseline should exactly match the numbers on:
    # unittest_data/dom_counter_sample.html
    # Please contact kouhei@, hajimehoshi@ when rebaselining.
    counts = self._tab.dom_stats
    self.assertEqual(counts['document_count'], 1,
        'Document leak is detected! '+
        'The previous document is likely retained unexpectedly.')
    self.assertEqual(counts['node_count'], 14,
        'Node leak is detected!')
    self.assertEqual(counts['event_listener_count'], 2,
        'EventListener leak is detected!')
