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
3 # found in the LICENSE file.
5 from telemetry
.page
import page
as page_module
6 from telemetry
import story
9 class SwiffyPage(page_module
.Page
):
11 def __init__(self
, url
, page_set
):
12 super(SwiffyPage
, self
).__init
__(url
=url
, page_set
=page_set
,
13 make_javascript_deterministic
=False)
15 def RunNavigateSteps(self
, action_runner
):
16 super(SwiffyPage
, self
).RunNavigateSteps(action_runner
)
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.
19 action_runner
.EvaluateJavaScript(
20 'Function.prototype.toString = function() { return "[native code]"; }')
21 # Make sure we have a reasonable viewport for mobile.
23 'var meta = document.createElement("meta");'
24 'meta.name = "viewport";'
25 'meta.content = "width=device-width";'
26 'document.getElementsByTagName("head")[0].appendChild(meta);')
27 action_runner
.EvaluateJavaScript(viewport_js
)
29 def RunPageInteractions(self
, action_runner
):
30 with action_runner
.CreateInteraction('ToughAd'):
31 action_runner
.Wait(10)
34 class ToughAdCasesPageSet(story
.StorySet
):
35 """Pages for measuring performance with advertising content."""
38 super(ToughAdCasesPageSet
, self
).__init
__(
39 archive_data_file
='data/tough_ad_cases.json',
40 cloud_storage_bucket
=story
.INTERNAL_BUCKET
)
42 base_url
= 'http://localhost:8000'
44 # See go/swiffy-chrome-samples for how to add new pages here or how to
45 # update the existing ones.
47 'CICAgICQ15a9NxDIARjIASgBMghBC1XuTk8ezw.swiffy72.html',
48 'shapes-CK7ptO3F8bi2KxDQAhiYAigBMgij6QBQtD2gyA.swiffy72.html',
49 'CNP2xe_LmqPEKBCsAhj6ASgBMggnyMqth81h8Q.swiffy72.html',
50 'clip-paths-CICAgMDO7Ye9-gEQ2AUYWigBMgjZxDii6aoK9w.swiffy72.html',
51 'filters-CNLa0t2T47qJ_wEQoAEY2AQoATIIFaIdc7VMBr4.swiffy72.html',
52 'shapes-CICAgMDO7cfIzwEQ1AMYPCgBMghqY8tqyRCArQ.swiffy72.html',
53 'CICAgIDQ2Pb-MxCsAhj6ASgBMgi5DLoSO0gPbQ.swiffy72.html',
54 'CICAgKCN39CopQEQoAEY2AQoATIID59gK5hjjIg.swiffy72.html',
55 'CICAgKCNj4HgyAEQeBjYBCgBMgjQpPkOjyWNdw.1.swiffy72.html',
56 'clip-paths-CILZhLqO_-27bxB4GNgEKAEyCC46kMLBXnMT.swiffy72.html',
57 'CICAgMDOrcnRGRB4GNgEKAEyCP_ZBSfwUFsj.swiffy72.html',
59 for page_name
in swiffy_pages
:
60 url
= base_url
+ '/' + page_name
61 self
.AddStory(SwiffyPage(url
, self
))