Bug 1292396 - Replace Marionette context string literals with symbolic variables. r?AutomatedTester draft
authorBryce Van Dyk <bvandyk@mozilla.com>
Wed, 03 Aug 2016 14:21:27 +1200
changeset 397001 67c824d3406090908c36c37abb5f1ec564838231
parent 396997 3f6525de5029cd512bdd1d04b5bd10a1e2ffc3e3
child 527349 6cafa51e1744fce7911f379cab316c289823becc
push id25175
push userbvandyk@mozilla.com
push dateFri, 05 Aug 2016 02:06:42 +0000
reviewersAutomatedTester
bugs1292396
milestone51.0a1
Bug 1292396 - Replace Marionette context string literals with symbolic variables. r?AutomatedTester MozReview-Commit-ID: 9tRUYmVsaXO
dom/media/test/external/external_media_harness/testcase.py
dom/media/test/external/external_media_tests/media_utils/video_puppeteer.py
dom/media/test/external/external_media_tests/media_utils/youtube_puppeteer.py
dom/media/test/external/external_media_tests/playback/test_full_playback.py
dom/media/test/external/external_media_tests/playback/test_shaka_playback.py
dom/media/test/external/external_media_tests/playback/youtube/test_basic_playback.py
dom/media/test/external/external_media_tests/test_example.py
--- a/dom/media/test/external/external_media_harness/testcase.py
+++ b/dom/media/test/external/external_media_harness/testcase.py
@@ -1,17 +1,17 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import re
 import os
 import time
 
-from marionette import BrowserMobProxyTestCaseMixin, MarionetteTestCase
+from marionette import BrowserMobProxyTestCaseMixin, MarionetteTestCase, Marionette
 from marionette_driver import Wait
 from marionette_driver.errors import TimeoutException
 from marionette.marionette_test import SkipTest
 
 from firefox_puppeteer.testcases import BaseFirefoxTestCase
 from external_media_tests.utils import (timestamp_now, verbose_until)
 from external_media_tests.media_utils.video_puppeteer import (playback_done, playback_started,
                                          VideoException, VideoPuppeteer as VP)
@@ -38,56 +38,56 @@ class MediaTestCase(BaseFirefoxTestCase,
                                       'screenshots')
         filename = ''.join([self.id().replace(' ', '-'),
                             '_',
                             str(timestamp_now()),
                             '.png'])
         path = os.path.join(screenshot_dir, filename)
         if not os.path.exists(screenshot_dir):
             os.makedirs(screenshot_dir)
-        with self.marionette.using_context('content'):
+        with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
             img_data = self.marionette.screenshot()
         with open(path, 'wb') as f:
             f.write(img_data.decode('base64'))
         self.marionette.log('Screenshot saved in %s' % os.path.abspath(path))
 
     def log_video_debug_lines(self):
         """
         Log the debugging information that Firefox provides for video elements.
         """
-        with self.marionette.using_context('chrome'):
+        with self.marionette.using_context(Marionette.CONTEXT_CHROME):
             debug_lines = self.marionette.execute_script(VP._debug_script)
             if debug_lines:
                 self.marionette.log('\n'.join(debug_lines))
 
     def run_playback(self, video):
         """
         Play the video all of the way through, or for the requested duration,
         whichever comes first. Raises if the video stalls for too long.
 
         :param video: VideoPuppeteer instance to play.
         """
-        with self.marionette.using_context('content'):
+        with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
             self.logger.info(video.test_url)
             try:
                 verbose_until(Wait(video, interval=video.interval,
                                    timeout=video.expected_duration * 1.3 +
                                    video.stall_wait_time),
                               video, playback_done)
             except VideoException as e:
                 raise self.failureException(e)
 
     def check_playback_starts(self, video):
         """
         Check to see if a given video will start. Raises if the video does not
         start.
 
         :param video: VideoPuppeteer instance to play.
         """
-        with self.marionette.using_context('content'):
+        with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
             self.logger.info(video.test_url)
             try:
                 verbose_until(Wait(video, timeout=video.timeout),
                               video, playback_started)
             except TimeoutException as e:
                 raise self.failureException(e)
 
     def skipTest(self, reason):
