Bug 1451159 - [testing/profiles] Use 'format' for interpolation instead of %s r=gbrown
☠☠ backed out by baf0ff2fb10e ☠ ☠
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Fri, 20 Apr 2018 11:03:38 -0400
changeset 472915 f90a996823820e36e1ba66a48afb5c5c5db1e88d
parent 472914 3914937893dee9b5370128bddfa41d4f3627d8db
child 472916 72926ae685af24250b0b65fdfac4e3cace9f2a90
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgbrown
bugs1451159
milestone61.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 1451159 - [testing/profiles] Use 'format' for interpolation instead of %s r=gbrown MozReview-Commit-ID: EbDS1fYDe1X
build/pgo/profileserver.py
build/valgrind/mach_commands.py
testing/mochitest/runjunit.py
testing/mochitest/runtests.py
testing/profiles/common/user.js
--- a/build/pgo/profileserver.py
+++ b/build/pgo/profileserver.py
@@ -49,17 +49,17 @@ if __name__ == '__main__':
             build.topsrcdir, "build", "pgo", "prefs_override.js")
 
         prefs = {}
         prefs.update(Preferences.read_prefs(prefpath))
         prefs.update(Preferences.read_prefs(overridepath))
 
         interpolation = {"server": "%s:%d" % httpd.httpd.server_address,
                          "OOP": "false"}
-        prefs = json.loads(json.dumps(prefs) % interpolation)
+        prefs = json.loads(json.dumps(prefs).format(**interpolation))
         for pref in prefs:
             prefs[pref] = Preferences.cast(prefs[pref])
 
         profile = FirefoxProfile(profile=profilePath,
                                  preferences=prefs,
                                  addons=[os.path.join(
                                      build.topsrcdir, 'tools', 'quitter', 'quitter@mozilla.org.xpi')],
                                  locations=locations)
--- a/build/valgrind/mach_commands.py
+++ b/build/valgrind/mach_commands.py
@@ -65,17 +65,17 @@ class MachCommands(MachCommandBase):
 
         with TemporaryDirectory() as profilePath:
             #TODO: refactor this into mozprofile
             prefpath = os.path.join(self.topsrcdir, 'testing', 'profiles', 'common', 'user.js')
             prefs = {}
             prefs.update(Preferences.read_prefs(prefpath))
             interpolation = { 'server': '%s:%d' % httpd.httpd.server_address,
                               'OOP': 'false'}
