Bug 1305607 - Correct reading of baseURI from video element. r=maja_zf

Previous changes that I'd made broke the reporting of the baseURI on videos.
This changeset aims to fix those breakages, and also puts the baseURI on the
state snapshot.

MozReview-Commit-ID: 8YgPpHzoX1E

--HG--
extra : rebase_source : 28840d1e47e9f2909eb67bc376a3a85874427149
This commit is contained in:
Bryce Van Dyk 2016-09-27 15:35:57 +13:00
Родитель 732cc6b973
Коммит 1342cbfe94
2 изменённых файлов: 13 добавлений и 11 удалений

Просмотреть файл

@ -59,6 +59,7 @@ class VideoPuppeteer(object):
_video_var_script = ( _video_var_script = (
'var video = arguments[0];' 'var video = arguments[0];'
'var baseURI = arguments[0].baseURI;'
'var currentTime = video.wrappedJSObject.currentTime;' 'var currentTime = video.wrappedJSObject.currentTime;'
'var duration = video.wrappedJSObject.duration;' 'var duration = video.wrappedJSObject.duration;'
'var buffered = video.wrappedJSObject.buffered;' 'var buffered = video.wrappedJSObject.buffered;'
@ -203,7 +204,7 @@ class VideoPuppeteer(object):
if (self.stall_wait_time and if (self.stall_wait_time and
self._last_seen_video_state.lag > self.stall_wait_time): self._last_seen_video_state.lag > self.stall_wait_time):
raise VideoException('Video {} stalled.\n{}' raise VideoException('Video {} stalled.\n{}'
.format(self._last_seen_video_state.video_url, .format(self._last_seen_video_state.video_uri,
self)) self))
# We are cruising, so we are not done. # We are cruising, so we are not done.
@ -251,7 +252,8 @@ class VideoPuppeteer(object):
of the wrapped element. The fields in the tuple should be used as of the wrapped element. The fields in the tuple should be used as
follows: follows:
current_time: The current time of the wrapped element. base_uri: the baseURI attribute of the wrapped element.
current_time: the current time of the wrapped element.
duration: the duration of the wrapped element. duration: the duration of the wrapped element.
buffered: the buffered ranges of the wrapped element. In its raw form buffered: the buffered ranges of the wrapped element. In its raw form
this is as a list where the first element is the length and the second this is as a list where the first element is the length and the second
@ -269,12 +271,12 @@ class VideoPuppeteer(object):
droppedFrames: number of dropped frames for the wrapped element. droppedFrames: number of dropped frames for the wrapped element.
corruptedFrames: number of corrupted frames for the wrapped. corruptedFrames: number of corrupted frames for the wrapped.
video_src: the src attribute of the wrapped element. video_src: the src attribute of the wrapped element.
video_url: the url attribute of the wrapped element.
:return: A 'video_state_info' named tuple class. :return: A 'video_state_info' named tuple class.
""" """
return namedtuple('video_state_info', return namedtuple('video_state_info',
['current_time', ['base_uri',
'current_time',
'duration', 'duration',
'remaining_time', 'remaining_time',
'buffered', 'buffered',
@ -283,8 +285,7 @@ class VideoPuppeteer(object):
'total_frames', 'total_frames',
'dropped_frames', 'dropped_frames',
'corrupted_frames', 'corrupted_frames',
'video_src', 'video_src'])
'video_url'])
def _create_video_state_info(self, **video_state_info_kwargs): def _create_video_state_info(self, **video_state_info_kwargs):
""" """
@ -330,7 +331,6 @@ class VideoPuppeteer(object):
video_state_info_kwargs['remaining_time'] = self.expected_duration video_state_info_kwargs['remaining_time'] = self.expected_duration
# Fetch non time critical source information # Fetch non time critical source information
video_state_info_kwargs['video_src'] = self.video.get_attribute('src') video_state_info_kwargs['video_src'] = self.video.get_attribute('src')
video_state_info_kwargs['video_url'] = self.video.get_attribute('url')
# Create video state snapshot # Create video state snapshot
state_info = self._video_state_named_tuple() state_info = self._video_state_named_tuple()
return state_info(**video_state_info_kwargs) return state_info(**video_state_info_kwargs)
@ -341,6 +341,7 @@ class VideoPuppeteer(object):
self._fetch_state_script_string = ( self._fetch_state_script_string = (
self._video_var_script + self._video_var_script +
'return [' 'return ['
'baseURI,'
'currentTime,' 'currentTime,'
'duration,' 'duration,'
'[buffered.length, bufferedRanges],' '[buffered.length, bufferedRanges],'
@ -359,7 +360,7 @@ class VideoPuppeteer(object):
information, such as lag. This is stored in the last seen state to information, such as lag. This is stored in the last seen state to
stress that it's based on the snapshot. stress that it's based on the snapshot.
""" """
keys = ['current_time', 'duration', 'raw_buffered_ranges', keys = ['base_uri', 'current_time', 'duration', 'raw_buffered_ranges',
'raw_played_ranges', 'total_frames', 'dropped_frames', 'raw_played_ranges', 'total_frames', 'dropped_frames',
'corrupted_frames'] 'corrupted_frames']
values = self._execute_video_script(self._fetch_state_script) values = self._execute_video_script(self._fetch_state_script)

Просмотреть файл

@ -344,6 +344,7 @@ class YouTubePuppeteer(VideoPuppeteer):
self._video_var_script + self._video_var_script +
self._player_var_script + self._player_var_script +
'return [' 'return ['
'baseURI,'
'currentTime,' 'currentTime,'
'duration,' 'duration,'
'[buffered.length, bufferedRanges],' '[buffered.length, bufferedRanges],'
@ -372,9 +373,9 @@ class YouTubePuppeteer(VideoPuppeteer):
stress that it's based on the snapshot. stress that it's based on the snapshot.
""" """
values = self._execute_yt_script(self._fetch_state_script) values = self._execute_yt_script(self._fetch_state_script)
video_keys = ['current_time', 'duration', 'raw_buffered_ranges', video_keys = ['base_uri', 'current_time', 'duration',
'raw_played_ranges', 'total_frames', 'dropped_frames', 'raw_buffered_ranges', 'raw_played_ranges',
'corrupted_frames'] 'total_frames', 'dropped_frames', 'corrupted_frames']
player_keys = ['player_duration', 'player_current_time', player_keys = ['player_duration', 'player_current_time',
'player_playback_quality', 'player_movie_id', 'player_playback_quality', 'player_movie_id',
'player_movie_title', 'player_url', 'player_state', 'player_movie_title', 'player_url', 'player_state',