@@ -123,17 +123,17 @@ class NetworkBandwidthTestCase(MediaTest
         BrowserMobProxyTestCaseMixin.tearDown(self)
         self.proxy = None
 
     def run_videos(self, timeout=60):
         """
         Run each of the videos in the video list. Raises if something goes
         wrong in playback.
         """
-        with self.marionette.using_context('content'):
+        with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
             for url in self.video_urls:
                 video = VP(self.marionette, url, stall_wait_time=60,
                            set_duration=60, timeout=timeout)
                 self.run_playback(video)
 
 
 class VideoPlaybackTestsMixin(object):
 
@@ -147,17 +147,17 @@ class VideoPlaybackTestsMixin(object):
     minute each, and is the test that should be run frequently in automation.
     """
 
     def test_playback_starts(self):
         """
         Test to make sure that playback of the video element starts for each
         video.
         """
-        with self.marionette.using_context('content'):
+        with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
             for url in self.video_urls:
                 try:
                     video = VP(self.marionette, url, timeout=60)
                     # Second playback_started check in case video._start_time
                     # is not 0
                     self.check_playback_starts(video)
                     video.pause()
                     src = video.video_src
@@ -167,17 +167,17 @@ class VideoPlaybackTestsMixin(object):
                                             level='WARNING')
                 except TimeoutException as e:
                     raise self.failureException(e)
 
     def test_video_playback_partial(self):
         """
         Test to make sure that playback of 60 seconds works for each video.
         """
-        with self.marionette.using_context('content'):
+        with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
             for url in self.video_urls:
                 video = VP(self.marionette, url,
                            stall_wait_time=10,
                            set_duration=60)
                 self.run_playback(video)
 
 
 class NetworkBandwidthTestsMixin(object):
@@ -241,30 +241,30 @@ class EMESetupMixin(object):
         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'):
+        with self.marionette.using_context(Marionette.CONTEXT_CHROME):
             # https://bugzilla.mozilla.org/show_bug.cgi?id=1187471#c28
             # 2015-09-28 cpearce says this is no longer necessary, but in case
             # 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'):
+            with self.marionette.using_context(Marionette.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'):
+            with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
                 adobe_result = self.marionette.execute_async_script(
                     reset_adobe_gmp_script,
                     script_timeout=60000)
                 widevine_result = self.marionette.execute_async_script(
                     reset_widevine_gmp_script,
                     script_timeout=60000)
                 if not adobe_result == 'success':
                     raise VideoException(
@@ -272,33 +272,33 @@ class EMESetupMixin(object):
                 if not widevine_result == 'success':
                     raise VideoException(
                         'ERROR: Resetting Widevine GMP failed % s'
                         % widevine_result)
 
             EMESetupMixin.version_needs_reset = False
 
     def check_and_log_boolean_pref(self, pref_name, expected_value):
-        with self.marionette.using_context('chrome'):
+        with self.marionette.using_context(Marionette.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))
                 if pref_value != expected_value:
                     self.logger.info('Pref %s has unexpected value.'
                                      % pref_name)
                     return False
 
         return True
 
     def check_and_log_integer_pref(self, pref_name, minimum_value=0):
-        with self.marionette.using_context('chrome'):
+        with self.marionette.using_context(Marionette.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))
 
@@ -314,17 +314,17 @@ class EMESetupMixin(object):
         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'):
+        with self.marionette.using_context(Marionette.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))
 
@@ -335,17 +335,17 @@ class EMESetupMixin(object):
                     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'):
+        with self.marionette.using_context(Marionette.CONTEXT_CHROME):
             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(
--- 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
@@ -1,14 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from time import clock, sleep
 
+from marionette import Marionette
 from marionette_driver import By, expected, Wait
 
 from external_media_tests.utils import verbose_until
 
 
 # Adapted from
 # https://github.com/gavinsharp/aboutmedia/blob/master/chrome/content/aboutmedia.xhtml
 debug_script = """
@@ -64,17 +65,17 @@ class VideoPuppeteer(object):
         self.stall_wait_time = stall_wait_time
         self.timeout = timeout
         self._set_duration = set_duration
         self.video = None
         self.expected_duration = 0
         self._start_time = 0
         self._start_wall_time = 0
         wait = Wait(self.marionette, timeout=self.timeout)
-        with self.marionette.using_context('content'):
+        with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
             self.marionette.navigate(self.test_url)
             self.marionette.execute_script("""
                 log('URL: {0}');""".format(self.test_url))
             verbose_until(wait, self,
                           expected.element_present(By.TAG_NAME, 'video'))
             videos_found = self.marionette.find_elements(By.CSS_SELECTOR,
                                                          video_selector)
             if len(videos_found) > 1:
@@ -173,17 +174,17 @@ class VideoPuppeteer(object):
         return self.expected_duration - self.current_time
 
     @property
     def video_src(self):
         """
         :return: The url of the actual video file, as opposed to the url
             of the page with the video element.
         """
-        with self.marionette.using_context('content'):
+        with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
             return self.video.get_attribute('src')
 
     @property
     def total_frames(self):
         """
         :return: Number of video frames created and dropped since the creation
             of this video element.
         """
@@ -233,22 +234,22 @@ class VideoPuppeteer(object):
 
     def measure_progress(self):
         initial = self.current_time
         sleep(1)
         return self.current_time - initial
 
     def execute_video_script(self, script):
         """
-        Execute JS script in 'content' context with access to video element.
+        Execute JS script in content context with access  to video element.
 
         :param script: script to be executed
         :return: value returned by script
         """
-        with self.marionette.using_context('content'):
+        with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
             return self.marionette.execute_script(script,
                                                   script_args=[self.video])
 
     def __str__(self):
         messages = ['%s - test url: %s: {' % (type(self).__name__,
                                               self.test_url)]
         if self.video:
             messages += [
--- 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
@@ -1,16 +1,17 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from time import sleep
 import re
 from json import loads
 
+from marionette import Marionette
 from marionette_driver import By, expected, Wait
 from marionette_driver.errors import TimeoutException, NoSuchElementException
 from video_puppeteer import VideoPuppeteer, VideoException
 from external_media_tests.utils import verbose_until
 
 
 class YouTubePuppeteer(VideoPuppeteer):
     """
@@ -34,17 +35,17 @@ class YouTubePuppeteer(VideoPuppeteer):
 
     def __init__(self, marionette, url, **kwargs):
         self.player = None
         super(YouTubePuppeteer,
               self).__init__(marionette, url,
                              video_selector='#movie_player video',
                              **kwargs)
         wait = Wait(self.marionette, timeout=30)
-        with self.marionette.using_context('content'):
+        with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
             verbose_until(wait, self,
                           expected.element_present(By.ID, 'movie_player'))
             self.player = self.marionette.find_element(By.ID, 'movie_player')
             self.marionette.execute_script("log('#movie_player "
                                            "element obtained');")
         # When an ad is playing, self.player_duration indicates the duration
         # of the spliced-in ad stream, not the duration of the main video, so
         # we attempt to skip the ad first.
@@ -110,24 +111,24 @@ class YouTubePuppeteer(VideoPuppeteer):
             try:
                 return loads(text)
             except ValueError:
                 self.marionette.log('Error loading json: DebugText',
                                     level='DEBUG')
 
     def execute_yt_script(self, script):
         """
-        Execute JS script in 'content' context with access to video element and
+        Execute JS script in content context with access to video element and
         YouTube #movie_player element.
 
         :param script: script to be executed.
 
         :return: value returned by script
         """
-        with self.marionette.using_context('content'):
+        with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
             return self.marionette.execute_script(script,
                                                   script_args=[self.video,
                                                                self.player])
 
     @property
     def playback_quality(self):
         """
         Please see https://developers.google.com/youtube/js_api_reference#Playback_quality
@@ -252,32 +253,32 @@ class YouTubePuppeteer(VideoPuppeteer):
         """
         When ad is not playing, ad_format is False.
 
         :return: integer representing ad format, or False
         """
         state = self.get_ad_displaystate()
         ad_format = False
         if state:
-            with self.marionette.using_context('content'):
+            with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
                 ad_format = self.marionette.execute_script("""
                     return arguments[0].adFormat;""",
                     script_args=[state])
         return ad_format
 
     @property
     def ad_skippable(self):
         """
 
         :return: True if the current ad is skippable.
         """
         state = self.get_ad_displaystate()
         skippable = False
         if state:
-            with self.marionette.using_context('content'):
+            with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
                 skippable = self.marionette.execute_script("""
                     return arguments[0].skippable;""",
                     script_args=[state])
         return skippable
 
     def get_ad_displaystate(self):
         # may return None
         return self.execute_yt_script('return arguments[1].'
@@ -347,17 +348,17 @@ class YouTubePuppeteer(VideoPuppeteer):
             sleep(10)
         else:
             # no ad playing
             return False
         if self.ad_skippable:
             selector = '#movie_player .videoAdUiSkipContainer'
             wait = Wait(self.marionette, timeout=30)
             try:
-                with self.marionette.using_context('content'):
+                with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
                     wait.until(expected.element_displayed(By.CSS_SELECTOR,
                                                           selector))
                     ad_button = self.marionette.find_element(By.CSS_SELECTOR,
                                                              selector)
                     ad_button.click()
                     self.marionette.log('Skipped ad.')
                     return True
             except (TimeoutException, NoSuchElementException):
@@ -375,17 +376,17 @@ class YouTubePuppeteer(VideoPuppeteer):
             return None
         # If the ad is not Flash...
         if (self.ad_playing and self.video_src.startswith('mediasource') and
                 self.duration):
             return self.duration
         selector = '#movie_player .videoAdUiAttribution'
         wait = Wait(self.marionette, timeout=5)
         try:
-            with self.marionette.using_context('content'):
+            with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
                 wait.until(expected.element_present(By.CSS_SELECTOR,
                                                     selector))
                 countdown = self.marionette.find_element(By.CSS_SELECTOR,
                                                          selector)
                 ad_time = self._time_pattern.search(countdown.text)
                 if ad_time:
                     ad_minutes = int(ad_time.group('minute'))
                     ad_seconds = int(ad_time.group('second'))
@@ -431,17 +432,17 @@ class YouTubePuppeteer(VideoPuppeteer):
         mn = self.marionette
         wait = Wait(mn, timeout=10)
 
         def get_status(el):
             script = 'return arguments[0].wrappedJSObject.checked'
             return mn.execute_script(script, script_args=[el])
 
         try:
-            with mn.using_context('content'):
+            with mn.using_context(Marionette.CONTEXT_CONTENT):
                 # the width, height of the element are 0, so it's not visible
                 wait.until(expected.element_present(By.ID, element_id))
                 checkbox = mn.find_element(By.ID, element_id)
 
                 # Note: in some videos, due to late-loading of sidebar ads, the
                 # button is rerendered after sidebar ads appear & the autoplay
                 # pref resets to "on". In other words, if you click too early,
                 # the pref might get reset moments later.
--- a/dom/media/test/external/external_media_tests/playback/test_full_playback.py
+++ b/dom/media/test/external/external_media_tests/playback/test_full_playback.py
@@ -1,24 +1,25 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 
+from marionette import Marionette
 from external_media_harness.testcase import MediaTestCase
 from external_media_tests.media_utils.video_puppeteer import VideoPuppeteer
 
 
 class TestFullPlayback(MediaTestCase):
     """ Test MSE playback in HTML5 video element.
 
     These tests should pass on any site where a single video element plays
     upon loading and is uninterrupted (by ads, for example). This will play
     the full videos, so it could take a while depending on the videos playing.
     It should be run much less frequently in automated systems.
     """
 
     def test_video_playback_full(self):
-        with self.marionette.using_context('content'):
+        with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
             for url in self.video_urls:
                 video = VideoPuppeteer(self.marionette, url,
                                        stall_wait_time=10)
                 self.run_playback(video)
--- a/dom/media/test/external/external_media_tests/playback/test_shaka_playback.py
+++ b/dom/media/test/external/external_media_tests/playback/test_shaka_playback.py
@@ -1,13 +1,14 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 
+from marionette import Marionette
 from external_media_harness.testcase import MediaTestCase
 from external_media_tests.media_utils.video_puppeteer import VideoPuppeteer
 
 
 class TestShakaPlayback(MediaTestCase):
     """ Test Widevine playback in shaka-player
 
     This test takes manifest URLs rather than URLs for pages with videos. These
@@ -15,25 +16,26 @@ class TestShakaPlayback(MediaTestCase):
     """
 
     def test_video_playback_partial(self):
         """ Plays 60 seconds of the video from the manifest URLs given
         """
         shakaUrl = "http://shaka-player-demo.appspot.com"
         self.prefs.set_pref('media.mediasource.webm.enabled', True)
 
-        with self.marionette.using_context('content'):
+        with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
             for manifestUrl in self.video_urls:
                 vp = VideoPuppeteer(self.marionette,
                                     shakaUrl,
                                     stall_wait_time=10,
                                     set_duration=60,
                                     video_selector="video#video",
                                     autostart=False)
 
+
                 manifestInput = self.marionette.find_element("id",
                                                              "manifestUrlInput")
                 manifestInput.clear()
                 manifestInput.send_keys(manifestUrl)
                 loadButton = self.marionette.find_element("id", "loadButton")
                 loadButton.click()
 
                 vp.start()
--- a/dom/media/test/external/external_media_tests/playback/youtube/test_basic_playback.py
+++ b/dom/media/test/external/external_media_tests/playback/youtube/test_basic_playback.py
@@ -1,39 +1,40 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
+from marionette import Marionette
 from marionette_driver import Wait
 from marionette_driver.errors import TimeoutException
 
 from external_media_tests.utils import verbose_until
 from external_media_harness.testcase import MediaTestCase
 from external_media_tests.media_utils.video_puppeteer import VideoException
 from external_media_tests.media_utils.youtube_puppeteer import (YouTubePuppeteer, playback_done,
                                            wait_for_almost_done)
 
 
 class TestBasicYouTubePlayback(MediaTestCase):
     def test_mse_is_enabled_by_default(self):
-        with self.marionette.using_context('content'):
+        with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
             youtube = YouTubePuppeteer(self.marionette, self.video_urls[0],
                                        timeout=60)
             wait = Wait(youtube,
                         timeout=min(300, youtube.expected_duration * 1.3),
                         interval=1)
             try:
                 verbose_until(wait, youtube,
                               lambda y: y.video_src.startswith('mediasource'),
                               "Failed to find 'mediasource' in video src url.")
             except TimeoutException as e:
                 raise self.failureException(e)
 
     def test_video_playing_in_one_tab(self):
-        with self.marionette.using_context('content'):
+        with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
             for url in self.video_urls:
                 self.logger.info(url)
                 youtube = YouTubePuppeteer(self.marionette, url)
                 self.logger.info('Expected duration: %s' %
                                  youtube.expected_duration)
                 youtube.deactivate_autoplay()
 
                 final_piece = 60
@@ -60,14 +61,14 @@ class TestBasicYouTubePlayback(MediaTest
                                        timeout=max(100, time_left) * 1.3,
                                        interval=1),
                                   youtube,
                                   playback_done)
                 except TimeoutException as e:
                     raise self.failureException(e)
 
     def test_playback_starts(self):
-        with self.marionette.using_context('content'):
+        with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
             for url in self.video_urls:
                 try:
                     YouTubePuppeteer(self.marionette, url, timeout=60)
                 except TimeoutException as e:
                     raise self.failureException(e)
--- a/dom/media/test/external/external_media_tests/test_example.py
+++ b/dom/media/test/external/external_media_tests/test_example.py
@@ -1,8 +1,9 @@
+from marionette import Marionette
 from external_media_harness.testcase import MediaTestCase
 
 
 class TestSomethingElse(MediaTestCase):
     def setUp(self):
         MediaTestCase.setUp(self)
         self.test_urls = [
             'mozilla.html',
@@ -10,10 +11,10 @@ class TestSomethingElse(MediaTestCase):
         self.test_urls = [self.marionette.absolute_url(t)
                           for t in self.test_urls]
 
     def tearDown(self):
         MediaTestCase.tearDown(self)
 
     def test_foo(self):
         self.logger.info('foo!')
-        with self.marionette.using_context('content'):
+        with self.marionette.using_context(Marionette.CONTEXT_CONTENT):
             self.marionette.navigate(self.test_urls[0])