mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1458571 - Add a script for diffing and sorting preferences, r=rwood
The main purpose of this script is to gain a view into the state of prefs between various profiles or suites. There are three commands: - show: Display prefs for the given profile or suite - diff: Display differences of prefs between two profiles or suites - sort: Sort pref files alphabetically for the given suite (this takes comments into account) This also sorts common/user.js. MozReview-Commit-ID: Bzl7w7i3glm --HG-- extra : rebase_source : a8e620d06e9a940fadc7c3c0727e5c81ac3e3dfa
This commit is contained in:
parent
970f7e41b1
commit
c15fc95f29
@ -1,223 +1,26 @@
|
||||
// Base preferences file used by most test harnesses
|
||||
/* globals user_pref */
|
||||
user_pref("browser.console.showInPanel", true);
|
||||
user_pref("browser.dom.window.dump.enabled", true);
|
||||
user_pref("browser.firstrun.show.localepicker", false);
|
||||
user_pref("browser.firstrun.show.uidiscovery", false);
|
||||
user_pref("browser.startup.page", 0); // use about:blank, not browser.startup.homepage
|
||||
user_pref("browser.search.suggest.timeout", 10000); // use a 10s suggestion timeout in tests
|
||||
user_pref("browser.ui.layout.tablet", 0); // force tablet UI off
|
||||
user_pref("browser.urlbar.speculativeConnect.enabled", false);
|
||||
user_pref("dom.allow_scripts_to_close_windows", true);
|
||||
user_pref("dom.disable_open_during_load", false);
|
||||
user_pref("dom.experimental_forms", true); // on for testing
|
||||
user_pref("dom.forms.color", true); // on for testing
|
||||
user_pref("dom.forms.datetime", true); // on for testing
|
||||
user_pref("dom.forms.datetime.others", true); // on for testing
|
||||
user_pref("dom.max_script_run_time", 0); // no slow script dialogs
|
||||
user_pref("hangmonitor.timeout", 0); // no hang monitor
|
||||
user_pref("dom.max_chrome_script_run_time", 0);
|
||||
user_pref("dom.ipc.reportProcessHangs", false); // process hang monitor
|
||||
user_pref("dom.popup_maximum", -1);
|
||||
user_pref("dom.send_after_paint_to_content", true);
|
||||
user_pref("dom.successive_dialog_time_limit", 0);
|
||||
user_pref("browser.shell.checkDefaultBrowser", false);
|
||||
user_pref("shell.checkDefaultClient", false);
|
||||
user_pref("browser.warnOnQuit", false);
|
||||
user_pref("accessibility.typeaheadfind.autostart", false);
|
||||
user_pref("findbar.highlightAll", false);
|
||||
user_pref("findbar.modalHighlight", false);
|
||||
user_pref("javascript.options.showInConsole", true);
|
||||
user_pref("devtools.browsertoolbox.panel", "jsdebugger");
|
||||
user_pref("devtools.debugger.remote-port", 6023);
|
||||
user_pref("devtools.devedition.promo.enabled", false);
|
||||
user_pref("devtools.chrome.enabled", false);
|
||||
user_pref("devtools.debugger.remote-enabled", false);
|
||||
user_pref("devtools.debugger.prompt-connection", true);
|
||||
user_pref("devtools.testing", true);
|
||||
user_pref("browser.EULA.override", true);
|
||||
user_pref("gfx.color_management.force_srgb", true);
|
||||
user_pref("gfx.logging.level", 1);
|
||||
user_pref("network.manage-offline-status", false);
|
||||
// Disable speculative connections so they aren't reported as leaking when they're hanging around.
|
||||
user_pref("network.http.speculative-parallel-limit", 0);
|
||||
user_pref("dom.min_background_timeout_value", 1000);
|
||||
user_pref("test.mousescroll", true);
|
||||
user_pref("security.default_personal_cert", "Select Automatically"); // Need to client auth test be w/o any dialogs
|
||||
user_pref("network.http.prompt-temp-redirect", false);
|
||||
user_pref("media.preload.default", 2); // default = metadata
|
||||
user_pref("media.preload.auto", 3); // auto = enough
|
||||
user_pref("media.cache_size", 1000);
|
||||
user_pref("media.memory_cache_max_size", 32);
|
||||
user_pref("media.memory_caches_combined_limit_kb", 256);
|
||||
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);
|
||||
// Make sure Shield doesn't hit the network.
|
||||
user_pref("app.normandy.api_url", "");
|
||||
// Make sure the notification permission migration test doesn't hit the network.
|
||||
user_pref("app.support.baseURL", "http://{server}/support-dummy/");
|
||||
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}/dummy-gmp-manager.xml");
|
||||
user_pref("media.gmp-manager.updateEnabled", false);
|
||||
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
|
||||
user_pref("ui.caretBlinkTime", -1);
|
||||
|
||||
// Don't allow background tabs to be zombified, otherwise for tests that
|
||||
// open additional tabs, the test harness tab itself might get unloaded.
|
||||
user_pref("browser.tabs.disableBackgroundZombification", true);
|
||||
|
||||
// Only load extensions from the application and user profile
|
||||
// AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_APPLICATION
|
||||
user_pref("extensions.enabledScopes", 5);
|
||||
user_pref("extensions.autoDisableScopes", 0);
|
||||
// Disable metadata caching for installed add-ons by default
|
||||
user_pref("extensions.getAddons.cache.enabled", false);
|
||||
// Disable intalling any distribution add-ons
|
||||
user_pref("extensions.installDistroAddons", false);
|
||||
user_pref("xpinstall.signatures.required", false);
|
||||
user_pref("extensions.legacy.enabled", true);
|
||||
|
||||
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}/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}/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}/extensions-dummy/discoveryURL");
|
||||
// Make sure AddonRepository won't hit the network
|
||||
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}/dummy-kinto/v1");
|
||||
// Make sure SNTP requests don't hit the network
|
||||
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}/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}/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}/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
|
||||
user_pref("layout.css.contain.enabled", true);
|
||||
|
||||
// Enable CSS initial-letter for testing
|
||||
user_pref("layout.css.initial-letter.enabled", true);
|
||||
|
||||
// Enable webkit prefixed CSS features for testing
|
||||
user_pref("layout.css.prefixes.webkit", true);
|
||||
|
||||
// Enable -webkit-{min|max}-device-pixel-ratio media queries for testing
|
||||
user_pref("layout.css.prefixes.device-pixel-ratio-webkit", true);
|
||||
|
||||
// Enable CSS shape-outside for testing
|
||||
user_pref("layout.css.shape-outside.enabled", true);
|
||||
|
||||
// Disable spammy layout warnings because they pollute test logs
|
||||
user_pref("layout.spammy_warnings.enabled", false);
|
||||
|
||||
// Enable Media Source Extensions for testing
|
||||
user_pref("media.mediasource.mp4.enabled", true);
|
||||
user_pref("media.mediasource.webm.enabled", true);
|
||||
|
||||
// Enable Gamepad
|
||||
user_pref("dom.gamepad.enabled", true);
|
||||
user_pref("dom.gamepad.non_standard_events.enabled", true);
|
||||
|
||||
// Always use network provider for geolocation tests
|
||||
// so we bypass the OSX dialog raised by the corelocation provider
|
||||
user_pref("geo.provider.testing", true);
|
||||
|
||||
// Background thumbnails in particular cause grief, and disabling thumbnails
|
||||
// in general can't hurt - we re-enable them when tests need them.
|
||||
user_pref("browser.pagethumbnails.capturing_disabled", true);
|
||||
|
||||
// Indicate that the download panel has been shown once so that whichever
|
||||
// download test runs first doesn't show the popup inconsistently.
|
||||
user_pref("browser.download.panel.shown", true);
|
||||
|
||||
// Enable webapps testing mode, which bypasses native installation.
|
||||
user_pref("browser.webapps.testing", true);
|
||||
|
||||
// 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%");
|
||||
|
||||
// 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);
|
||||
|
||||
// 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);
|
||||
user_pref("browser.EULA.override", true);
|
||||
// Make sure we don't try to load snippets from the network.
|
||||
user_pref("browser.aboutHomeSnippets.updateUrl", "nonexistent://test");
|
||||
// Disable Bookmark backups by default.
|
||||
user_pref("browser.bookmarks.max_backups", 0);
|
||||
user_pref("browser.console.showInPanel", true);
|
||||
// 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");
|
||||
@ -226,151 +29,287 @@ user_pref("browser.contentHandlers.types.2.uri", "http://test1.example.org/rss?u
|
||||
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}/telemetry-dummy/");
|
||||
user_pref("browser.dom.window.dump.enabled", true);
|
||||
// Indicate that the download panel has been shown once so that whichever
|
||||
// download test runs first doesn't show the popup inconsistently.
|
||||
user_pref("browser.download.panel.shown", true);
|
||||
user_pref("browser.firstrun.show.localepicker", false);
|
||||
user_pref("browser.firstrun.show.uidiscovery", false);
|
||||
// Use an empty list of sites to avoid fetching
|
||||
user_pref("browser.newtabpage.activity-stream.default.sites", "");
|
||||
user_pref("browser.newtabpage.activity-stream.feeds.section.topstories", false);
|
||||
user_pref("browser.newtabpage.activity-stream.feeds.snippets", false);
|
||||
user_pref("browser.newtabpage.activity-stream.telemetry", false);
|
||||
user_pref("browser.newtabpage.activity-stream.tippyTop.service.endpoint", "");
|
||||
// Background thumbnails in particular cause grief, and disabling thumbnails
|
||||
// in general can't hurt - we re-enable them when tests need them.
|
||||
user_pref("browser.pagethumbnails.capturing_disabled", true);
|
||||
user_pref("browser.ping-centre.production.endpoint", "");
|
||||
// Make sure PingCentre doesn't hit the network.
|
||||
user_pref("browser.ping-centre.staging.endpoint", "");
|
||||
// Point the url-classifier to the local testing server for fast failures
|
||||
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("browser.search.countryCode", "US");
|
||||
// This will prevent HTTP requests for region defaults.
|
||||
user_pref("browser.search.geoSpecificDefaults", false);
|
||||
// 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.suggest.timeout", 10000); // use a 10s suggestion timeout in tests
|
||||
user_pref("browser.shell.checkDefaultBrowser", false);
|
||||
// Disable android snippets
|
||||
user_pref("browser.snippets.enabled", false);
|
||||
user_pref("browser.snippets.firstrunHomepage.enabled", false);
|
||||
user_pref("browser.snippets.syncPromo.enabled", false);
|
||||
user_pref("browser.startup.page", 0); // use about:blank, not browser.startup.homepage
|
||||
// Don't show a delay when hiding the audio indicator during tests
|
||||
user_pref("browser.tabs.delayHidingAudioPlayingIconMS", 0);
|
||||
// Don't allow background tabs to be zombified, otherwise for tests that
|
||||
// open additional tabs, the test harness tab itself might get unloaded.
|
||||
user_pref("browser.tabs.disableBackgroundZombification", true);
|
||||
// Don't use auto-enabled e10s
|
||||
user_pref("browser.tabs.remote.autostart", false);
|
||||
// Make sure Translation won't hit the network.
|
||||
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.engine", "bing");
|
||||
user_pref("browser.translation.yandex.translateURLOverride", "http://{server}/browser/browser/components/translation/test/yandex.sjs");
|
||||
user_pref("browser.ui.layout.tablet", 0); // force tablet UI off
|
||||
// Ensure UITour won't hit the network
|
||||
user_pref("browser.uitour.pinnedTabUrl", "http://{server}/uitour-dummy/pinnedTab");
|
||||
user_pref("browser.uitour.url", "http://{server}/uitour-dummy/tour");
|
||||
user_pref("browser.urlbar.speculativeConnect.enabled", false);
|
||||
// Turn off search suggestions in the location bar so as not to trigger network
|
||||
// connections.
|
||||
user_pref("browser.urlbar.suggest.searches", false);
|
||||
user_pref("browser.urlbar.usepreloadedtopurls.enabled", false);
|
||||
// Turn off the location bar search suggestions opt-in. It interferes with
|
||||
// tests that don't expect it to be there.
|
||||
user_pref("browser.urlbar.userMadeSearchSuggestionsChoice", true);
|
||||
user_pref("browser.warnOnQuit", false);
|
||||
// Disable webapp updates. Yes, it is supposed to be an integer.
|
||||
user_pref("browser.webapps.checkForUpdates", 0);
|
||||
// Enable webapps testing mode, which bypasses native installation.
|
||||
user_pref("browser.webapps.testing", true);
|
||||
user_pref("captivedetect.canonicalURL", "http://{server}/captive-detect/success.txt");
|
||||
// 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}/healthreport/");
|
||||
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);
|
||||
// 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);
|
||||
user_pref("devtools.browsertoolbox.panel", "jsdebugger");
|
||||
user_pref("devtools.chrome.enabled", false);
|
||||
user_pref("devtools.debugger.prompt-connection", true);
|
||||
user_pref("devtools.debugger.remote-enabled", false);
|
||||
user_pref("devtools.debugger.remote-port", 6023);
|
||||
user_pref("devtools.devedition.promo.enabled", false);
|
||||
user_pref("devtools.testing", true);
|
||||
user_pref("dom.allow_scripts_to_close_windows", true);
|
||||
user_pref("dom.disable_open_during_load", false);
|
||||
user_pref("dom.experimental_forms", true); // on for testing
|
||||
user_pref("dom.forms.color", true); // on for testing
|
||||
user_pref("dom.forms.datetime", true); // on for testing
|
||||
user_pref("dom.forms.datetime.others", true); // on for testing
|
||||
// Enable Gamepad
|
||||
user_pref("dom.gamepad.enabled", true);
|
||||
user_pref("dom.gamepad.non_standard_events.enabled", true);
|
||||
user_pref("dom.ipc.reportProcessHangs", false); // process hang monitor
|
||||
// Don't forceably kill content processes after a timeout
|
||||
user_pref("dom.ipc.tabs.shutdownTimeoutSecs", 0);
|
||||
user_pref("dom.max_chrome_script_run_time", 0);
|
||||
user_pref("dom.max_script_run_time", 0); // no slow script dialogs
|
||||
user_pref("dom.min_background_timeout_value", 1000);
|
||||
user_pref("dom.popup_maximum", -1);
|
||||
user_pref("dom.presentation.testing.simulate-receiver", false);
|
||||
// Prevent connection to the push server for tests.
|
||||
user_pref("dom.push.connection.enabled", false);
|
||||
user_pref("dom.send_after_paint_to_content", true);
|
||||
user_pref("dom.successive_dialog_time_limit", 0);
|
||||
// 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("dom.w3c_touch_events.enabled", 1);
|
||||
user_pref("dom.webcomponents.customelements.enabled", true);
|
||||
user_pref("dom.webcomponents.shadowdom.enabled", false);
|
||||
user_pref("extensions.autoDisableScopes", 0);
|
||||
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");
|
||||
// XPI extensions are required for test harnesses to load
|
||||
user_pref("extensions.defaultProviders.enabled", true);
|
||||
// Only load extensions from the application and user profile
|
||||
// AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_APPLICATION
|
||||
user_pref("extensions.enabledScopes", 5);
|
||||
// Enable form autofill feature testing.
|
||||
user_pref("extensions.formautofill.available", "on");
|
||||
// Disable metadata caching for installed add-ons by default
|
||||
user_pref("extensions.getAddons.cache.enabled", false);
|
||||
// Make sure AddonRepository won't hit the network
|
||||
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");
|
||||
user_pref("extensions.hotfix.url", "http://{server}/extensions-dummy/hotfixURL");
|
||||
// Disable intalling any distribution add-ons
|
||||
user_pref("extensions.installDistroAddons", false);
|
||||
user_pref("extensions.legacy.enabled", true);
|
||||
// Disable Screenshots by default for now
|
||||
user_pref("extensions.screenshots.disabled", true);
|
||||
user_pref("extensions.systemAddon.update.url", "http://{server}/dummy-system-addons.xml");
|
||||
user_pref("extensions.update.background.url", "http://{server}/extensions-dummy/updateBackgroundURL");
|
||||
// Turn off extension updates so they don't bother tests
|
||||
user_pref("extensions.update.enabled", false);
|
||||
// Point update checks to the local testing server for fast failures
|
||||
user_pref("extensions.update.url", "http://{server}/extensions-dummy/updateURL");
|
||||
// Make sure opening about:addons won't hit the network
|
||||
user_pref("extensions.webservice.discoverURL", "http://{server}/extensions-dummy/discoveryURL");
|
||||
user_pref("findbar.highlightAll", false);
|
||||
user_pref("findbar.modalHighlight", false);
|
||||
// Existing tests assume there is no font size inflation.
|
||||
user_pref("font.size.inflation.emPerLine", 0);
|
||||
user_pref("font.size.inflation.minTwips", 0);
|
||||
// Disable useragent updates.
|
||||
user_pref("general.useragent.updates.enabled", false);
|
||||
user_pref("general.useragent.updates.url", "https://example.com/0/%APP_ID%");
|
||||
// Always use network provider for geolocation tests
|
||||
// so we bypass the OSX dialog raised by the corelocation provider
|
||||
user_pref("geo.provider.testing", true);
|
||||
user_pref("geo.wifi.logging.enabled", true);
|
||||
user_pref("geo.wifi.scan", false);
|
||||
user_pref("geo.wifi.timeToWaitBeforeSending", 2000);
|
||||
user_pref("geo.wifi.uri", "http://{server}/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs");
|
||||
user_pref("gfx.color_management.force_srgb", true);
|
||||
user_pref("gfx.logging.level", 1);
|
||||
user_pref("hangmonitor.timeout", 0); // no hang monitor
|
||||
// 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}/fxa-dummy/");
|
||||
// Ditto for all the FxA content root URI.
|
||||
user_pref("identity.fxaccounts.remote.root", "https://{server}/");
|
||||
user_pref("javascript.options.showInConsole", true);
|
||||
user_pref("layout.accessiblecaret.enabled_on_touch", false);
|
||||
// Enable CSS 'contain' for testing
|
||||
user_pref("layout.css.contain.enabled", true);
|
||||
// Enable CSS Grid 'subgrid' feature for testing
|
||||
user_pref("layout.css.grid-template-subgrid-value.enabled", true);
|
||||
// Enable CSS initial-letter for testing
|
||||
user_pref("layout.css.initial-letter.enabled", true);
|
||||
// Enable -webkit-{min|max}-device-pixel-ratio media queries for testing
|
||||
user_pref("layout.css.prefixes.device-pixel-ratio-webkit", true);
|
||||
// Enable webkit prefixed CSS features for testing
|
||||
user_pref("layout.css.prefixes.webkit", true);
|
||||
// Make sure CSS error reporting is enabled for tests
|
||||
user_pref("layout.css.report_errors", true);
|
||||
// Enable CSS shape-outside for testing
|
||||
user_pref("layout.css.shape-outside.enabled", true);
|
||||
// Disable spammy layout warnings because they pollute test logs
|
||||
user_pref("layout.spammy_warnings.enabled", false);
|
||||
// Make tests run consistently on DevEdition (which has a lightweight theme
|
||||
// selected by default).
|
||||
user_pref("lightweightThemes.selectedThemeID", "");
|
||||
// Disable all recommended Marionette preferences for Gecko tests.
|
||||
// The prefs recommended by Marionette are typically geared towards
|
||||
// consumer automation; not vendor testing.
|
||||
user_pref("marionette.prefs.recommended", false);
|
||||
user_pref("media.autoplay.enabled", true);
|
||||
user_pref("media.cache_size", 1000);
|
||||
user_pref("media.dormant-on-pause-timeout-ms", 0); // Enter dormant immediately without waiting for timeout.
|
||||
// Set the number of shmems the PChromiumCDM protocol pre-allocates to 0,
|
||||
// so that we test the case where we under-estimate how many shmems we need
|
||||
// to send decoded video frames from the CDM to Gecko.
|
||||
user_pref("media.eme.chromium-api.video-shmems", 0);
|
||||
user_pref("media.eme.enabled", true);
|
||||
user_pref("media.gmp-manager.updateEnabled", false);
|
||||
// Make sure GMPInstallManager won't hit the network.
|
||||
user_pref("media.gmp-manager.url.override", "http://{server}/dummy-gmp-manager.xml");
|
||||
user_pref("media.hls.server.url", "http://{server}/tests/dom/media/test/hls");
|
||||
// Don't block old libavcodec libraries when testing, because our test systems
|
||||
// cannot easily be upgraded.
|
||||
user_pref("media.libavcodec.allow-obsolete", true);
|
||||
// Enable Media Source Extensions for testing
|
||||
user_pref("media.mediasource.mp4.enabled", true);
|
||||
user_pref("media.mediasource.webm.enabled", true);
|
||||
user_pref("media.memory_cache_max_size", 32);
|
||||
user_pref("media.memory_caches_combined_limit_kb", 256);
|
||||
user_pref("media.openUnsupportedTypeWithExternalApp", false);
|
||||
user_pref("media.preload.auto", 3); // auto = enough
|
||||
user_pref("media.preload.default", 2); // default = metadata
|
||||
user_pref("media.suspend-bkgnd-video.enabled", false);
|
||||
user_pref("media.test.dumpDebugInfo", true);
|
||||
user_pref("media.volume_scale", "0.01");
|
||||
// Enable speech synth test service, and disable built in platform services.
|
||||
user_pref("media.webspeech.synth.test", true);
|
||||
user_pref("network.http.prompt-temp-redirect", false);
|
||||
// Disable speculative connections so they aren't reported as leaking when they're hanging around.
|
||||
user_pref("network.http.speculative-parallel-limit", 0);
|
||||
user_pref("network.manage-offline-status", false);
|
||||
// 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 SNTP requests don't hit the network
|
||||
user_pref("network.sntp.pools", "{server}");
|
||||
// Set places maintenance far in the future (the maximum time possible in an
|
||||
// int32_t) to avoid it kicking in during tests. The maintenance can take a
|
||||
// relatively long time which may cause unnecessary intermittents and slow down
|
||||
// tests. This, like many things, will stop working correctly in 2038.
|
||||
user_pref("places.database.lastMaintenance", 2147483647);
|
||||
// For Firefox 52 only, ESR will support non-Flash plugins while release will
|
||||
// not, so we keep testing the non-Flash pathways
|
||||
user_pref("plugin.load_flash_only", false);
|
||||
user_pref("privacy.trackingprotection.introURL", "http://{server}/trackingprotection/tour");
|
||||
user_pref("security.default_personal_cert", "Select Automatically"); // Need to client auth test be w/o any dialogs
|
||||
// Existing tests don't wait for the notification button security delay
|
||||
user_pref("security.notification_enable_delay", 0);
|
||||
// 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 enablePrivilege continue to work for test code. :-(
|
||||
user_pref("security.turn_off_all_security_so_that_viruses_can_take_over_this_computer", true);
|
||||
user_pref("security.warn_viewing_mixed", false);
|
||||
// Ensure blocklist updates don't hit the network
|
||||
user_pref("services.settings.server", "http://{server}/dummy-kinto/v1");
|
||||
user_pref("shell.checkDefaultClient", false);
|
||||
// Disable password capture, so that mochitests that include forms aren't
|
||||
// influenced by the presence of the persistent doorhanger notification.
|
||||
user_pref("signon.rememberSignons", false);
|
||||
user_pref("startup.homepage_welcome_url", "about:blank");
|
||||
user_pref("startup.homepage_welcome_url.additional", "");
|
||||
user_pref("test.mousescroll", true);
|
||||
// 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 'first-shutdown' during tests, otherwise tests expecting
|
||||
// main and subsession pings will fail.
|
||||
user_pref("toolkit.telemetry.firstShutdownPing.enabled", 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);
|
||||
// We want to collect telemetry, but we don't want to send in the results.
|
||||
user_pref("toolkit.telemetry.server", "https://{server}/telemetry-dummy/");
|
||||
// Don't send the 'shutdown' ping using the pingsender on the first session using
|
||||
// the 'pingsender' process. Valgrind marks the process as leaky (e.g. see bug 1364068
|
||||
// for the 'new-profile' ping) but does not provide enough information
|
||||
// to suppress the leak. Running locally does not reproduce the issue,
|
||||
// so disable this until we rewrite the pingsender in Rust (bug 1339035).
|
||||
user_pref("toolkit.telemetry.shutdownPingSender.enabledFirstSession", false);
|
||||
// Don't send the 'first-shutdown' during tests, otherwise tests expecting
|
||||
// main and subsession pings will fail.
|
||||
user_pref("toolkit.telemetry.firstShutdownPing.enabled", false);
|
||||
|
||||
// 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}/fxa-dummy/");
|
||||
|
||||
// Ditto for all the FxA content root URI.
|
||||
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}/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}/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);
|
||||
|
||||
// Make sure Shield doesn't hit the network.
|
||||
user_pref("app.normandy.api_url", "");
|
||||
|
||||
// Make sure PingCentre doesn't hit the network.
|
||||
user_pref("browser.ping-centre.staging.endpoint", "");
|
||||
user_pref("browser.ping-centre.production.endpoint", "");
|
||||
|
||||
user_pref("media.eme.enabled", true);
|
||||
|
||||
// Set the number of shmems the PChromiumCDM protocol pre-allocates to 0,
|
||||
// so that we test the case where we under-estimate how many shmems we need
|
||||
// to send decoded video frames from the CDM to Gecko.
|
||||
user_pref("media.eme.chromium-api.video-shmems", 0);
|
||||
|
||||
user_pref("media.autoplay.enabled", true);
|
||||
|
||||
// Don't use auto-enabled e10s
|
||||
user_pref("browser.tabs.remote.autostart", false);
|
||||
// Don't show a delay when hiding the audio indicator during tests
|
||||
user_pref("browser.tabs.delayHidingAudioPlayingIconMS", 0);
|
||||
// Don't forceably kill content processes after a timeout
|
||||
user_pref("dom.ipc.tabs.shutdownTimeoutSecs", 0);
|
||||
|
||||
// Make tests run consistently on DevEdition (which has a lightweight theme
|
||||
// selected by default).
|
||||
user_pref("lightweightThemes.selectedThemeID", "");
|
||||
|
||||
// Enable speech synth test service, and disable built in platform services.
|
||||
user_pref("media.webspeech.synth.test", true);
|
||||
|
||||
// Turn off search suggestions in the location bar so as not to trigger network
|
||||
// connections.
|
||||
user_pref("browser.urlbar.suggest.searches", false);
|
||||
|
||||
// Turn off the location bar search suggestions opt-in. It interferes with
|
||||
// tests that don't expect it to be there.
|
||||
user_pref("browser.urlbar.userMadeSearchSuggestionsChoice", true);
|
||||
|
||||
user_pref("browser.urlbar.usepreloadedtopurls.enabled", false);
|
||||
|
||||
// Disable the caret blinking so we get stable snapshot
|
||||
user_pref("ui.caretBlinkTime", -1);
|
||||
user_pref("webextensions.tests", true);
|
||||
user_pref("startup.homepage_welcome_url", "about:blank");
|
||||
user_pref("startup.homepage_welcome_url.additional", "");
|
||||
|
||||
// For Firefox 52 only, ESR will support non-Flash plugins while release will
|
||||
// not, so we keep testing the non-Flash pathways
|
||||
user_pref("plugin.load_flash_only", false);
|
||||
|
||||
// Don't block old libavcodec libraries when testing, because our test systems
|
||||
// cannot easily be upgraded.
|
||||
user_pref("media.libavcodec.allow-obsolete", true);
|
||||
|
||||
user_pref("media.openUnsupportedTypeWithExternalApp", false);
|
||||
|
||||
// Disable password capture, so that mochitests that include forms aren't
|
||||
// influenced by the presence of the persistent doorhanger notification.
|
||||
user_pref("signon.rememberSignons", false);
|
||||
|
||||
// Enable form autofill feature testing.
|
||||
user_pref("extensions.formautofill.available", "on");
|
||||
|
||||
// Disable all recommended Marionette preferences for Gecko tests.
|
||||
// The prefs recommended by Marionette are typically geared towards
|
||||
// consumer automation; not vendor testing.
|
||||
user_pref("marionette.prefs.recommended", false);
|
||||
|
||||
// Disable Screenshots by default for now
|
||||
user_pref("extensions.screenshots.disabled", true);
|
||||
|
||||
// Set places maintenance far in the future (the maximum time possible in an
|
||||
// int32_t) to avoid it kicking in during tests. The maintenance can take a
|
||||
// relatively long time which may cause unnecessary intermittents and slow down
|
||||
// tests. This, like many things, will stop working correctly in 2038.
|
||||
user_pref("places.database.lastMaintenance", 2147483647);
|
||||
|
||||
// Disable Bookmark backups by default.
|
||||
user_pref("browser.bookmarks.max_backups", 0);
|
||||
user_pref("xpinstall.signatures.required", false);
|
||||
|
220
testing/profiles/profile
Executable file
220
testing/profiles/profile
Executable file
@ -0,0 +1,220 @@
|
||||
#!/bin/sh
|
||||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
|
||||
# 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/.
|
||||
|
||||
# The beginning of this script is both valid shell and valid python,
|
||||
# such that the script starts with the shell and is reexecuted python
|
||||
'''which' mach > /dev/null 2>&1 && exec mach python "$0" "$@" ||
|
||||
echo "mach not found, either add it to your \$PATH or run this script via ./mach python testing/profiles/profile"; exit
|
||||
'''
|
||||
|
||||
from __future__ import absolute_import, unicode_literals, print_function
|
||||
|
||||
"""This script can be used to:
|
||||
|
||||
1) Show all preferences for a given suite
|
||||
2) Diff preferences between two suites or profiles
|
||||
3) Sort preference files alphabetically for a given profile
|
||||
|
||||
To use, either make sure that `mach` is on your $PATH, or run:
|
||||
$ ./mach python testing/profiles/profile <args>
|
||||
|
||||
For more details run:
|
||||
$ ./profile -- --help
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from argparse import ArgumentParser
|
||||
from itertools import chain
|
||||
|
||||
from mozprofile import Profile
|
||||
from mozprofile.prefs import Preferences
|
||||
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
try:
|
||||
import jsondiff
|
||||
except ImportError:
|
||||
from mozbuild.base import MozbuildObject
|
||||
build = MozbuildObject.from_environment(cwd=here)
|
||||
build.virtualenv_manager.install_pip_package("jsondiff")
|
||||
import jsondiff
|
||||
|
||||
|
||||
def read_prefs(profile, pref_files=None):
|
||||
"""Read and return all preferences set in the given profile.
|
||||
|
||||
:param profile: Profile name relative to this `here`.
|
||||
:returns: A dictionary of preferences set in the profile.
|
||||
"""
|
||||
pref_files = pref_files or Profile.preference_file_names
|
||||
prefs = {}
|
||||
for name in pref_files:
|
||||
path = os.path.join(here, profile, name)
|
||||
if not os.path.isfile(path):
|
||||
continue
|
||||
|
||||
try:
|
||||
prefs.update(Preferences.read_json(path))
|
||||
except ValueError:
|
||||
prefs.update(Preferences.read_prefs(path))
|
||||
return prefs
|
||||
|
||||
|
||||
def read(key):
|
||||
"""Read preferences relevant to either a profile or suite.
|
||||
|
||||
:param key: Can either be the name of a profile, or the name of
|
||||
a suite as defined in suites.json.
|
||||
"""
|
||||
with open(os.path.join(here, 'profiles.json'), 'r') as fh:
|
||||
profiles = json.load(fh)
|
||||
|
||||
if key in profiles:
|
||||
names = profiles[key]
|
||||
elif os.path.isdir(os.path.join(here, key)):
|
||||
names = [key]
|
||||
else:
|
||||
raise ValueError('{} is not a recognized suite or profile'.format(key))
|
||||
|
||||
prefs = {}
|
||||
for profile in names:
|
||||
prefs.update(read_prefs(profile))
|
||||
return prefs
|
||||
|
||||
|
||||
def diff(a, b):
|
||||
"""Diff two profiles or suites.
|
||||
|
||||
:param a: The first profile or suite name.
|
||||
:param b: The second profile or suite name.
|
||||
"""
|
||||
prefs_a = read(a)
|
||||
prefs_b = read(b)
|
||||
res = jsondiff.diff(prefs_a, prefs_b, syntax='symmetric')
|
||||
if not res:
|
||||
return 0
|
||||
|
||||
if isinstance(res, list) and len(res) == 2:
|
||||
res = {
|
||||
jsondiff.Symbol('delete'): res[0],
|
||||
jsondiff.Symbol('insert'): res[1],
|
||||
}
|
||||
|
||||
modified = [(k, v) for k, v in res.items() if not isinstance(k, jsondiff.Symbol)]
|
||||
if modified:
|
||||
print("modified ({} => {}):".format(a, b))
|
||||
for k, v in sorted(modified):
|
||||
del prefs_a[k]
|
||||
print(" {}: {} => {}".format(k, repr(v[0]), repr(v[1])))
|
||||
|
||||
label_map = {
|
||||
'insert': 'missing in {}'.format(a),
|
||||
'delete': 'missing in {}'.format(b),
|
||||
}
|
||||
|
||||
symbols = [(k, v) for k, v in res.items() if isinstance(k, jsondiff.Symbol)]
|
||||
for sym, value in symbols:
|
||||
prefs = []
|
||||
for k, v in value.items():
|
||||
if k in prefs_a:
|
||||
del prefs_a[k]
|
||||
prefs.append(" {}: {}".format(k, repr(v)))
|
||||
print("\n{}:\n{}".format(label_map.get(sym.label, sym.label), "\n".join(sorted(prefs))))
|
||||
|
||||
if prefs_a:
|
||||
print("\nidentical:")
|
||||
for k, v in sorted(prefs_a.items()):
|
||||
print(" {}: {}".format(k, repr(v)))
|
||||
|
||||
|
||||
def sort_file(path):
|
||||
"""Sort the given pref file alphabetically, preserving preceding comments
|
||||
that start with '//'.
|
||||
|
||||
:param path: Path to the preference file to sort.
|
||||
"""
|
||||
with open(path, 'r') as fh:
|
||||
lines = fh.readlines()
|
||||
|
||||
result = []
|
||||
buf = []
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
|
||||
if line.startswith('//'):
|
||||
buf.append(line)
|
||||
continue
|
||||
|
||||
if buf:
|
||||
result.append(buf + [line])
|
||||
buf = []
|
||||
continue
|
||||
|
||||
result.append([line])
|
||||
|
||||
result = sorted(result, key=lambda x: x[-1])
|
||||
result = chain(*result)
|
||||
|
||||
with open(path, 'w') as fh:
|
||||
fh.write('\n'.join(result))
|
||||
|
||||
|
||||
def sort(profile):
|
||||
"""Sort all prefs in the given profile alphabetically. This will preserve
|
||||
comments on preceding lines.
|
||||
|
||||
:param profile: The name of the profile to sort.
|
||||
"""
|
||||
pref_files = Profile.preference_file_names
|
||||
|
||||
for name in pref_files:
|
||||
path = os.path.join(here, profile, name)
|
||||
if os.path.isfile(path):
|
||||
sort_file(path)
|
||||
|
||||
|
||||
def show(suite):
|
||||
"""Display all prefs set in profiles used by the given suite.
|
||||
|
||||
:param suite: The name of the suite to show preferences for. This must
|
||||
be a key in suites.json.
|
||||
"""
|
||||
for k, v in sorted(read(suite).items()):
|
||||
print("{}: {}".format(k, repr(v)))
|
||||
|
||||
|
||||
def cli(args=sys.argv[1:]):
|
||||
parser = ArgumentParser()
|
||||
subparsers = parser.add_subparsers()
|
||||
|
||||
diff_parser = subparsers.add_parser('diff')
|
||||
diff_parser.add_argument('a', metavar='A',
|
||||
help="Path to the first profile or suite name to diff.")
|
||||
diff_parser.add_argument('b', metavar='B',
|
||||
help="Path to the second profile or suite name to diff.")
|
||||
diff_parser.set_defaults(func=diff)
|
||||
|
||||
sort_parser = subparsers.add_parser('sort')
|
||||
sort_parser.add_argument('profile', help="Path to profile to sort preferences.")
|
||||
sort_parser.set_defaults(func=sort)
|
||||
|
||||
show_parser = subparsers.add_parser('show')
|
||||
show_parser.add_argument('suite', help="Name of suite to show arguments for.")
|
||||
show_parser.set_defaults(func=show)
|
||||
|
||||
args = vars(parser.parse_args(args))
|
||||
func = args.pop('func')
|
||||
func(**args)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(cli())
|
Loading…
Reference in New Issue
Block a user