Bug 1304961 - Rename variables storing played ranges to be more specific. r?maja_zf draft
authorBryce Van Dyk <bvandyk@mozilla.com>
Fri, 23 Sep 2016 17:24:40 +1200
changeset 416854 f5b67d4bd8918e53e51e3df9915a98b612da977d
parent 416770 058cf01f6cf2d2526c28b864a78afd4b97189b2a
child 416855 3c440cb9016c3972f984ce1ede3a37582e641d57
push id30266
push userbvandyk@mozilla.com
push dateFri, 23 Sep 2016 06:08:16 +0000
reviewersmaja_zf
bugs1304961
milestone52.0a1
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(