Bug 1316687 - Make use of the default value for "app.update.url" because "app.update.url.override" was removed.
MozReview-Commit-ID: CbsDNExDtct
--- a/testing/firefox-ui/harness/firefox_ui_harness/arguments/update.py
+++ b/testing/firefox-ui/harness/firefox_ui_harness/arguments/update.py
@@ -13,44 +13,38 @@ class UpdateBaseArguments(object):
'default': [],
'action': 'append',
'metavar': 'MAR_CHANNEL',
'help': 'Additional MAR channel to be allowed for updates, '
'e.g. "firefox-mozilla-beta" for updating a release '
'build to the latest beta build.'
}],
[['--update-channel'], {
- 'dest': 'update_channel',
'metavar': 'CHANNEL',
'help': 'Channel to use for the update check.'
}],
[['--update-direct-only'], {
- 'dest': 'update_direct_only',
'default': False,
'action': 'store_true',
'help': 'Only perform a direct update'
}],
[['--update-fallback-only'], {
- 'dest': 'update_fallback_only',
'default': False,
'action': 'store_true',
'help': 'Only perform a fallback update'
}],
- [['--update-override-url'], {
- 'dest': 'update_override_url',
+ [['--update-url'], {
'metavar': 'URL',
'help': 'Force specified URL to use for update checks.'
}],
[['--update-target-version'], {
- 'dest': 'update_target_version',
'metavar': 'VERSION',
'help': 'Version of the updated build.'
}],
[['--update-target-buildid'], {
- 'dest': 'update_target_buildid',
'metavar': 'BUILD_ID',
'help': 'Build ID of the updated build.'
}],
]
def verify_usage_handler(self, args):
if args.update_direct_only and args.update_fallback_only:
raise ValueError('Arguments --update-direct-only and --update-fallback-only '
--- a/testing/firefox-ui/harness/firefox_ui_harness/runners/update.py
+++ b/testing/firefox-ui/harness/firefox_ui_harness/runners/update.py
@@ -21,21 +21,16 @@ class UpdateTestRunner(FirefoxUITestRunn
def __init__(self, **kwargs):
super(UpdateTestRunner, self).__init__(**kwargs)
self.original_bin = self.bin
self.prefs.update(DEFAULT_PREFS)
- # In case of overriding the update URL, set the appropriate preference
- override_url = kwargs.pop('update_override_url', None)
- if override_url:
- self.prefs.update({'app.update.url.override': override_url})
-
self.run_direct_update = not kwargs.pop('update_fallback_only', False)
self.run_fallback_update = not kwargs.pop('update_direct_only', False)
self.test_handlers = [UpdateTestCase]
def run_tests(self, tests):
# Used to store the last occurred exception because we execute
# run_tests() multiple times
--- a/testing/firefox-ui/harness/firefox_ui_harness/testcases.py
+++ b/testing/firefox-ui/harness/firefox_ui_harness/testcases.py
@@ -31,16 +31,18 @@ class UpdateTestCase(PuppeteerMixin, Mar
# raised. See:
# http://mxr.mozilla.org/mozilla-central/source/toolkit/mozapps/update/nsUpdateService.js?rev=a9240b1eb2fb#4813
# http://mxr.mozilla.org/mozilla-central/source/toolkit/mozapps/update/nsUpdateService.js?rev=a9240b1eb2fb#4756
PREF_APP_UPDATE_ALTWINDOWTYPE = 'app.update.altwindowtype'
def __init__(self, *args, **kwargs):
super(UpdateTestCase, self).__init__(*args, **kwargs)
+ self.update_url = kwargs.pop('update_url')
+
self.target_buildid = kwargs.pop('update_target_buildid')
self.target_version = kwargs.pop('update_target_version')
self.update_channel = kwargs.pop('update_channel')
self.default_update_channel = None
self.update_mar_channels = set(kwargs.pop('update_mar_channels'))
self.default_mar_channels = None
@@ -54,16 +56,18 @@ class UpdateTestCase(PuppeteerMixin, Mar
self.download_duration = None
# Bug 604364 - Preparation to test multiple update steps
self.current_update_index = 0
# Ensure that there exists no already partially downloaded update
self.remove_downloaded_update()
+ self.set_preferences_defaults()
+
# If requested modify the default update channel. It will be active
# after the next restart of the application
# Bug 1142805 - Modify file via Python directly
if self.update_channel:
# Backup the original content and the path of the channel-prefs.js file
self.default_update_channel = {
'content': self.software_update.update_channel.file_contents,
'path': self.software_update.update_channel.file_path,
@@ -365,16 +369,23 @@ class UpdateTestCase(PuppeteerMixin, Mar
"""Remove an already downloaded update from the update staging directory.
Hereby not only remove the update subdir but everything below 'updates'.
"""
path = os.path.dirname(self.software_update.staging_directory)
self.logger.info('Clean-up update staging directory: {}'.format(path))
mozfile.remove(path)
+ def restart(self, *args, **kwargs):
+ super(UpdateTestCase, self).restart(*args, **kwargs)
+
+ # After a restart default preference values as set in the former session are lost.
+ # Make sure that any of those are getting restored.
+ self.set_preferences_defaults()
+
def restore_config_files(self):
# Reset channel-prefs.js file if modified
try:
if self.default_update_channel:
path = self.default_update_channel['path']
self.logger.info('Restoring channel defaults for: {}'.format(path))
with open(path, 'w') as f:
f.write(self.default_update_channel['content'])
@@ -388,16 +399,22 @@ class UpdateTestCase(PuppeteerMixin, Mar
path = self.default_mar_channels['path']
self.logger.info('Restoring mar channel defaults for: {}'.format(path))
with open(path, 'w') as f:
f.write(self.default_mar_channels['content'])
except IOError:
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_url:
+ self.puppeteer.prefs.set_pref("app.update.url", self.update_url,
+ default_branch=True)
+
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.
"""
# The old update wizard dialog has to be handled differently. It's necessary