-            prefs = json.loads(json.dumps(prefs) % interpolation)
+            prefs = json.loads(json.dumps(prefs).format(**interpolation))
             for pref in prefs:
                 prefs[pref] = Preferences.cast(prefs[pref])
 
             quitter = os.path.join(self.topsrcdir, 'tools', 'quitter', 'quitter@mozilla.org.xpi')
 
             locations = ServerLocations()
             locations.add_host(host='127.0.0.1',
                                port=httpd.httpd.server_port,
--- a/testing/mochitest/runjunit.py
+++ b/testing/mochitest/runjunit.py
@@ -103,17 +103,17 @@ class JUnitTestRunner(MochitestDesktop):
         prefs = {}
         for path in preferences:
             prefs.update(Preferences.read_prefs(path))
 
         interpolation = {
             "server": "%s:%s" %
             (self.options.webServer, self.options.httpPort)}
 
-        prefs = json.loads(json.dumps(prefs) % interpolation)
+        prefs = json.loads(json.dumps(prefs).format(**interpolation))
         for pref in prefs:
             prefs[pref] = Preferences.cast(prefs[pref])
 
         proxy = {'remote': self.options.webServer,
                  'http': self.options.httpPort,
                  'https': self.options.sslPort,
                  'ws': self.options.sslPort
                  }
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -47,16 +47,17 @@ from manifestparser import TestManifest
 from manifestparser.filters import (
     chunk_by_dir,
     chunk_by_runtime,
     chunk_by_slice,
     pathprefix,
     subsuite,
     tags,
 )
+from six import string_types
 
 try:
     from marionette_driver.addons import Addons
     from marionette_harness import Marionette
 except ImportError as e:
     # Defer ImportError until attempt to use Marionette
     def reraise(*args, **kwargs):
         raise(e)
@@ -1879,18 +1880,19 @@ toolbar#nav-bar {
             sandbox_whitelist_paths = map(lambda p: os.path.join(p, ""),
                                           sandbox_whitelist_paths)
 
         # interpolate preferences
         interpolation = {
             "server": "%s:%s" %
             (options.webServer, options.httpPort)}
 
-        prefs = json.loads(json.dumps(prefs) % interpolation)
         for pref in prefs:
+            if isinstance(prefs[pref], string_types):
+                prefs[pref] = prefs[pref].format(**interpolation)
             prefs[pref] = Preferences.cast(prefs[pref])
         # TODO: make this less hacky
         # https://bugzilla.mozilla.org/show_bug.cgi?id=913152
 
         # proxy
         # use SSL port for legacy compatibility; see
         # - https://bugzilla.mozilla.org/show_bug.cgi?id=688667#c66
         # - https://bugzilla.mozilla.org/show_bug.cgi?id=899221
--- a/testing/profiles/common/user.js
+++ b/testing/profiles/common/user.js
@@ -54,19 +54,19 @@ user_pref("media.volume_scale", "0.01");
 user_pref("media.test.dumpDebugInfo", true);
 user_pref("media.dormant-on-pause-timeout-ms", 0); // Enter dormant immediately without waiting for timeout.
 user_pref("media.suspend-bkgnd-video.enabled", false);
 user_pref("security.warn_viewing_mixed", false);
 user_pref("app.update.enabled", false);
 user_pref("app.update.staging.enabled", false);
 user_pref("app.update.url.android", "");
 // Make sure GMPInstallManager won't hit the network.
-user_pref("media.gmp-manager.url.override", "http://%(server)s/dummy-gmp-manager.xml");
+user_pref("media.gmp-manager.url.override", "http://{server}/dummy-gmp-manager.xml");
 user_pref("media.gmp-manager.updateEnabled", false);
-user_pref("media.hls.server.url", "http://%(server)s/tests/dom/media/test/hls");
+user_pref("media.hls.server.url", "http://{server}/tests/dom/media/test/hls");
 user_pref("dom.w3c_touch_events.enabled", 1);
 user_pref("layout.accessiblecaret.enabled_on_touch", false);
 user_pref("dom.webcomponents.shadowdom.enabled", false);
 user_pref("dom.webcomponents.customelements.enabled", true);
 // Existing tests assume there is no font size inflation.
 user_pref("font.size.inflation.emPerLine", 0);
 user_pref("font.size.inflation.minTwips", 0);
 // Disable the caret blinking so we get stable snapshot
@@ -84,85 +84,85 @@ user_pref("extensions.autoDisableScopes"
 user_pref("extensions.getAddons.cache.enabled", false);
 // Disable intalling any distribution add-ons
 user_pref("extensions.installDistroAddons", false);
 // XPI extensions are required for test harnesses to load
 user_pref("extensions.defaultProviders.enabled", true);
 user_pref("xpinstall.signatures.required", false);
 user_pref("extensions.legacy.enabled", true);
 
-user_pref("geo.wifi.uri", "http://%(server)s/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs");
+user_pref("geo.wifi.uri", "http://{server}/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs");
 user_pref("geo.wifi.timeToWaitBeforeSending", 2000);
 user_pref("geo.wifi.scan", false);
 user_pref("geo.wifi.logging.enabled", true);
 
 // Prevent connection to the push server for tests.
 user_pref("dom.push.connection.enabled", false);
 
 // Point the url-classifier to the local testing server for fast failures
-user_pref("browser.safebrowsing.downloads.remote.url", "http://%(server)s/safebrowsing-dummy/update");
-user_pref("browser.safebrowsing.provider.google.gethashURL", "http://%(server)s/safebrowsing-dummy/gethash");
-user_pref("browser.safebrowsing.provider.google.updateURL", "http://%(server)s/safebrowsing-dummy/update");
-user_pref("browser.safebrowsing.provider.google4.gethashURL", "http://%(server)s/safebrowsing4-dummy/gethash");
-user_pref("browser.safebrowsing.provider.google4.updateURL", "http://%(server)s/safebrowsing4-dummy/update");
-user_pref("browser.safebrowsing.provider.mozilla.gethashURL", "http://%(server)s/safebrowsing-dummy/gethash");
-user_pref("browser.safebrowsing.provider.mozilla.updateURL", "http://%(server)s/safebrowsing-dummy/update");
-user_pref("privacy.trackingprotection.introURL", "http://%(server)s/trackingprotection/tour");
+user_pref("browser.safebrowsing.downloads.remote.url", "http://{server}/safebrowsing-dummy/update");
+user_pref("browser.safebrowsing.provider.google.gethashURL", "http://{server}/safebrowsing-dummy/gethash");
+user_pref("browser.safebrowsing.provider.google.updateURL", "http://{server}/safebrowsing-dummy/update");
+user_pref("browser.safebrowsing.provider.google4.gethashURL", "http://{server}/safebrowsing4-dummy/gethash");
+user_pref("browser.safebrowsing.provider.google4.updateURL", "http://{server}/safebrowsing4-dummy/update");
+user_pref("browser.safebrowsing.provider.mozilla.gethashURL", "http://{server}/safebrowsing-dummy/gethash");
+user_pref("browser.safebrowsing.provider.mozilla.updateURL", "http://{server}/safebrowsing-dummy/update");
+user_pref("privacy.trackingprotection.introURL", "http://{server}/trackingprotection/tour");
 // Point update checks to the local testing server for fast failures
-user_pref("extensions.update.url", "http://%(server)s/extensions-dummy/updateURL");
-user_pref("extensions.update.background.url", "http://%(server)s/extensions-dummy/updateBackgroundURL");
-user_pref("extensions.blocklist.detailsURL", "http://%(server)s/extensions-dummy/blocklistDetailsURL");
-user_pref("extensions.blocklist.itemURL", "http://%(server)s/extensions-dummy/blocklistItemURL");
-user_pref("extensions.blocklist.url", "http://%(server)s/extensions-dummy/blocklistURL");
-user_pref("extensions.hotfix.url", "http://%(server)s/extensions-dummy/hotfixURL");
-user_pref("extensions.systemAddon.update.url", "http://%(server)s/dummy-system-addons.xml");
+user_pref("extensions.update.url", "http://{server}/extensions-dummy/updateURL");
+user_pref("extensions.update.background.url", "http://{server}/extensions-dummy/updateBackgroundURL");
+user_pref("extensions.blocklist.detailsURL", "http://{server}/extensions-dummy/blocklistDetailsURL");
+user_pref("extensions.blocklist.itemURL", "http://{server}/extensions-dummy/blocklistItemURL");
+user_pref("extensions.blocklist.url", "http://{server}/extensions-dummy/blocklistURL");
+user_pref("extensions.hotfix.url", "http://{server}/extensions-dummy/hotfixURL");
+user_pref("extensions.systemAddon.update.url", "http://{server}/dummy-system-addons.xml");
 // Turn off extension updates so they don't bother tests
 user_pref("extensions.update.enabled", false);
 // Make sure opening about:addons won't hit the network
-user_pref("extensions.webservice.discoverURL", "http://%(server)s/extensions-dummy/discoveryURL");
+user_pref("extensions.webservice.discoverURL", "http://{server}/extensions-dummy/discoveryURL");
 // Make sure AddonRepository won't hit the network
-user_pref("extensions.getAddons.get.url", "http://%(server)s/extensions-dummy/repositoryGetURL");
-user_pref("extensions.getAddons.getWithPerformance.url", "http://%(server)s/extensions-dummy/repositoryGetWithPerformanceURL");
-user_pref("extensions.getAddons.search.browseURL", "http://%(server)s/extensions-dummy/repositoryBrowseURL");
+user_pref("extensions.getAddons.get.url", "http://{server}/extensions-dummy/repositoryGetURL");
+user_pref("extensions.getAddons.getWithPerformance.url", "http://{server}/extensions-dummy/repositoryGetWithPerformanceURL");
+user_pref("extensions.getAddons.search.browseURL", "http://{server}/extensions-dummy/repositoryBrowseURL");
 // Ensure blocklist updates don't hit the network
-user_pref("services.settings.server", "http://%(server)s/dummy-kinto/v1");
+user_pref("services.settings.server", "http://{server}/dummy-kinto/v1");
 // Make sure SNTP requests don't hit the network
-user_pref("network.sntp.pools", "%(server)s");
+user_pref("network.sntp.pools", "{server}");
 // We know the SNTP request will fail, since localhost isn't listening on
 // port 135. The default number of retries (10) is excessive, but retrying
 // at least once will mean that codepath is still tested in automation.
 user_pref("network.sntp.maxRetryCount", 1);
 
 // Make sure the notification permission migration test doesn't hit the network.
-user_pref("app.support.baseURL", "http://%(server)s/support-dummy/");
+user_pref("app.support.baseURL", "http://{server}/support-dummy/");
 
 // Existing tests don't wait for the notification button security delay
 user_pref("security.notification_enable_delay", 0);
 
 // Make enablePrivilege continue to work for test code. :-(
 user_pref("security.turn_off_all_security_so_that_viruses_can_take_over_this_computer", true);
 
 // In the default configuration, we bypass XBL scopes (a security feature) for
 // domains whitelisted for remote XUL, so that intranet apps and such continue
 // to work without major rewrites. However, we also use the whitelist mechanism
 // to run our XBL tests in automation, in which case we really want to be testing
 // the configuration that we ship to users without special whitelisting. So we
 // use an additional pref here to allow automation to use the "normal" behavior.
 user_pref("dom.use_xbl_scopes_for_remote_xul", true);
 
-user_pref("captivedetect.canonicalURL", "http://%(server)s/captive-detect/success.txt");
+user_pref("captivedetect.canonicalURL", "http://{server}/captive-detect/success.txt");
 
 // We do not wish to display datareporting policy notifications as it might
 // cause other tests to fail. Tests that wish to test the notification functionality
 // should explicitly disable this pref.
 user_pref("datareporting.policy.dataSubmissionPolicyBypassNotification", true);
 
 // Point Firefox Health Report at a local server. We don't care if it actually
 // works. It just can't hit the default production endpoint.
-user_pref("datareporting.healthreport.documentServerURI", "http://%(server)s/healthreport/");
+user_pref("datareporting.healthreport.documentServerURI", "http://{server}/healthreport/");
 
 // Make sure CSS error reporting is enabled for tests
 user_pref("layout.css.report_errors", true);
 
 // Enable CSS Grid 'subgrid' feature for testing
 user_pref("layout.css.grid-template-subgrid-value.enabled", true);
 
 // Enable CSS 'contain' for testing
@@ -208,34 +208,34 @@ user_pref("browser.webapps.testing", tru
 
 // Disable android snippets
 user_pref("browser.snippets.enabled", false);
 user_pref("browser.snippets.syncPromo.enabled", false);
 user_pref("browser.snippets.firstrunHomepage.enabled", false);
 
 // Disable useragent updates.
 user_pref("general.useragent.updates.enabled", false);
-user_pref("general.useragent.updates.url", "https://example.com/0/%%APP_ID%%");
+user_pref("general.useragent.updates.url", "https://example.com/0/%APP_ID%");
 
 // Disable webapp updates.  Yes, it is supposed to be an integer.
 user_pref("browser.webapps.checkForUpdates", 0);
 
 user_pref("dom.presentation.testing.simulate-receiver", false);
 
 // Don't connect to Yahoo! for RSS feed tests.
 // en-US only uses .types.0.uri, but set all of them just to be sure.
-user_pref("browser.contentHandlers.types.0.uri", "http://test1.example.org/rss?url=%%s");
-user_pref("browser.contentHandlers.types.1.uri", "http://test1.example.org/rss?url=%%s");
-user_pref("browser.contentHandlers.types.2.uri", "http://test1.example.org/rss?url=%%s");
-user_pref("browser.contentHandlers.types.3.uri", "http://test1.example.org/rss?url=%%s");
-user_pref("browser.contentHandlers.types.4.uri", "http://test1.example.org/rss?url=%%s");
-user_pref("browser.contentHandlers.types.5.uri", "http://test1.example.org/rss?url=%%s");
+user_pref("browser.contentHandlers.types.0.uri", "http://test1.example.org/rss?url=%s");
+user_pref("browser.contentHandlers.types.1.uri", "http://test1.example.org/rss?url=%s");
+user_pref("browser.contentHandlers.types.2.uri", "http://test1.example.org/rss?url=%s");
+user_pref("browser.contentHandlers.types.3.uri", "http://test1.example.org/rss?url=%s");
+user_pref("browser.contentHandlers.types.4.uri", "http://test1.example.org/rss?url=%s");
+user_pref("browser.contentHandlers.types.5.uri", "http://test1.example.org/rss?url=%s");
 
 // We want to collect telemetry, but we don't want to send in the results.
-user_pref("toolkit.telemetry.server", "https://%(server)s/telemetry-dummy/");
+user_pref("toolkit.telemetry.server", "https://{server}/telemetry-dummy/");
 user_pref("datareporting.healthreport.uploadEnabled", false);
 // Don't send 'new-profile' ping on new profiles during tests, otherwise the testing framework
 // might wait on the pingsender to finish and slow down tests.
 user_pref("toolkit.telemetry.newProfilePing.enabled", false);
 // Don't send 'bhr' ping during tests, otherwise the testing framework might
 // wait on the pingsender to finish and slow down tests.
 user_pref("toolkit.telemetry.bhrPing.enabled", false);
 // Don't send the 'shutdown' ping using the pingsender on the first session using
@@ -251,51 +251,51 @@ user_pref("toolkit.telemetry.firstShutdo
 // A couple of preferences with default values to test that telemetry preference
 // watching is working.
 user_pref("toolkit.telemetry.test.pref1", true);
 user_pref("toolkit.telemetry.test.pref2", false);
 
 // We don't want to hit the real Firefox Accounts server for tests.  We don't
 // actually need a functioning FxA server, so just set it to something that
 // resolves and accepts requests, even if they all fail.
-user_pref("identity.fxaccounts.auth.uri", "https://%(server)s/fxa-dummy/");
+user_pref("identity.fxaccounts.auth.uri", "https://{server}/fxa-dummy/");
 
 // Ditto for all the FxA content root URI.
-user_pref("identity.fxaccounts.remote.root", "https://%(server)s/");
+user_pref("identity.fxaccounts.remote.root", "https://{server}/");
 
 // Increase the APZ content response timeout in tests to 1 minute.
 // This is to accommodate the fact that test environments tends to be slower
 // than production environments (with the b2g emulator being the slowest of them
 // all), resulting in the production timeout value sometimes being exceeded
 // and causing false-positive test failures. See bug 1176798, bug 1177018,
 // bug 1210465.
 user_pref("apz.content_response_timeout", 60000);
 
 // Make sure SSL Error reports don't hit the network
 user_pref("security.ssl.errorReporting.url", "https://example.com/browser/browser/base/content/test/general/ssl_error_reports.sjs?succeed");
 
 // Make sure Translation won't hit the network.
-user_pref("browser.translation.bing.authURL", "http://%(server)s/browser/browser/components/translation/test/bing.sjs");
-user_pref("browser.translation.bing.translateArrayURL", "http://%(server)s/browser/browser/components/translation/test/bing.sjs");
-user_pref("browser.translation.yandex.translateURLOverride", "http://%(server)s/browser/browser/components/translation/test/yandex.sjs");
+user_pref("browser.translation.bing.authURL", "http://{server}/browser/browser/components/translation/test/bing.sjs");
+user_pref("browser.translation.bing.translateArrayURL", "http://{server}/browser/browser/components/translation/test/bing.sjs");
+user_pref("browser.translation.yandex.translateURLOverride", "http://{server}/browser/browser/components/translation/test/yandex.sjs");
 user_pref("browser.translation.engine", "bing");
 
 // Make sure we don't try to load snippets from the network.
 user_pref("browser.aboutHomeSnippets.updateUrl", "nonexistent://test");
 
 // Use an empty list of sites to avoid fetching
 user_pref("browser.newtabpage.activity-stream.default.sites", "");
 user_pref("browser.newtabpage.activity-stream.telemetry", false);
 user_pref("browser.newtabpage.activity-stream.tippyTop.service.endpoint", "");
 user_pref("browser.newtabpage.activity-stream.feeds.section.topstories", false);
 user_pref("browser.newtabpage.activity-stream.feeds.snippets", false);
 
 // Ensure UITour won't hit the network
-user_pref("browser.uitour.pinnedTabUrl", "http://%(server)s/uitour-dummy/pinnedTab");
-user_pref("browser.uitour.url", "http://%(server)s/uitour-dummy/tour");
+user_pref("browser.uitour.pinnedTabUrl", "http://{server}/uitour-dummy/pinnedTab");
+user_pref("browser.uitour.url", "http://{server}/uitour-dummy/tour");
 
 // Tell the search service we are running in the US.  This also has the desired
 // side-effect of preventing our geoip lookup.
 user_pref("browser.search.isUS", true);
 user_pref("browser.search.countryCode", "US");
 // This will prevent HTTP requests for region defaults.
 user_pref("browser.search.geoSpecificDefaults", false);