diff options
author | chrishenry <chrishenry@google.com> | 2014-12-16 17:18:20 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-17 01:18:53 +0000 |
commit | 1ea2aacffca6ea3474085d6b61a470086665d2da (patch) | |
tree | a99203aea67bd123edc0fb8bd87d58c64a9abef4 | |
parent | 33044f54e20273dcaaaaaa195cd2787307ce407e (diff) | |
download | chromium_src-1ea2aacffca6ea3474085d6b61a470086665d2da.zip chromium_src-1ea2aacffca6ea3474085d6b61a470086665d2da.tar.gz chromium_src-1ea2aacffca6ea3474085d6b61a470086665d2da.tar.bz2 |
Move make_javascript_deterministic to UserStory.
BUG=439512,439700
Review URL: https://codereview.chromium.org/806513002
Cr-Commit-Position: refs/heads/master@{#308707}
19 files changed, 73 insertions, 52 deletions
diff --git a/content/test/gpu/gpu_tests/maps.py b/content/test/gpu/gpu_tests/maps.py index bf0257e..27a741d 100644 --- a/content/test/gpu/gpu_tests/maps.py +++ b/content/test/gpu/gpu_tests/maps.py @@ -74,10 +74,11 @@ class _MapsValidator(cloud_storage_test_base.ValidatorBase): class MapsPage(page.Page): def __init__(self, page_set, base_dir): super(MapsPage, self).__init__( - url='http://localhost:10020/tracker.html', - page_set=page_set, - base_dir=base_dir, - name='Maps.maps_002') + url='http://localhost:10020/tracker.html', + page_set=page_set, + base_dir=base_dir, + name='Maps.maps_002', + make_javascript_deterministic=False) self.pixel_expectations = 'data/maps_002_expectations.json' def RunNavigateSteps(self, action_runner): @@ -97,7 +98,6 @@ class Maps(cloud_storage_test_base.TestBase): page_set_path = os.path.join( util.GetChromiumSrcDir(), 'content', 'test', 'gpu', 'page_sets') ps = page_set.PageSet(archive_data_file='data/maps.json', - make_javascript_deterministic=False, file_path=page_set_path, bucket=page_set.PUBLIC_BUCKET) ps.AddUserStory(MapsPage(ps, ps.base_dir)) diff --git a/tools/perf/benchmarks/dromaeo.py b/tools/perf/benchmarks/dromaeo.py index 0ee1ffd..c5e00c4 100644 --- a/tools/perf/benchmarks/dromaeo.py +++ b/tools/perf/benchmarks/dromaeo.py @@ -105,11 +105,11 @@ class _DromaeoBenchmark(benchmark.Benchmark): raise NotImplementedError('query_param or tag not in Dromaeo benchmark.') archive_data_file = '../page_sets/data/dromaeo.%s.json' % self.tag ps = page_set.PageSet( - make_javascript_deterministic=False, archive_data_file=archive_data_file, file_path=os.path.abspath(__file__), bucket=page_set.PUBLIC_BUCKET) url = 'http://dromaeo.com?%s' % self.query_param - ps.AddUserStory(page_module.Page(url, ps, ps.base_dir)) + ps.AddUserStory(page_module.Page( + url, ps, ps.base_dir, make_javascript_deterministic=False)) return ps diff --git a/tools/perf/benchmarks/jetstream.py b/tools/perf/benchmarks/jetstream.py index 2b169c7..fffa23a 100644 --- a/tools/perf/benchmarks/jetstream.py +++ b/tools/perf/benchmarks/jetstream.py @@ -83,9 +83,9 @@ class Jetstream(benchmark.Benchmark): def CreatePageSet(self, options): ps = page_set.PageSet( archive_data_file='../page_sets/data/jetstream.json', - make_javascript_deterministic=False, file_path=os.path.abspath(__file__), bucket=page_set.INTERNAL_BUCKET) ps.AddUserStory(page_module.Page( - 'http://browserbench.org/JetStream/', ps, ps.base_dir)) + 'http://browserbench.org/JetStream/', ps, ps.base_dir, + make_javascript_deterministic=False)) return ps diff --git a/tools/perf/benchmarks/maps.py b/tools/perf/benchmarks/maps.py index c21ef54..85f8053 100644 --- a/tools/perf/benchmarks/maps.py +++ b/tools/perf/benchmarks/maps.py @@ -31,9 +31,10 @@ class _MapsMeasurement(page_test.PageTest): class MapsPage(page_module.Page): def __init__(self, page_set, base_dir): super(MapsPage, self).__init__( - url='http://localhost:10020/tracker.html', - page_set=page_set, - base_dir=base_dir) + url='http://localhost:10020/tracker.html', + page_set=page_set, + base_dir=base_dir, + make_javascript_deterministic=False) def RunNavigateSteps(self, action_runner): action_runner.NavigateToPage(self) @@ -49,9 +50,8 @@ class MapsBenchmark(benchmark.Benchmark): page_set_path = os.path.join( util.GetChromiumSrcDir(), 'tools', 'perf', 'page_sets') ps = page_set_module.PageSet( - archive_data_file='data/maps.json', - make_javascript_deterministic=False, - file_path=page_set_path) + archive_data_file='data/maps.json', + file_path=page_set_path) ps.AddUserStory(MapsPage(ps, ps.base_dir)) return ps diff --git a/tools/perf/benchmarks/octane.py b/tools/perf/benchmarks/octane.py index 1c1e4c1..be50c62 100644 --- a/tools/perf/benchmarks/octane.py +++ b/tools/perf/benchmarks/octane.py @@ -136,10 +136,9 @@ class Octane(benchmark.Benchmark): def CreatePageSet(self, options): ps = page_set.PageSet( archive_data_file='../page_sets/data/octane.json', - make_javascript_deterministic=False, file_path=os.path.abspath(__file__), bucket=page_set.PUBLIC_BUCKET) ps.AddUserStory(page_module.Page( 'http://octane-benchmark.googlecode.com/svn/latest/index.html?auto=1', - ps, ps.base_dir)) + ps, ps.base_dir, make_javascript_deterministic=False)) return ps diff --git a/tools/perf/benchmarks/robohornet_pro.py b/tools/perf/benchmarks/robohornet_pro.py index 8e875a7..d36da24 100644 --- a/tools/perf/benchmarks/robohornet_pro.py +++ b/tools/perf/benchmarks/robohornet_pro.py @@ -51,12 +51,12 @@ class RobohornetPro(benchmark.Benchmark): def CreatePageSet(self, options): ps = page_set.PageSet( - archive_data_file='../page_sets/data/robohornet_pro.json', - # Measurement require use of real Date.now() for measurement. - make_javascript_deterministic=False, - file_path=os.path.abspath(__file__), - bucket=page_set.PARTNER_BUCKET) + archive_data_file='../page_sets/data/robohornet_pro.json', + file_path=os.path.abspath(__file__), + bucket=page_set.PARTNER_BUCKET) ps.AddUserStory(page_module.Page( 'http://ie.microsoft.com/testdrive/performance/robohornetpro/', - ps, ps.base_dir)) + ps, ps.base_dir, + # Measurement require use of real Date.now() for measurement. + make_javascript_deterministic=False)) return ps diff --git a/tools/perf/benchmarks/speedometer.py b/tools/perf/benchmarks/speedometer.py index bc36053..96ca66b 100644 --- a/tools/perf/benchmarks/speedometer.py +++ b/tools/perf/benchmarks/speedometer.py @@ -80,8 +80,8 @@ class Speedometer(benchmark.Benchmark): ps = page_set.PageSet( file_path=os.path.abspath(__file__), archive_data_file='../page_sets/data/speedometer.json', - make_javascript_deterministic=False, bucket=page_set.PUBLIC_BUCKET) ps.AddUserStory(page_module.Page( - 'http://browserbench.org/Speedometer/', ps, ps.base_dir)) + 'http://browserbench.org/Speedometer/', ps, ps.base_dir, + make_javascript_deterministic=False)) return ps diff --git a/tools/perf/benchmarks/sunspider.py b/tools/perf/benchmarks/sunspider.py index 63f56c3..eb212bd 100644 --- a/tools/perf/benchmarks/sunspider.py +++ b/tools/perf/benchmarks/sunspider.py @@ -131,8 +131,8 @@ class Sunspider(benchmark.Benchmark): def CreatePageSet(self, options): ps = page_set.PageSet( archive_data_file='../page_sets/data/sunspider.json', - make_javascript_deterministic=False, file_path=os.path.abspath(__file__), bucket=page_set.PARTNER_BUCKET) - ps.AddUserStory(page_module.Page(_URL, ps, ps.base_dir)) + ps.AddUserStory(page_module.Page( + _URL, ps, ps.base_dir, make_javascript_deterministic=False)) return ps diff --git a/tools/perf/page_sets/alexa1-10000.py b/tools/perf/page_sets/alexa1-10000.py index 094e705..e002478 100644 --- a/tools/perf/page_sets/alexa1-10000.py +++ b/tools/perf/page_sets/alexa1-10000.py @@ -9,7 +9,6 @@ class Alexa1To10000Page(Page): def __init__(self, url, page_set): super(Alexa1To10000Page, self).__init__(url=url, page_set=page_set) - self.make_javascript_deterministic = True def RunSmoothness(self, action_runner): interaction = action_runner.BeginGestureInteraction( @@ -25,9 +24,7 @@ class Alexa1To10000PageSet(PageSet): """ def __init__(self): - super(Alexa1To10000PageSet, self).__init__( - make_javascript_deterministic=True, - user_agent_type='desktop') + super(Alexa1To10000PageSet, self).__init__(user_agent_type='desktop') urls_list = [ # Why: #1 in Alexa global diff --git a/tools/perf/page_sets/service_worker.py b/tools/perf/page_sets/service_worker.py index 2ac1c6b..6816a7d 100644 --- a/tools/perf/page_sets/service_worker.py +++ b/tools/perf/page_sets/service_worker.py @@ -15,16 +15,18 @@ class ServiceWorkerPageSet(page_set.PageSet): def __init__(self): super(ServiceWorkerPageSet, self).__init__( archive_data_file=archive_data_file_path, - make_javascript_deterministic=False, bucket=page_set.PARTNER_BUCKET) # Why: the first application using ServiceWorker # 1st time: registration self.AddUserStory(page.Page( - 'https://jakearchibald.github.io/trained-to-thrill/', self)) + 'https://jakearchibald.github.io/trained-to-thrill/', self, + make_javascript_deterministic=False)) # 2st time: 1st onfetch with caching self.AddUserStory(page.Page( - 'https://jakearchibald.github.io/trained-to-thrill/', self)) + 'https://jakearchibald.github.io/trained-to-thrill/', self, + make_javascript_deterministic=False)) # 3rd time: 2nd onfetch from cache self.AddUserStory(page.Page( - 'https://jakearchibald.github.io/trained-to-thrill/', self)) + 'https://jakearchibald.github.io/trained-to-thrill/', self, + make_javascript_deterministic=False)) diff --git a/tools/perf/page_sets/service_worker_micro_benchmark.py b/tools/perf/page_sets/service_worker_micro_benchmark.py index 6523aad..24ac8d2 100644 --- a/tools/perf/page_sets/service_worker_micro_benchmark.py +++ b/tools/perf/page_sets/service_worker_micro_benchmark.py @@ -23,7 +23,6 @@ class ServiceWorkerMicroBenchmarkPageSet(page_set.PageSet): def __init__(self): super(ServiceWorkerMicroBenchmarkPageSet, self).__init__( archive_data_file=archive_data_file_path, - make_javascript_deterministic=False, bucket=page_set.PUBLIC_BUCKET) # pylint: disable=C0301 @@ -36,4 +35,5 @@ class ServiceWorkerMicroBenchmarkPageSet(page_set.PageSet): # pylint: enable=C0301 # Why: to measure performance of many concurrent fetches self.AddUserStory(ServiceWorkerBenchmarkPage( - 'http://localhost:8091/index.html', self)) + 'http://localhost:8091/index.html', self, + make_javascript_deterministic=False)) diff --git a/tools/perf/page_sets/top_desktop_sites_2012Q3.py b/tools/perf/page_sets/top_desktop_sites_2012Q3.py index 5d26058..94f1d48 100644 --- a/tools/perf/page_sets/top_desktop_sites_2012Q3.py +++ b/tools/perf/page_sets/top_desktop_sites_2012Q3.py @@ -252,7 +252,6 @@ class Top2012Q3Page(page.Page): def __init__(self, url, ps): super(Top2012Q3Page, self).__init__( url=url, page_set=ps, credentials_path = 'data/credentials.json') - self.make_javascript_deterministic = True self.archive_data_file = 'data/2012Q3.json' def RunSmoothness(self, action_runner): @@ -267,7 +266,6 @@ class Top2012Q3PageSet(page_set.PageSet): def __init__(self): super(Top2012Q3PageSet, self).__init__( - make_javascript_deterministic=True, archive_data_file='data/2012Q3.json', bucket=page_set.PARTNER_BUCKET) diff --git a/tools/perf/page_sets/top_desktop_sites_2012Q3_stress.py b/tools/perf/page_sets/top_desktop_sites_2012Q3_stress.py index bc1d9ce3..b94fca8 100644 --- a/tools/perf/page_sets/top_desktop_sites_2012Q3_stress.py +++ b/tools/perf/page_sets/top_desktop_sites_2012Q3_stress.py @@ -13,7 +13,6 @@ class Top2012Q3StressPage(page.Page): def __init__(self, url, ps): super(Top2012Q3StressPage, self).__init__( url=url, page_set=ps, credentials_path='data/credentials.json') - self.make_javascript_deterministic = True self.archive_data_file = 'data/2012Q3.json' def RunPageInteractions(self, action_runner): @@ -28,7 +27,6 @@ class Top2012Q3StressPageSet(page_set.PageSet): def __init__(self): super(Top2012Q3StressPageSet, self).__init__( - make_javascript_deterministic=True, archive_data_file='data/2012Q3.json', bucket=page_set.PARTNER_BUCKET) diff --git a/tools/telemetry/telemetry/page/__init__.py b/tools/telemetry/telemetry/page/__init__.py index f8ff788..34a41d4 100644 --- a/tools/telemetry/telemetry/page/__init__.py +++ b/tools/telemetry/telemetry/page/__init__.py @@ -24,12 +24,14 @@ def _UpdateCredentials(credentials_path): class Page(user_story.UserStory): def __init__(self, url, page_set=None, base_dir=None, name='', - credentials_path=None, labels=None, startup_url=''): + credentials_path=None, labels=None, startup_url='', + make_javascript_deterministic=True): self._url = url super(Page, self).__init__( shared_page_state.SharedPageState, name=name, labels=labels, - is_local=self._scheme in ['file', 'chrome', 'about']) + is_local=self._scheme in ['file', 'chrome', 'about'], + make_javascript_deterministic=make_javascript_deterministic) self._page_set = page_set # Default value of base_dir is the directory of the file that defines the diff --git a/tools/telemetry/telemetry/page/page_set.py b/tools/telemetry/telemetry/page/page_set.py index 7a7f0e0..a4ddc1e 100644 --- a/tools/telemetry/telemetry/page/page_set.py +++ b/tools/telemetry/telemetry/page/page_set.py @@ -21,8 +21,7 @@ class PageSetError(Exception): class PageSet(user_story_set.UserStorySet): def __init__(self, file_path=None, archive_data_file='', user_agent_type=None, - make_javascript_deterministic=True, serving_dirs=None, - bucket=None): + serving_dirs=None, bucket=None): # The default value of file_path is location of the file that define this # page set instance's class. # TODO(chrishenry): Move this logic to user_story_set. Consider passing @@ -41,7 +40,6 @@ class PageSet(user_story_set.UserStorySet): # These attributes can be set dynamically by the page set. self.user_agent_type = user_agent_type - self.make_javascript_deterministic = make_javascript_deterministic @property def pages(self): diff --git a/tools/telemetry/telemetry/page/shared_page_state.py b/tools/telemetry/telemetry/page/shared_page_state.py index eacb9e6..1c4644a 100644 --- a/tools/telemetry/telemetry/page/shared_page_state.py +++ b/tools/telemetry/telemetry/page/shared_page_state.py @@ -113,7 +113,7 @@ class SharedPageState(shared_user_story_state.SharedUserStoryState): started_browser = not self.browser self._PrepareWpr(self.platform.network_controller, page_set.WprFilePathForUserStory(page), - page_set.make_javascript_deterministic) + page.make_javascript_deterministic) if self.browser: # Set new credential path for browser. self.browser.credentials.credentials_path = page.credentials_path diff --git a/tools/telemetry/telemetry/unittest_util/page_set_smoke_test.py b/tools/telemetry/telemetry/unittest_util/page_set_smoke_test.py index 7462a28..c25911e 100644 --- a/tools/telemetry/telemetry/unittest_util/page_set_smoke_test.py +++ b/tools/telemetry/telemetry/unittest_util/page_set_smoke_test.py @@ -100,10 +100,6 @@ class PageSetSmokeTest(unittest.TestCase): isinstance(page_set.user_agent_type, str), msg='page_set\'s user_agent_type must have type string') - self.assertTrue( - isinstance(page_set.make_javascript_deterministic, bool), - msg='page_set\'s make_javascript_deterministic must have type bool') - def CheckAttributesOfPageBasicAttributes(self, page): self.assertTrue(not hasattr(page, 'disabled')) self.assertTrue( @@ -123,6 +119,10 @@ class PageSetSmokeTest(unittest.TestCase): isinstance(page.startup_url, str), msg=('page %s \'s startup_url field must have type string' % page.display_name)) + self.assertIsInstance( + page.make_javascript_deterministic, bool, + msg='page %s \'s make_javascript_deterministic must have type bool' + % page.display_name) for l in page.labels: self.assertTrue( isinstance(l, str), diff --git a/tools/telemetry/telemetry/user_story/__init__.py b/tools/telemetry/telemetry/user_story/__init__.py index 68d9b56..4b03f43 100644 --- a/tools/telemetry/telemetry/user_story/__init__.py +++ b/tools/telemetry/telemetry/user_story/__init__.py @@ -27,7 +27,17 @@ class UserStory(object): """ def __init__(self, shared_user_story_state_class, name='', labels=None, - is_local=False): + is_local=False, make_javascript_deterministic=True): + """ + Args: + make_javascript_deterministic: Whether JavaScript performed on + the page is made deterministic across multiple runs. This + requires that the web content is served via Web Page Replay + to take effect. Does not affect user story containing no web + contents or where there is the HTTP response mime type is + not text/html. See also: _InjectScripts method in + third_party/webpagereplay/httpclient.py. + """ assert issubclass(shared_user_story_state_class, shared_user_story_state.SharedUserStoryState) self._shared_user_story_state_class = shared_user_story_state_class @@ -43,6 +53,7 @@ class UserStory(object): assert isinstance(labels, set) self._labels = labels self._is_local = is_local + self._make_javascript_deterministic = make_javascript_deterministic @property def labels(self): @@ -86,3 +97,7 @@ class UserStory(object): def is_local(self): """Returns True iff this user story does not require network.""" return self._is_local + + @property + def make_javascript_deterministic(self): + return self._make_javascript_deterministic diff --git a/tools/telemetry/telemetry/user_story/user_story_unittest.py b/tools/telemetry/telemetry/user_story/user_story_unittest.py index 46ae6ff..8e60310 100644 --- a/tools/telemetry/telemetry/user_story/user_story_unittest.py +++ b/tools/telemetry/telemetry/user_story/user_story_unittest.py @@ -48,3 +48,15 @@ class UserStoryTest(unittest.TestCase): u_dict = u.AsDict() self.assertEquals(u_dict['id'], u.id) self.assertEquals('Foo', u_dict['name']) + + def testMakeJavaScriptDeterministic(self): + u = user_story.UserStory(SharedUserStoryStateBar) + self.assertTrue(u.make_javascript_deterministic) + + u = user_story.UserStory( + SharedUserStoryStateBar, make_javascript_deterministic=False) + self.assertFalse(u.make_javascript_deterministic) + + u = user_story.UserStory( + SharedUserStoryStateBar, make_javascript_deterministic=True) + self.assertTrue(u.make_javascript_deterministic) |