Commit 49d43234 authored by tonyg@chromium.org's avatar tonyg@chromium.org

[Telemetry] Improve unittest cycle time and fix testIFrame.

Starting chrome to about:blank instead of the NTP improves telemetry_unittests
cycle time by ~14% (172s -> 148s) on my MBP.

This required a couple of test updates:
1. It made testIFrame fail deterministically which exposed the source of
flake. The context_id isn't the current index, it is just a monotonically
increasing ID. So it depends on the number of contexts used previously.
2. It made the GPU memory test measure a larger delta (presumably due to the simpler previous page).

BUG=394454,388256

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

Cr-Commit-Position: refs/heads/master@{#289423}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289423 0039d316-1c4b-4281-b951-d872f2087c98
parent 433d3657
...@@ -11,7 +11,7 @@ from telemetry.timeline import model ...@@ -11,7 +11,7 @@ from telemetry.timeline import model
MEMORY_LIMIT_MB = 192 MEMORY_LIMIT_MB = 192
SINGLE_TAB_LIMIT_MB = 192 SINGLE_TAB_LIMIT_MB = 192
WIGGLE_ROOM_MB = 8 WIGGLE_ROOM_MB = 12
test_harness_script = r""" test_harness_script = r"""
var domAutomationController = {}; var domAutomationController = {};
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
from telemetry import decorators
from telemetry.core import exceptions from telemetry.core import exceptions
from telemetry.core import util from telemetry.core import util
from telemetry.unittest import tab_test_case from telemetry.unittest import tab_test_case
...@@ -34,15 +33,19 @@ class InspectorRuntimeTest(tab_test_case.TabTestCase): ...@@ -34,15 +33,19 @@ class InspectorRuntimeTest(tab_test_case.TabTestCase):
def testRuntimeExecuteOfSomethingThatCantJSONize(self): def testRuntimeExecuteOfSomethingThatCantJSONize(self):
self._tab.ExecuteJavaScript('window') self._tab.ExecuteJavaScript('window')
# TODO(achuith): Fix http://crbug.com/394454 on cros.
@decorators.Disabled('android', 'chromeos', 'win')
def testIFrame(self): def testIFrame(self):
starting_contexts = self._tab.EnableAllContexts()
self.Navigate('host.html') self.Navigate('host.html')
# Access host page. # Access host page.
test_defined_js = "typeof(testVar) != 'undefined'" test_defined_js = "typeof(testVar) != 'undefined'"
self._tab.WaitForJavaScriptExpression(test_defined_js, timeout=30) self._tab.WaitForJavaScriptExpression(test_defined_js, timeout=10)
util.WaitFor(lambda: self._tab.EnableAllContexts() == 4, timeout=30)
expected_contexts = 4 + starting_contexts
util.WaitFor(lambda: self._tab.EnableAllContexts() == expected_contexts,
timeout=10)
self.assertEquals(self._tab.EvaluateJavaScript('testVar'), 'host') self.assertEquals(self._tab.EvaluateJavaScript('testVar'), 'host')
...@@ -58,17 +61,20 @@ class InspectorRuntimeTest(tab_test_case.TabTestCase): ...@@ -58,17 +61,20 @@ class InspectorRuntimeTest(tab_test_case.TabTestCase):
def TestVar(context_id): def TestVar(context_id):
"""Waits for testVar and the context to be ready, then returns the value """Waits for testVar and the context to be ready, then returns the value
of testVar.""" of testVar."""
util.WaitFor(lambda: TestVarReady(context_id), timeout=30) util.WaitFor(lambda: TestVarReady(context_id), timeout=10)
return self._tab.EvaluateJavaScriptInContext('testVar', context_id) return self._tab.EvaluateJavaScriptInContext('testVar', context_id)
# Access parent page using EvaluateJavaScriptInContext. # Access parent page using EvaluateJavaScriptInContext.
self.assertEquals(TestVar(context_id=1), 'host') self.assertEquals(TestVar(context_id=starting_contexts+1), 'host')
# Access the iframes. # Access the iframes.
self.assertEquals(TestVar(context_id=2), 'iframe1') self.assertEquals(TestVar(context_id=starting_contexts+2), 'iframe1')
self.assertTrue(TestVar(context_id=3) in ['iframe2', 'iframe3']) self.assertTrue(TestVar(context_id=starting_contexts+3) in ['iframe2',
self.assertTrue(TestVar(context_id=4) in ['iframe2', 'iframe3']) 'iframe3'])
self.assertTrue(TestVar(context_id=starting_contexts+4) in ['iframe2',
'iframe3'])
# Accessing a non-existent iframe throws an exception. # Accessing a non-existent iframe throws an exception.
self.assertRaises(exceptions.EvaluateException, self.assertRaises(exceptions.EvaluateException,
lambda: self._tab.EvaluateJavaScriptInContext('1+1', context_id=5)) lambda: self._tab.EvaluateJavaScriptInContext(
'1+1', context_id=starting_contexts+5))
...@@ -195,7 +195,7 @@ class BrowserOptions(object): ...@@ -195,7 +195,7 @@ class BrowserOptions(object):
self.browser_user_agent_type = None self.browser_user_agent_type = None
self.clear_sytem_cache_for_browser_and_profile_on_start = False self.clear_sytem_cache_for_browser_and_profile_on_start = False
self.startup_url = None self.startup_url = 'about:blank'
# Background pages of built-in component extensions can interfere with # Background pages of built-in component extensions can interfere with
# performance measurements. # performance measurements.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment