Bug 1304961 - Rename variables storing played ranges to be more specific. r=maja_zf
authorBryce Van Dyk <bvandyk@mozilla.com>
Fri, 23 Sep 2016 17:24:40 +1200
changeset 315191 9efa0b30eab2794efca785b24a19934d9a112dbd
parent 315190 b451b91d4b4687f248bc7b2a4b959c7bd7459790
child 315192 89fc0a741450051c0243a264f0c8ee4ceb071395
push id82104
push userihsiao@mozilla.com
push dateMon, 26 Sep 2016 11:08:56 +0000
treeherdermozilla-inbound@87aeaae19f90 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1304961
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1304961 - Rename variables storing played ranges to be more specific. r=maja_zf The played ranges being retrieved in VideoPuppeteer and YoutubePuppeteer were often referenced as some variation of 'time ranges'. This patch makes that more specific and references the played ranges as variations of 'played ranges'. This removes ambiguity if other time ranges are retrieved in future, such as the buffered ranges. MozReview-Commit-ID: CInjDCCIQkV
dom/media/test/external/external_media_tests/media_utils/video_puppeteer.py
dom/media/test/external/external_media_tests/media_utils/youtube_puppeteer.py
--- a/dom/media/test/external/external_media_tests/media_utils/video_puppeteer.py
+++ b/dom/media/test/external/external_media_tests/media_utils/video_puppeteer.py
@@ -57,19 +57,19 @@ class VideoPuppeteer(object):
     :param timeout: The amount of time to wait until the video starts.
     """
 
     _video_var_script = (
         'var video = arguments[0];'
         'var currentTime = video.wrappedJSObject.currentTime;'
         'var duration = video.wrappedJSObject.duration;'
         'var played = video.wrappedJSObject.played;'
-        'var timeRanges = [];'
+        'var playedRanges = [];'
         'for (var i = 0; i < played.length; i++) {'
-        'timeRanges.push([played.start(i), played.end(i)]);'
+        'playedRanges.push([played.start(i), played.end(i)]);'
         '}'
         'var totalFrames = '
         'video.getVideoPlaybackQuality()["totalVideoFrames"];'
         'var droppedFrames = '
         'video.getVideoPlaybackQuality()["droppedVideoFrames"];'
         'var corruptedFrames = '
         'video.getVideoPlaybackQuality()["corruptedVideoFrames"];'
     )
@@ -274,33 +274,33 @@ class VideoPuppeteer(object):
                            'corrupted_frames',
                            'video_src',
                            'video_url'])
 
     def _create_video_state_info(self, **video_state_info_kwargs):
         """
         Create an instance of the video_state_info named tuple. This function
         expects a dictionary populated with the following keys: current_time,
-        duration, raw_time_ranges, total_frames, dropped_frames, and
+        duration, raw_played_ranges, total_frames, dropped_frames, and
         corrupted_frames.
 
-        Aside from raw_time_ranges, see `_video_state_named_tuple` for more
-        information on the above keys and values. For raw_time_ranges a
+        Aside from raw_played_ranges, see `_video_state_named_tuple` for more
+        information on the above keys and values. For raw_played_ranges a
         list is expected that can be consumed to make a TimeRanges object.
 
         :return: A named tuple 'video_state_info' derived from arguments and
         state information from the puppeteer.
         """
-        raw_time_ranges = video_state_info_kwargs['raw_time_ranges']
+        raw_played_ranges = video_state_info_kwargs['raw_played_ranges']
         # Remove raw ranges from dict as it is not used in the final named
         # tuple and will provide an unexpected kwarg if kept.
-        del video_state_info_kwargs['raw_time_ranges']
+        del video_state_info_kwargs['raw_played_ranges']
         # Create played ranges
         video_state_info_kwargs['played'] = (
-            TimeRanges(raw_time_ranges[0], raw_time_ranges[1]))
+            TimeRanges(raw_played_ranges[0], raw_played_ranges[1]))
         # Calculate elapsed times
         elapsed_current_time = (video_state_info_kwargs['current_time'] -
                                 self._first_seen_time)
         elapsed_wall_time = clock() - self._first_seen_wall_time
         # Calculate lag
         video_state_info_kwargs['lag'] = (
             elapsed_wall_time - elapsed_current_time)
         # Calculate remaining time
@@ -322,32 +322,32 @@ class VideoPuppeteer(object):
     @property
     def _fetch_state_script(self):
         if not self._fetch_state_script_string:
             self._fetch_state_script_string = (
                 self._video_var_script +
                 'return ['
                 'currentTime,'
                 'duration,'
-                '[played.length, timeRanges],'
+                '[played.length, playedRanges],'
                 'totalFrames,'
                 'droppedFrames,'
                 'corruptedFrames];')
         return self._fetch_state_script_string
 
     def _refresh_state(self):
         """
         Refresh the snapshot of the underlying video state. We do this all
         in one so that the state doesn't change in between queries.
 
         We also store information that can be derived from the snapshotted
         information, such as lag. This is stored in the last seen state to
         stress that it's based on the snapshot.
         """
-        keys = ['current_time', 'duration', 'raw_time_ranges', 'total_frames',
+        keys = ['current_time', 'duration', 'raw_played_ranges', 'total_frames',
                 'dropped_frames', 'corrupted_frames']
         values = self._execute_video_script(self._fetch_state_script)
         self._last_seen_video_state = (
             self._create_video_state_info(**dict(zip(keys, values))))
 
     def _measure_progress(self):
         self._refresh_state()
         initial = self._last_seen_video_state.current_time
--- a/dom/media/test/external/external_media_tests/media_utils/youtube_puppeteer.py
+++ b/dom/media/test/external/external_media_tests/media_utils/youtube_puppeteer.py
@@ -341,17 +341,17 @@ class YouTubePuppeteer(VideoPuppeteer):
     def _fetch_state_script(self):
         if not self._fetch_state_script_string:
             self._fetch_state_script_string = (
                 self._video_var_script +
                 self._player_var_script +
                 'return ['
                 'currentTime,'
                 'duration,'
-                '[played.length, timeRanges],'
+                '[played.length, playedRanges],'
                 'totalFrames,'
                 'droppedFrames,'
                 'corruptedFrames,'
                 'player_duration,'
                 'player_current_time,'
                 'player_playback_quality,'
                 'player_movie_id,'
                 'player_movie_title,'
@@ -366,17 +366,17 @@ class YouTubePuppeteer(VideoPuppeteer):
         Refresh the snapshot of the underlying video and player state. We do
         this allin one so that the state doesn't change in between queries.
 
         We also store information that can be derived from the snapshotted
         information, such as lag. This is stored in the last seen state to
         stress that it's based on the snapshot.
         """
         values = self._execute_yt_script(self._fetch_state_script)
-        video_keys = ['current_time', 'duration', 'raw_time_ranges',
+        video_keys = ['current_time', 'duration', 'raw_played_ranges',
                       'total_frames', 'dropped_frames', 'corrupted_frames']
         player_keys = ['player_duration', 'player_current_time',
                        'player_playback_quality', 'player_movie_id',
                        'player_movie_title', 'player_url', 'player_state',
                        'player_ad_state', 'player_breaks_count']
         # Get video state
         self._last_seen_video_state = (
             self._create_video_state_info(**dict(