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

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: Disable browse:social:facebook_infinite_scroll & browse:tech:discourse_infinite_scroll Created 3 years, 6 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
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 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 # Reduce the speed (the current wpr is recorded with speed set to 50) when 778 # Reduce the speed (the current wpr is recorded with speed set to 50) when
778 # recording the wpr. If we scroll too fast, the data will not be recorded 779 # recording the wpr. If we scroll too fast, the data will not be recorded
779 # well. After recording reset it back to the original value to have a more 780 # well. After recording reset it back to the original value to have a more
780 # realistic scroll. 781 # realistic scroll.
781 action_runner.RepeatableBrowserDrivenScroll( 782 action_runner.RepeatableBrowserDrivenScroll(
782 x_scroll_distance_ratio = 0.0, y_scroll_distance_ratio = 1, 783 x_scroll_distance_ratio = 0.0, y_scroll_distance_ratio = 1,
783 repeat_count=3, speed=400, timeout=120) 784 repeat_count=3, speed=400, timeout=120)
784 action_runner.RepeatableBrowserDrivenScroll( 785 action_runner.RepeatableBrowserDrivenScroll(
785 x_scroll_distance_ratio = 1, y_scroll_distance_ratio = 0, 786 x_scroll_distance_ratio = 1, y_scroll_distance_ratio = 0,
786 repeat_count=3, speed=500, timeout=120) 787 repeat_count=3, speed=500, timeout=120)
788
789
790 ##############################################################################
791 # Browsing stories with infinite scrolling
792 ##############################################################################
793
794
795 class _InfiniteScrollStory(system_health_story.SystemHealthStory):
796 SUPPORTED_PLATFORMS = platforms.ALL_PLATFORMS
797
798 SCROLL_DISTANCE = 25000
799 SCROLL_STEP = 1000
800 MAX_SCROLL_RETRIES = 3
801 TIME_BEFORE_SCROLL_RETRY_IN_SECONDS = 1
802 TIME_TO_WAIT_BEFORE_STARTING_IN_SECONDS = 5
803
804 def __init__(self, story_set, take_memory_measurement):
805 super(_InfiniteScrollStory, self).__init__(story_set,
806 take_memory_measurement)
807 self.script_to_evaluate_on_commit = '''
808 window.WebSocket = undefined;
809 window.Worker = undefined;
810 window.performance = undefined;'''
811
812 def _DidLoadDocument(self, action_runner):
813 action_runner.WaitForJavaScriptCondition(
814 'document.body != null && '
815 'document.body.scrollHeight > window.innerHeight && '
816 '!document.body.addEventListener("touchstart", function() {})')
817 action_runner.Wait(self.TIME_TO_WAIT_BEFORE_STARTING_IN_SECONDS)
818 self._Scroll(action_runner, self.SCROLL_DISTANCE, self.SCROLL_STEP)
819
820
821 def _Scroll(self, action_runner, distance, step_size):
822 """ This function scrolls the webpage by the given scroll distance in
823 multiple steps, where each step (except the last one) has the given size.
824
825 If scrolling gets stuck, the functions retries scrolling MAX_SCROLL_RETRIES
826 times waiting TIME_BEFORE_SCROLL_RETRY_IN_SECONDS seconds between retries.
827 """
828 remaining = distance - action_runner.EvaluateJavaScript('window.scrollY')
829 retry_count = 0
830 # Scroll until the window.scrollY is within 1 pixel of the target distance.
831 while remaining > 1:
832 action_runner.ScrollPage(distance=min(remaining, step_size) + 1)
833 new_remaining = (distance -
834 action_runner.EvaluateJavaScript('window.scrollY'))
835 if remaining <= new_remaining:
836 # Scrolling is stuck. This can happen if the page is loading
837 # resources. Give the page some time and retry scrolling.
838 if retry_count == self.MAX_SCROLL_RETRIES:
839 raise Exception('Scrolling stuck at %d' % remaining)
840 retry_count += 1
841 action_runner.Wait(self.TIME_BEFORE_SCROLL_RETRY_IN_SECONDS)
842 else:
843 retry_count = 0
844 remaining = new_remaining
845
846 @classmethod
847 def GenerateStoryDescription(cls):
848 return 'Load %s then make a very long scroll.' % cls.URL
849
850
851 @decorators.Disabled('win') # crbug.com/728152
852 class DiscourseDesktopStory(_InfiniteScrollStory):
853 NAME = 'browse:tech:discourse_infinite_scroll'
854 URL = ('https://meta.discourse.org/t/the-official-discourse-tags-plugin-discou rse-tagging/26482')
855 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
856 TAGS = [story_tags.INFINITE_SCROLL]
857
858
859 class DiscourseMobileStory(_InfiniteScrollStory):
860 NAME = 'browse:tech:discourse_infinite_scroll'
861 URL = ('https://meta.discourse.org/t/the-official-discourse-tags-plugin-discou rse-tagging/26482')
862 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
863 SCROLL_DISTANCE = 15000
864 TAGS = [story_tags.INFINITE_SCROLL]
865
866
867 @decorators.Disabled('win') # crbug.com/728152
868 class FacebookScrollDesktopStory(_InfiniteScrollStory):
869 NAME = 'browse:social:facebook_infinite_scroll'
870 URL = 'https://www.facebook.com/shakira'
871 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
872 TAGS = [story_tags.INFINITE_SCROLL]
873
874
875 @decorators.Disabled('all') # crbug.com/727835
876 class FacebookScrollMobileStory(_InfiniteScrollStory):
877 NAME = 'browse:social:facebook_infinite_scroll'
878 URL = 'https://m.facebook.com/shakira'
879 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
880
881 def _Login(self, action_runner):
882 facebook_login.LoginWithMobileSite(
883 action_runner, 'facebook3', self.credentials_path)
884
885
886 class FlickrDesktopStory(_InfiniteScrollStory):
887 NAME = 'browse:media:flickr_infinite_scroll'
888 URL = 'https://www.flickr.com/explore'
889 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
890 TAGS = [story_tags.INFINITE_SCROLL]
891
892
893 class FlickrMobileStory(_InfiniteScrollStory):
894 NAME = 'browse:media:flickr_infinite_scroll'
895 URL = 'https://www.flickr.com/explore'
896 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
897 SCROLL_DISTANCE = 10000
898 TAGS = [story_tags.INFINITE_SCROLL]
899
900
901 class PinterestMobileStory(_InfiniteScrollStory):
902 NAME = 'browse:social:pinterest_infinite_scroll'
903 URL = 'https://www.pinterest.com/all'
904 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
905 TAGS = [story_tags.INFINITE_SCROLL]
906
907
908 class TumblrStory(_InfiniteScrollStory):
909 NAME = 'browse:social:tumblr_infinite_scroll'
910 URL = 'http://techcrunch.tumblr.com/' # This page doesn't support HTTPS.
911 TAGS = [story_tags.INFINITE_SCROLL]
912
913
914 class TwitterScrollDesktopStory(_InfiniteScrollStory):
915 NAME = 'browse:social:twitter_infinite_scroll'
916 URL = 'https://twitter.com/taylorswift13'
917 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
918 TAGS = [story_tags.INFINITE_SCROLL]
OLDNEW
« no previous file with comments | « tools/perf/page_sets/data/system_health_mobile.json ('k') | tools/perf/page_sets/system_health/story_tags.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698