Bug 1142805 - Fix remaining traces for app.update.url.override.
MozReview-Commit-ID: BJvSjqippar
--- a/testing/firefox-ui/harness/firefox_ui_harness/testcases.py
+++ b/testing/firefox-ui/harness/firefox_ui_harness/testcases.py
@@ -377,18 +377,17 @@ class UpdateTestCase(PuppeteerMixin, Mar
self.logger.error('Failed to reset the default mar channels.',
exc_info=True)
def set_preferences_defaults(self):
"""Set the default value for specific preferences to force its usage."""
if self.update_channel:
self.software_update.update_channel = self.update_channel
if self.update_url:
- self.puppeteer.prefs.set_pref("app.update.url", self.update_url,
- default_branch=True)
+ self.software_update.update_url = self.update_url
def wait_for_download_finished(self, window, timeout=TIMEOUT_UPDATE_DOWNLOAD):
""" Waits until download is completed.
:param window: Instance of :class:`AboutWindow` or :class:`UpdateWizardDialog`.
:param timeout: How long to wait for the download to finish. Optional,
default to 360 seconds.
"""
--- a/testing/firefox-ui/tests/puppeteer/test_software_update.py
+++ b/testing/firefox-ui/tests/puppeteer/test_software_update.py
@@ -53,20 +53,20 @@ class TestSoftwareUpdate(PuppeteerMixin,
self.software_update.force_fallback()
with open(status_file, 'r') as f:
content = f.read()
self.assertEqual(content, 'failed: 6\n')
finally:
os.remove(status_file)
def test_get_update_url(self):
- update_url = self.software_update.get_update_url()
+ update_url = self.software_update.get_formatted_update_url()
self.assertIn('Firefox', update_url)
self.assertNotIn('force=1', update_url)
- update_url = self.software_update.get_update_url(True)
+ update_url = self.software_update.get_formatted_update_url(True)
self.assertIn('Firefox', update_url)
self.assertIn('force=1', update_url)
def test_os_version(self):
self.assertTrue(self.software_update.os_version)
def test_staging_directory(self):
self.assertTrue(self.software_update.staging_directory)
--- a/testing/puppeteer/firefox/firefox_puppeteer/api/software_update.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/api/software_update.py
@@ -160,17 +160,16 @@ class MARChannels(BaseLib):
class SoftwareUpdate(BaseLib):
"""The SoftwareUpdate API adds support for an easy access to the update process."""
PREF_APP_DISTRIBUTION = 'distribution.id'
PREF_APP_DISTRIBUTION_VERSION = 'distribution.version'
PREF_APP_UPDATE_CHANNEL = 'app.update.channel'
PREF_APP_UPDATE_URL = 'app.update.url'
- PREF_APP_UPDATE_URL_OVERRIDE = 'app.update.url.override'
PREF_DISABLED_ADDONS = 'extensions.disabledAddons'
def __init__(self, marionette):
BaseLib.__init__(self, marionette)
self.app_info = AppInfo(marionette)
self.prefs = Preferences(marionette)
@@ -214,17 +213,17 @@ class SoftwareUpdate(BaseLib):
""")
@property
def build_info(self):
"""Return information of the current build version
:returns: A dictionary of build information
"""
- update_url = self.get_update_url(True)
+ update_url = self.get_formatted_update_url(True)
return {
'buildid': self.app_info.appBuildID,
'channel': self.update_channel,
'disabled_addons': self.prefs.get_pref(self.PREF_DISABLED_ADDONS),
'locale': self.app_info.locale,
'mar_channels': self.mar_channels.channels,
'update_url': update_url,
@@ -326,16 +325,30 @@ class SoftwareUpdate(BaseLib):
"""Set the update channel to be used for update checks.
:param channel: New update channel to use
"""
self.prefs.set_pref(self.PREF_APP_UPDATE_CHANNEL, channel, default_branch=True)
@property
+ def update_url(self):
+ """Return the update URL used for update checks."""
+ return self.prefs.get_pref(self.PREF_APP_UPDATE_URL, default_branch=True)
+
+ @update_url.setter
+ def update_url(self, url):
+ """Set the update URL to be used for update checks.
+
+ :param url: New update URL to use
+
+ """
+ self.prefs.set_pref(self.PREF_APP_UPDATE_URL, url, default_branch=True)
+
+ @property
def update_type(self):
"""Returns the type of the active update."""
return self.active_update.type
def force_fallback(self):
"""Update the update.status file and set the status to 'failed:6'"""
with open(os.path.join(self.staging_directory, 'update.status'), 'w') as f:
f.write('failed: 6\n')
@@ -350,34 +363,29 @@ class SoftwareUpdate(BaseLib):
import urllib2
response = urllib2.urlopen(update_url)
snippet = response.read()
except Exception:
pass
return snippet
- def get_update_url(self, force=False):
- """Retrieve the AUS update URL the update snippet is retrieved from.
+ def get_formatted_update_url(self, force=False):
+ """Retrieve the formatted AUS update URL the update snippet is retrieved from.
:param force: Boolean flag to force an update check
:returns: The URL of the update snippet
"""
- url = self.prefs.get_pref(self.PREF_APP_UPDATE_URL_OVERRIDE)
- if not url:
- url = self.prefs.get_pref(self.PREF_APP_UPDATE_URL)
-
# Format the URL by replacing placeholders
url = self.marionette.execute_script("""
Components.utils.import("resource://gre/modules/UpdateUtils.jsm")
return UpdateUtils.formatUpdateURL(arguments[0]);
- """, script_args=[url])
+ """, script_args=[self.update_url])
if force:
if '?' in url:
url += '&'
else:
url += '?'
url += 'force=1'
return url
-