Bug 1276643 - External media tests reset widevine GMP. r=maja_zf
authorBryce Van Dyk <bvandyk@mozilla.com>
Mon, 30 May 2016 15:21:51 +1200
changeset 341561 ac2aaa6bcb4a80476d8c19dd6482ac119779f8b9
parent 341560 f729fa97d3a7e69f7550f01ddbfa8da9256421d7
child 341562 b8b0f46e3811071923c137964af94fe021934500
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1276643
milestone49.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 1276643 - External media tests reset widevine GMP. r=maja_zf Make the EME mixin also reset the widevine GMP. This gives us some widevine downloader coverage, as well as meaning that EME tests that rely on widevine should work. MozReview-Commit-ID: AyeeLu2lJRK
dom/media/test/external/external_media_harness/testcase.py
--- a/dom/media/test/external/external_media_harness/testcase.py
+++ b/dom/media/test/external/external_media_harness/testcase.py
@@ -207,31 +207,44 @@ navigator.requestMediaKeySystemAccess('c
     },
     function(ex) {
         marionetteScriptFinished(ex);
     }
 );
 """
 
 
+reset_widevine_gmp_script = """
+navigator.requestMediaKeySystemAccess('com.widevine.alpha',
+[{initDataTypes: ['cenc']}]).then(
+    function(access) {
+        marionetteScriptFinished('success');
+    },
+    function(ex) {
+        marionetteScriptFinished(ex);
+    }
+);
+"""
+
+
 class EMESetupMixin(object):
 
     """
-    An object that needs to use the Adobe GMP system must inherit from this
-    class, and then call check_eme_system() to insure that everything is
-    setup correctly.
+    An object that needs to use the Adobe or Widevine GMP system must inherit
+    from this class, and then call check_eme_system() to insure that everything
+    is setup correctly.
     """
 
     version_needs_reset = True
 
     def check_eme_system(self):
         """
-        Download the most current version of the Adobe GMP Plugin. Verify
-        that all MSE and EME prefs are set correctly. Raises if things
-        are not OK.
+        Download the most current version of the Adobe and Widevine GMP
+        Plugins. Verify that all MSE and EME prefs are set correctly. Raises
+        if things are not OK.
         """
         self.set_eme_prefs()
         self.reset_GMP_version()
         assert(self.check_eme_prefs())
 
     def set_eme_prefs(self):
         with self.marionette.using_context('chrome'):
             # https://bugzilla.mozilla.org/show_bug.cgi?id=1187471#c28
@@ -239,23 +252,31 @@ class EMESetupMixin(object):
             # we are working with older firefoxes...
             self.prefs.set_pref('media.gmp.trial-create.enabled', False)
 
     def reset_GMP_version(self):
         if EMESetupMixin.version_needs_reset:
             with self.marionette.using_context('chrome'):
                 if self.prefs.get_pref('media.gmp-eme-adobe.version'):
                     self.prefs.reset_pref('media.gmp-eme-adobe.version')
+                if self.prefs.get_pref('media.gmp-widevinecdm.version'):
+                    self.prefs.reset_pref('media.gmp-widevinecdm.version')
             with self.marionette.using_context('content'):
-                result = self.marionette.execute_async_script(
+                adobe_result = self.marionette.execute_async_script(
                     reset_adobe_gmp_script,
                     script_timeout=60000)
-                if not result == 'success':
+                widevine_result = self.marionette.execute_async_script(
+                    reset_widevine_gmp_script,
+                    script_timeout=60000)
+                if not adobe_result == 'success':
                     raise VideoException(
                         'ERROR: Resetting Adobe GMP failed % s' % result)
+                if not widevine_result == 'success':
+                    raise VideoException(
+                        'ERROR: Resetting Widevine GMP failed % s' % result)
 
             EMESetupMixin.version_needs_reset = False
 
     def check_and_log_boolean_pref(self, pref_name, expected_value):
         with self.marionette.using_context('chrome'):
             pref_value = self.prefs.get_pref(pref_name)
 
             if pref_value is None:
@@ -282,25 +303,55 @@ class EMESetupMixin(object):
 
                 match = re.search('^\d+$', pref_value)
                 if not match:
                     self.logger.info('Pref %s is not an integer' % pref_name)
                     return False
 
             return pref_value >= minimum_value
 
+    def chceck_and_log_version_string_pref(self, pref_name, minimum_value='0'):
+        """
+        Compare a pref made up of integers separated by stops .s, with a
+        version string of the same format. The number of integers in each string
+        does not need to match. The comparison is done by converting each to an
+        integer array and comparing those. Both version strings must be made
+        up of only integers, or this method will raise an unhandled exception
+        of type ValueError when the conversion to int fails.
+        """
+        with self.marionette.using_context('chrome'):
+            pref_value = self.prefs.get_pref(pref_name)
+
+            if pref_value is None:
+                self.logger.info('Pref %s has no value.' % pref_name)
+                return False
+            else:
+                self.logger.info('Pref %s = %s' % (pref_name, pref_value))
+
+                match = re.search('^\d(.\d+)*$', pref_value)
+                if not match:
+                    self.logger.info('Pref %s is not a version string' % pref_name)
+                    return False
+
+            pref_ints = [int(n) for n in pref_value.split('.')]
+            minumum_ints = [int(n) for n in minimum_value.split('.')]
+
+            return pref_ints >= minumum_ints
+
+
     def check_eme_prefs(self):
         with self.marionette.using_context('chrome'):
-            prefs_ok = self.check_and_log_boolean_pref(
-                'media.mediasource.enabled', True)
-            prefs_ok = self.check_and_log_boolean_pref(
-                'media.eme.enabled', True) and prefs_ok
-            prefs_ok = self.check_and_log_boolean_pref(
-                'media.mediasource.mp4.enabled', True) and prefs_ok
-            prefs_ok = self.check_and_log_boolean_pref(
-                'media.gmp-eme-adobe.enabled', True) and prefs_ok
-            prefs_ok = self.check_and_log_integer_pref(
-                'media.gmp-eme-adobe.version', 1) and prefs_ok
-
-        return prefs_ok
-
-
-
+            return all([
+                self.check_and_log_boolean_pref(
+                    'media.mediasource.enabled', True),
+                self.check_and_log_boolean_pref(
+                    'media.eme.enabled', True),
+                self.check_and_log_boolean_pref(
+                    'media.mediasource.mp4.enabled', True),
+                self.check_and_log_boolean_pref(
+                    'media.gmp-eme-adobe.enabled', True),
+                self.check_and_log_integer_pref(
+                    'media.gmp-eme-adobe.version', 1),
+                self.check_and_log_boolean_pref(
+                    'media.gmp-widevinecdm.enabled', True),
+                self.chceck_and_log_version_string_pref(
+                    'media.gmp-widevinecdm.version', '1.0.0.0')
+            ])