OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
| 5 from telemetry import story |
5 from telemetry.page import page as page_module | 6 from telemetry.page import page as page_module |
6 from telemetry.page import page_set as page_set_module | |
7 | 7 |
8 | 8 |
9 class SwiffyPage(page_module.Page): | 9 class SwiffyPage(page_module.Page): |
10 | 10 |
11 def __init__(self, url, page_set): | 11 def __init__(self, url, page_set): |
12 super(SwiffyPage, self).__init__(url=url, page_set=page_set, | 12 super(SwiffyPage, self).__init__(url=url, page_set=page_set, |
13 make_javascript_deterministic=False) | 13 make_javascript_deterministic=False) |
14 | 14 |
15 def RunNavigateSteps(self, action_runner): | 15 def RunNavigateSteps(self, action_runner): |
16 super(SwiffyPage, self).RunNavigateSteps(action_runner) | 16 super(SwiffyPage, self).RunNavigateSteps(action_runner) |
17 # Swiffy overwrites toString() to return a constant string, so "undo" that | 17 # Swiffy overwrites toString() to return a constant string, so "undo" that |
18 # here so that we don't think it has stomped over console.time. | 18 # here so that we don't think it has stomped over console.time. |
19 action_runner.EvaluateJavaScript( | 19 action_runner.EvaluateJavaScript( |
20 'Function.prototype.toString = function() { return "[native code]"; }') | 20 'Function.prototype.toString = function() { return "[native code]"; }') |
21 # Make sure we have a reasonable viewport for mobile. | 21 # Make sure we have a reasonable viewport for mobile. |
22 viewport_js = ( | 22 viewport_js = ( |
23 'var meta = document.createElement("meta");' | 23 'var meta = document.createElement("meta");' |
24 'meta.name = "viewport";' | 24 'meta.name = "viewport";' |
25 'meta.content = "width=device-width";' | 25 'meta.content = "width=device-width";' |
26 'document.getElementsByTagName("head")[0].appendChild(meta);') | 26 'document.getElementsByTagName("head")[0].appendChild(meta);') |
27 action_runner.EvaluateJavaScript(viewport_js) | 27 action_runner.EvaluateJavaScript(viewport_js) |
28 | 28 |
29 def RunPageInteractions(self, action_runner): | 29 def RunPageInteractions(self, action_runner): |
30 with action_runner.CreateInteraction('ToughAd'): | 30 with action_runner.CreateInteraction('ToughAd'): |
31 action_runner.Wait(10) | 31 action_runner.Wait(10) |
32 | 32 |
33 | 33 |
34 class ToughAdCasesPageSet(page_set_module.PageSet): | 34 class ToughAdCasesPageSet(story.StorySet): |
35 """Pages for measuring performance with advertising content.""" | 35 """Pages for measuring performance with advertising content.""" |
36 | 36 |
37 def __init__(self): | 37 def __init__(self): |
38 super(ToughAdCasesPageSet, self).__init__( | 38 super(ToughAdCasesPageSet, self).__init__( |
39 archive_data_file='data/tough_ad_cases.json', | 39 archive_data_file='data/tough_ad_cases.json', |
40 bucket=page_set_module.INTERNAL_BUCKET) | 40 cloud_storage_bucket=story.INTERNAL_BUCKET) |
41 | 41 |
42 base_url = 'http://localhost:8000' | 42 base_url = 'http://localhost:8000' |
43 | 43 |
44 # See go/swiffy-chrome-samples for how to add new pages here or how to | 44 # See go/swiffy-chrome-samples for how to add new pages here or how to |
45 # update the existing ones. | 45 # update the existing ones. |
46 swiffy_pages = [ | 46 swiffy_pages = [ |
47 'CICAgICQ15a9NxDIARjIASgBMghBC1XuTk8ezw.swiffy72.html', | 47 'CICAgICQ15a9NxDIARjIASgBMghBC1XuTk8ezw.swiffy72.html', |
48 'shapes-CK7ptO3F8bi2KxDQAhiYAigBMgij6QBQtD2gyA.swiffy72.html', | 48 'shapes-CK7ptO3F8bi2KxDQAhiYAigBMgij6QBQtD2gyA.swiffy72.html', |
49 'CNP2xe_LmqPEKBCsAhj6ASgBMggnyMqth81h8Q.swiffy72.html', | 49 'CNP2xe_LmqPEKBCsAhj6ASgBMggnyMqth81h8Q.swiffy72.html', |
50 'clip-paths-CICAgMDO7Ye9-gEQ2AUYWigBMgjZxDii6aoK9w.swiffy72.html', | 50 'clip-paths-CICAgMDO7Ye9-gEQ2AUYWigBMgjZxDii6aoK9w.swiffy72.html', |
51 'filters-CNLa0t2T47qJ_wEQoAEY2AQoATIIFaIdc7VMBr4.swiffy72.html', | 51 'filters-CNLa0t2T47qJ_wEQoAEY2AQoATIIFaIdc7VMBr4.swiffy72.html', |
52 'shapes-CICAgMDO7cfIzwEQ1AMYPCgBMghqY8tqyRCArQ.swiffy72.html', | 52 'shapes-CICAgMDO7cfIzwEQ1AMYPCgBMghqY8tqyRCArQ.swiffy72.html', |
53 'CICAgIDQ2Pb-MxCsAhj6ASgBMgi5DLoSO0gPbQ.swiffy72.html', | 53 'CICAgIDQ2Pb-MxCsAhj6ASgBMgi5DLoSO0gPbQ.swiffy72.html', |
54 'CICAgKCN39CopQEQoAEY2AQoATIID59gK5hjjIg.swiffy72.html', | 54 'CICAgKCN39CopQEQoAEY2AQoATIID59gK5hjjIg.swiffy72.html', |
55 'CICAgKCNj4HgyAEQeBjYBCgBMgjQpPkOjyWNdw.1.swiffy72.html', | 55 'CICAgKCNj4HgyAEQeBjYBCgBMgjQpPkOjyWNdw.1.swiffy72.html', |
56 'clip-paths-CILZhLqO_-27bxB4GNgEKAEyCC46kMLBXnMT.swiffy72.html', | 56 'clip-paths-CILZhLqO_-27bxB4GNgEKAEyCC46kMLBXnMT.swiffy72.html', |
57 'CICAgMDOrcnRGRB4GNgEKAEyCP_ZBSfwUFsj.swiffy72.html', | 57 'CICAgMDOrcnRGRB4GNgEKAEyCP_ZBSfwUFsj.swiffy72.html', |
58 ] | 58 ] |
59 for page_name in swiffy_pages: | 59 for page_name in swiffy_pages: |
60 url = base_url + '/' + page_name | 60 url = base_url + '/' + page_name |
61 self.AddUserStory(SwiffyPage(url, self)) | 61 self.AddUserStory(SwiffyPage(url, self)) |
OLD | NEW |