Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: tools/perf/page_sets/system_health/browsing_stories.py

Issue 2890283002: Migrate infinite scrolls to system health stories (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/perf/page_sets/data/system_health_mobile.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # encoding: utf-8 1 # encoding: utf-8
2 # Copyright 2016 The Chromium Authors. All rights reserved. 2 # Copyright 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 from page_sets.system_health import platforms 6 from page_sets.system_health import platforms
7 from page_sets.system_health import story_tags 7 from page_sets.system_health import story_tags
8 from page_sets.system_health import system_health_story 8 from page_sets.system_health import system_health_story
9 9
10 from page_sets.login_helpers import facebook_login
10 from page_sets.login_helpers import pinterest_login 11 from page_sets.login_helpers import pinterest_login
11 12
12 from telemetry import decorators 13 from telemetry import decorators
13 from telemetry.util import js_template 14 from telemetry.util import js_template
14 15
15 16
16 class _BrowsingStory(system_health_story.SystemHealthStory): 17 class _BrowsingStory(system_health_story.SystemHealthStory):
17 """Abstract base class for browsing stories. 18 """Abstract base class for browsing stories.
18 19
19 A browsing story visits items on the main page. Subclasses provide 20 A browsing story visits items on the main page. Subclasses provide
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 # Reduce the speed (the current wpr is recorded with speed set to 50) when 764 # Reduce the speed (the current wpr is recorded with speed set to 50) when
764 # recording the wpr. If we scroll too fast, the data will not be recorded 765 # recording the wpr. If we scroll too fast, the data will not be recorded
765 # well. After recording reset it back to the original value to have a more 766 # well. After recording reset it back to the original value to have a more
766 # realistic scroll. 767 # realistic scroll.
767 action_runner.RepeatableBrowserDrivenScroll( 768 action_runner.RepeatableBrowserDrivenScroll(
768 x_scroll_distance_ratio = 0.0, y_scroll_distance_ratio = 1, 769 x_scroll_distance_ratio = 0.0, y_scroll_distance_ratio = 1,
769 repeat_count=3, speed=400, timeout=120) 770 repeat_count=3, speed=400, timeout=120)
770 action_runner.RepeatableBrowserDrivenScroll( 771 action_runner.RepeatableBrowserDrivenScroll(
771 x_scroll_distance_ratio = 1, y_scroll_distance_ratio = 0, 772 x_scroll_distance_ratio = 1, y_scroll_distance_ratio = 0,
772 repeat_count=3, speed=500, timeout=120) 773 repeat_count=3, speed=500, timeout=120)
774
775
776 ##############################################################################
777 # Browsing stories with infinite scrolling
778 ##############################################################################
779
780
781 class _InfiniteScrollStory(system_health_story.SystemHealthStory):
782 SUPPORTED_PLATFORMS = platforms.ALL_PLATFORMS
783
784 SCROLL_DISTANCE = 25000
785 SCROLL_STEP = 1000
786 MAX_SCROLL_RETRIES = 3
787 TIME_BEFORE_SCROLL_RETRY_IN_SECONDS = 1
788 TIME_TO_WAIT_BEFORE_STARTING_IN_SECONDS = 5
789
790 def __init__(self, story_set, take_memory_measurement):
791 super(_InfiniteScrollStory, self).__init__(story_set,
792 take_memory_measurement)
793 self.script_to_evaluate_on_commit = '''
794 window.WebSocket = undefined;
795 window.Worker = undefined;
796 window.performance = undefined;'''
797
798 def RunPageInteractions(self, action_runner):
perezju 2017/05/19 09:40:35 I don't thing we should override this method. Cou
nednguyen 2017/05/24 21:08:49 Oh, it's just me copy & paste the stories from v8
799 with action_runner.CreateInteraction('Load'):
perezju 2017/05/19 09:40:36 Do we still want to create all of these interactio
nednguyen 2017/05/24 21:08:49 Nope.
800 action_runner.WaitForJavaScriptCondition(
801 'document.body != null && '
802 'document.body.scrollHeight > window.innerHeight && '
803 '!document.body.addEventListener("touchstart", function() {})')
804 with action_runner.CreateInteraction('Wait'):
805 action_runner.Wait(self.TIME_TO_WAIT_BEFORE_STARTING_IN_SECONDS)
806 with action_runner.CreateInteraction('GC'):
807 action_runner.ForceGarbageCollection()
808 with action_runner.CreateInteraction('Begin'):
809 action_runner.tab.browser.DumpMemory()
810 with action_runner.CreateInteraction('Scrolling'):
811 self._Scroll(action_runner, self.SCROLL_DISTANCE, self.SCROLL_STEP)
812 with action_runner.CreateInteraction('End'):
813 action_runner.tab.browser.DumpMemory()
814
815 def _Scroll(self, action_runner, distance, step_size):
perezju 2017/05/19 09:40:35 Could we use some of the Scroll methods in action_
hjd 2017/05/19 10:42:21 This does use action_runner.ScrollPage underneath
816 """ This function scrolls the webpage by the given scroll distance in
817 multiple steps, where each step (except the last one) has the given size.
818
819 If scrolling gets stuck, the functions retries scrolling MAX_SCROLL_RETRIES
820 times waiting TIME_BEFORE_SCROLL_RETRY_IN_SECONDS seconds between retries.
821 """
822 remaining = distance - action_runner.EvaluateJavaScript('window.scrollY')
hjd 2017/05/19 10:42:21 I think scrollY can be overwritten in JavaScript t
nednguyen 2017/05/24 21:08:49 Acknowledged.
823 retry_count = 0
824 # Scroll until the window.scrollY is within 1 pixel of the target distance.
825 while remaining > 1:
826 action_runner.ScrollPage(distance=min(remaining, step_size) + 1)
827 new_remaining = (distance -
828 action_runner.EvaluateJavaScript('window.scrollY'))
829 if remaining == new_remaining:
hjd 2017/05/19 10:42:21 This could be remaining >= new_remaining to guaran
nednguyen 2017/05/24 21:08:49 Done.
830 # Scrolling is stuck. This can happen if the page is loading
831 # resources. Give the page some time and retry scrolling.
832 if retry_count == self.MAX_SCROLL_RETRIES:
833 raise Exception('Scrolling stuck at %d' % remaining)
834 retry_count += 1
835 action_runner.Wait(self.TIME_BEFORE_SCROLL_RETRY_IN_SECONDS)
836 else:
837 retry_count = 0
838 remaining = new_remaining
839
840
841 class DiscourseDesktopStory(_InfiniteScrollStory):
842 NAME = 'browse_infinite_scroll:forum:discourse'
perezju 2017/05/19 09:40:35 I would call this: browse:social:discourse And add
ulan 2017/05/19 12:59:00 How about browse:infinite_scroll:discourse? I woul
perezju 2017/05/19 14:34:40 I think "tags" should be the correct way to group
843 URL = ('https://meta.discourse.org/t/the-official-discourse-tags-plugin' +
844 '-discourse-tagging/26482')
845 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
846
847
848 class DiscourseMobileStory(_InfiniteScrollStory):
849 NAME = 'browse_infinite_scroll:forum:discourse'
perezju 2017/05/19 09:40:35 ditto
850 URL = ('https://meta.discourse.org/t/the-official-discourse-tags-plugin' +
851 '-discourse-tagging/26482')
852 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
853 SCROLL_DISTANCE = 15000
854
855
856 class FacebookScrollDesktopStory(_InfiniteScrollStory):
857 NAME = 'browse_infinite_scroll:social:facebook'
perezju 2017/05/19 09:40:35 Could this replace our existing browse:social:face
ulan 2017/05/19 12:59:00 They execute different work loads and should be co
perezju 2017/05/19 14:34:40 For system health, IMO, we should pick representat
858 URL = 'https://www.facebook.com/shakira'
859 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
860
861
862 class FacebookScrollMobileStory(_InfiniteScrollStory):
863 NAME = 'browse_infinite_scroll:social:facebook'
864 URL = 'https://m.facebook.com/shakira'
865 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
866
867 def RunNavigateSteps(self, action_runner):
perezju 2017/05/19 09:40:36 We should be overriding _Login instead.
nednguyen 2017/05/24 21:08:49 Done.
868 facebook_login.LoginWithMobileSite(
869 action_runner, 'facebook3', self.credentials_path)
870 super(FacebookScrollMobileStory, self).RunNavigateSteps(action_runner)
871
872
873 class FlickrDesktopStory(_InfiniteScrollStory):
874 NAME = 'browse_infinite_scroll:media:flickr'
perezju 2017/05/19 09:40:35 Call this just browse:media:flickr
ulan 2017/05/19 12:59:00 How about browse:infinite_scroll:flickr?
875 URL = 'https://www.flickr.com/explore'
876 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
877
878
879 class FlickrMobileStory(_InfiniteScrollStory):
880 NAME = 'browse_infinite_scroll:media:flickr'
881 URL = 'https://www.flickr.com/explore'
882 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
883 SCROLL_DISTANCE = 10000
884
885
886 class PinterestMobileStory(_InfiniteScrollStory):
887 NAME = 'browse_infinite_scroll:social:pinterest'
perezju 2017/05/19 09:40:36 browse:social:pinterest
ulan 2017/05/19 12:59:00 How about browse:infinite_scroll:pinterest?
888 URL = 'https://www.pinterest.com/all'
889 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
perezju 2017/05/19 09:40:35 No desktop version?
nednguyen 2017/05/24 21:08:49 Nope
890
891
892 class TumblrStory(_InfiniteScrollStory):
893 NAME = 'browse_infinite_scroll:social:tumblr'
perezju 2017/05/19 09:40:36 browse:social:tumblr
ulan 2017/05/19 12:59:00 How about browse:infinite_scroll:pinterest?
894 URL = 'http://techcrunch.tumblr.com/'
hjd 2017/05/19 10:42:21 nit: maybe a comment that techcrunch.tumblr.com do
nednguyen 2017/05/24 21:08:49 Done.
895
896
897 class TwitterScrollDesktopStory(_InfiniteScrollStory):
898 NAME = 'browse_infinite_scroll:social:twitter'
899 URL = 'https://twitter.com/taylorswift13'
900 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
OLDNEW
« no previous file with comments | « tools/perf/page_sets/data/system_health_mobile.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698