mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 12:20:56 +00:00
Merge m-c to autoland, a=merge
MozReview-Commit-ID: L5cEw8jWPNI
This commit is contained in:
commit
b11975d1ad
@ -6,12 +6,9 @@
|
||||
|
||||
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const prefs = new Preferences("datareporting.healthreport.");
|
||||
|
||||
const PREF_UNIFIED = "toolkit.telemetry.unified";
|
||||
const PREF_REPORTING_URL = "datareporting.healthreport.about.reportUrl";
|
||||
|
||||
var healthReportWrapper = {
|
||||
@ -19,11 +16,9 @@ var healthReportWrapper = {
|
||||
let iframe = document.getElementById("remote-report");
|
||||
iframe.addEventListener("load", healthReportWrapper.initRemotePage);
|
||||
iframe.src = this._getReportURI().spec;
|
||||
prefs.observe("uploadEnabled", this.updatePrefState, healthReportWrapper);
|
||||
},
|
||||
|
||||
uninit() {
|
||||
prefs.ignore("uploadEnabled", this.updatePrefState, healthReportWrapper);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(this, /* unused */ "_isUploadEnabled",
|
||||
"datareporting.healthreport.uploadEnabled",
|
||||
false, () => this.updatePrefState());
|
||||
},
|
||||
|
||||
_getReportURI() {
|
||||
@ -175,4 +170,3 @@ var healthReportWrapper = {
|
||||
}
|
||||
|
||||
window.addEventListener("load", function() { healthReportWrapper.init(); });
|
||||
window.addEventListener("unload", function() { healthReportWrapper.uninit(); });
|
||||
|
@ -327,7 +327,7 @@ var gXPInstallObserver = {
|
||||
let notificationElement = [...this.owner.panel.childNodes]
|
||||
.find(n => n.notification == this);
|
||||
if (notificationElement) {
|
||||
if (Preferences.get("xpinstall.customConfirmationUI", false)) {
|
||||
if (Services.prefs.getBoolPref("xpinstall.customConfirmationUI", false)) {
|
||||
notificationElement.setAttribute("mainactiondisabled", "true");
|
||||
} else {
|
||||
notificationElement.button.hidden = true;
|
||||
|
@ -12,7 +12,7 @@ var CaptivePortalWatcher = {
|
||||
* and small enough that the delay in opening a tab isn't too noticeable.
|
||||
* Please see comments for _delayedCaptivePortalDetected for more details.
|
||||
*/
|
||||
PORTAL_RECHECK_DELAY_MS: Preferences.get("captivedetect.portalRecheckDelayMS", 500),
|
||||
PORTAL_RECHECK_DELAY_MS: Services.prefs.getIntPref("captivedetect.portalRecheckDelayMS", 500),
|
||||
|
||||
// This is the value used to identify the captive portal notification.
|
||||
PORTAL_NOTIFICATION_VALUE: "captive-portal-detected",
|
||||
@ -68,6 +68,9 @@ var CaptivePortalWatcher = {
|
||||
this._delayedRecheckPending = true;
|
||||
Services.obs.addObserver(this, "browser-delayed-startup-finished");
|
||||
}
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(this, "PORTAL_RECHECK_DELAY_MS",
|
||||
"captivedetect.portalRecheckDelayMS", 500);
|
||||
},
|
||||
|
||||
uninit() {
|
||||
|
@ -4,9 +4,6 @@
|
||||
|
||||
const LOGGER_NAME = "Toolkit.Telemetry";
|
||||
const LOGGER_PREFIX = "DataNotificationInfoBar::";
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
|
||||
"resource://gre/modules/Preferences.jsm");
|
||||
/**
|
||||
* Represents an info bar that shows a data submission notification.
|
||||
*/
|
||||
@ -68,7 +65,7 @@ var gDataNotificationInfoBar = {
|
||||
this._actionTaken = true;
|
||||
// The advanced subpanes are only supported in the old organization, which will
|
||||
// be removed by bug 1349689.
|
||||
if (Preferences.get("browser.preferences.useOldOrganization")) {
|
||||
if (Services.prefs.getBoolPref("browser.preferences.useOldOrganization")) {
|
||||
window.openAdvancedPreferences("dataChoicesTab", {origin: "dataReporting"});
|
||||
} else {
|
||||
window.openPreferences("privacy-reports", {origin: "dataReporting"});
|
||||
|
@ -31,7 +31,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "gPhotonStructure",
|
||||
Deprecated:false, E10SUtils:false, ExtensionsUI: false, FormValidationHandler:false,
|
||||
GMPInstallManager:false, LightweightThemeManager:false, Log:false,
|
||||
LoginManagerParent:false, NewTabUtils:false, PageThumbs:false,
|
||||
PluralForm:false, Preferences:false, PrivateBrowsingUtils:false,
|
||||
PluralForm:false, PrivateBrowsingUtils:false,
|
||||
ProcessHangMonitor:false, PromiseUtils:false, ReaderMode:false,
|
||||
ReaderParent:false, RecentWindow:false, SafeBrowsing: false,
|
||||
SessionStore:false,
|
||||
@ -72,7 +72,6 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "gPhotonStructure",
|
||||
["PageActions", "resource:///modules/PageActions.jsm"],
|
||||
["PageThumbs", "resource://gre/modules/PageThumbs.jsm"],
|
||||
["PluralForm", "resource://gre/modules/PluralForm.jsm"],
|
||||
["Preferences", "resource://gre/modules/Preferences.jsm"],
|
||||
["PrivateBrowsingUtils", "resource://gre/modules/PrivateBrowsingUtils.jsm"],
|
||||
["ProcessHangMonitor", "resource:///modules/ProcessHangMonitor.jsm"],
|
||||
["PromiseUtils", "resource://gre/modules/PromiseUtils.jsm"],
|
||||
@ -586,7 +585,7 @@ const gStoragePressureObserver = {
|
||||
// The advanced subpanes are only supported in the old organization, which will
|
||||
// be removed by bug 1349689.
|
||||
let win = gBrowser.ownerGlobal;
|
||||
if (Preferences.get("browser.preferences.useOldOrganization")) {
|
||||
if (Services.prefs.getBoolPref("browser.preferences.useOldOrganization")) {
|
||||
win.openAdvancedPreferences("networkTab", {origin: "storagePressure"});
|
||||
} else {
|
||||
win.openPreferences("panePrivacy", {origin: "storagePressure"});
|
||||
@ -6517,7 +6516,7 @@ var OfflineApps = {
|
||||
manage() {
|
||||
// The advanced subpanes are only supported in the old organization, which will
|
||||
// be removed by bug 1349689.
|
||||
if (Preferences.get("browser.preferences.useOldOrganization")) {
|
||||
if (Services.prefs.getBoolPref("browser.preferences.useOldOrganization")) {
|
||||
openAdvancedPreferences("networkTab", {origin: "offlineApps"});
|
||||
} else {
|
||||
openPreferences("panePrivacy", {origin: "offlineApps"});
|
||||
|
@ -21,8 +21,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "TelemetryStopwatch",
|
||||
"resource://gre/modules/TelemetryStopwatch.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "console",
|
||||
"resource://gre/modules/Console.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
|
||||
"resource://gre/modules/Preferences.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "setTimeout",
|
||||
"resource://gre/modules/Timer.jsm");
|
||||
|
||||
@ -110,8 +108,8 @@ Sanitizer.prototype = {
|
||||
|
||||
// Store the list of items to clear, in case we are killed before we
|
||||
// get a chance to complete.
|
||||
Preferences.set(Sanitizer.PREF_SANITIZE_IN_PROGRESS,
|
||||
JSON.stringify(itemsToClear));
|
||||
Services.prefs.setStringPref(Sanitizer.PREF_SANITIZE_IN_PROGRESS,
|
||||
JSON.stringify(itemsToClear));
|
||||
|
||||
// Store the list of items to clear, for debugging/forensics purposes
|
||||
for (let k of itemsToClear) {
|
||||
@ -177,7 +175,7 @@ Sanitizer.prototype = {
|
||||
TelemetryStopwatch.finish("FX_SANITIZE_TOTAL", refObj);
|
||||
// Reset the inProgress preference since we were not killed during
|
||||
// sanitization.
|
||||
Preferences.reset(Sanitizer.PREF_SANITIZE_IN_PROGRESS);
|
||||
Services.prefs.clearUserPref(Sanitizer.PREF_SANITIZE_IN_PROGRESS);
|
||||
progress = {};
|
||||
if (seenError) {
|
||||
throw new Error("Error sanitizing");
|
||||
@ -807,14 +805,14 @@ Sanitizer.sanitize = function(aParentWindow) {
|
||||
Sanitizer.onStartup = async function() {
|
||||
// Check if we were interrupted during the last shutdown sanitization.
|
||||
let shutownSanitizationWasInterrupted =
|
||||
Preferences.get(Sanitizer.PREF_SANITIZE_ON_SHUTDOWN, false) &&
|
||||
!Preferences.has(Sanitizer.PREF_SANITIZE_DID_SHUTDOWN);
|
||||
Services.prefs.getBoolPref(Sanitizer.PREF_SANITIZE_ON_SHUTDOWN, false) &&
|
||||
Services.prefs.getPrefType(Sanitizer.PREF_SANITIZE_DID_SHUTDOWN) == Ci.nsIPrefBranch.PREF_INVALID;
|
||||
|
||||
if (Preferences.has(Sanitizer.PREF_SANITIZE_DID_SHUTDOWN)) {
|
||||
if (Services.prefs.prefHasUserValue(Sanitizer.PREF_SANITIZE_DID_SHUTDOWN)) {
|
||||
// Reset the pref, so that if we crash before having a chance to
|
||||
// sanitize on shutdown, we will do at the next startup.
|
||||
// Flushing prefs has a cost, so do this only if necessary.
|
||||
Preferences.reset(Sanitizer.PREF_SANITIZE_DID_SHUTDOWN);
|
||||
Services.prefs.clearUserPref(Sanitizer.PREF_SANITIZE_DID_SHUTDOWN);
|
||||
Services.prefs.savePrefFile(null);
|
||||
}
|
||||
|
||||
@ -837,7 +835,7 @@ Sanitizer.onStartup = async function() {
|
||||
);
|
||||
|
||||
// Check if Firefox crashed during a sanitization.
|
||||
let lastInterruptedSanitization = Preferences.get(Sanitizer.PREF_SANITIZE_IN_PROGRESS, "");
|
||||
let lastInterruptedSanitization = Services.prefs.getStringPref(Sanitizer.PREF_SANITIZE_IN_PROGRESS, "");
|
||||
if (lastInterruptedSanitization) {
|
||||
let s = new Sanitizer();
|
||||
// If the json is invalid this will just throw and reject the Task.
|
||||
@ -852,7 +850,7 @@ Sanitizer.onStartup = async function() {
|
||||
};
|
||||
|
||||
var sanitizeOnShutdown = async function(options = {}) {
|
||||
if (!Preferences.get(Sanitizer.PREF_SANITIZE_ON_SHUTDOWN)) {
|
||||
if (!Services.prefs.getBoolPref(Sanitizer.PREF_SANITIZE_ON_SHUTDOWN)) {
|
||||
return;
|
||||
}
|
||||
// Need to sanitize upon shutdown
|
||||
@ -861,6 +859,6 @@ var sanitizeOnShutdown = async function(options = {}) {
|
||||
await s.sanitize(null, options);
|
||||
// We didn't crash during shutdown sanitization, so annotate it to avoid
|
||||
// sanitizing again on startup.
|
||||
Preferences.set(Sanitizer.PREF_SANITIZE_DID_SHUTDOWN, true);
|
||||
Services.prefs.setBoolPref(Sanitizer.PREF_SANITIZE_DID_SHUTDOWN, true);
|
||||
Services.prefs.savePrefFile(null);
|
||||
};
|
||||
|
@ -7,16 +7,16 @@ const CHROME_BASE = "chrome://mochitests/content/browser/browser/base/content/te
|
||||
const HTTPS_BASE = "https://example.com/browser/browser/base/content/test/about/";
|
||||
|
||||
const TELEMETRY_LOG_PREF = "toolkit.telemetry.log.level";
|
||||
const telemetryOriginalLogPref = Preferences.get(TELEMETRY_LOG_PREF, null);
|
||||
const telemetryOriginalLogPref = Services.prefs.getStringPref(TELEMETRY_LOG_PREF, null);
|
||||
|
||||
const originalReportUrl = Services.prefs.getCharPref("datareporting.healthreport.about.reportUrl");
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
// Ensure we don't pollute prefs for next tests.
|
||||
if (telemetryOriginalLogPref) {
|
||||
Preferences.set(TELEMETRY_LOG_PREF, telemetryOriginalLogPref);
|
||||
Services.prefs.setStringPref(TELEMETRY_LOG_PREF, telemetryOriginalLogPref);
|
||||
} else {
|
||||
Preferences.reset(TELEMETRY_LOG_PREF);
|
||||
Services.prefs.clearUserPref(TELEMETRY_LOG_PREF);
|
||||
}
|
||||
|
||||
try {
|
||||
@ -58,10 +58,10 @@ var gTests = [
|
||||
{
|
||||
desc: "Test the remote commands",
|
||||
async setup() {
|
||||
Preferences.set(TELEMETRY_LOG_PREF, "Trace");
|
||||
Services.prefs.setStringPref(TELEMETRY_LOG_PREF, "Trace");
|
||||
await setupPingArchive();
|
||||
Preferences.set("datareporting.healthreport.about.reportUrl",
|
||||
HTTPS_BASE + "healthreport_testRemoteCommands.html");
|
||||
Services.prefs.setCharPref("datareporting.healthreport.about.reportUrl",
|
||||
HTTPS_BASE + "healthreport_testRemoteCommands.html");
|
||||
},
|
||||
run(iframe) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
@ -64,7 +64,7 @@ async function focusWindowAndWaitForPortalUI(aLongRecheck, win) {
|
||||
// so use a delay threshold of -1 to simulate a long recheck (so that any
|
||||
// amount of time is considered excessive), and a very large threshold to
|
||||
// simulate a short recheck.
|
||||
Preferences.set("captivedetect.portalRecheckDelayMS", aLongRecheck ? -1 : 1000000);
|
||||
Services.prefs.setIntPref("captivedetect.portalRecheckDelayMS", aLongRecheck ? -1 : 1000000);
|
||||
|
||||
if (!win) {
|
||||
win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
|
@ -137,7 +137,7 @@ function waitForNotificationClose() {
|
||||
}
|
||||
|
||||
async function waitForInstallDialog() {
|
||||
if (Preferences.get("xpinstall.customConfirmationUI", false)) {
|
||||
if (Services.prefs.getBoolPref("xpinstall.customConfirmationUI", false)) {
|
||||
let panel = await waitForNotification("addon-install-confirmation");
|
||||
return panel.childNodes[0];
|
||||
}
|
||||
@ -183,7 +183,7 @@ function removeTab() {
|
||||
}
|
||||
|
||||
function acceptInstallDialog(installDialog) {
|
||||
if (Preferences.get("xpinstall.customConfirmationUI", false)) {
|
||||
if (Services.prefs.getBoolPref("xpinstall.customConfirmationUI", false)) {
|
||||
installDialog.button.click();
|
||||
} else {
|
||||
let win = Services.wm.getMostRecentWindow("Addons:Install");
|
||||
@ -192,7 +192,7 @@ function acceptInstallDialog(installDialog) {
|
||||
}
|
||||
|
||||
function cancelInstallDialog(installDialog) {
|
||||
if (Preferences.get("xpinstall.customConfirmationUI", false)) {
|
||||
if (Services.prefs.getBoolPref("xpinstall.customConfirmationUI", false)) {
|
||||
installDialog.secondaryButton.click();
|
||||
} else {
|
||||
let win = Services.wm.getMostRecentWindow("Addons:Install");
|
||||
@ -446,7 +446,7 @@ async function test_sequential() {
|
||||
// This test is only relevant if using the new doorhanger UI
|
||||
// TODO: this subtest is disabled until multiple notification prompts are
|
||||
// reworked in bug 1188152
|
||||
if (true || !Preferences.get("xpinstall.customConfirmationUI", false)) {
|
||||
if (true || !Services.prefs.getBoolPref("xpinstall.customConfirmationUI", false)) {
|
||||
return;
|
||||
}
|
||||
let pm = Services.perms;
|
||||
@ -519,8 +519,8 @@ async function test_sequential() {
|
||||
async function test_allUnverified() {
|
||||
// This test is only relevant if using the new doorhanger UI and allowing
|
||||
// unsigned add-ons
|
||||
if (!Preferences.get("xpinstall.customConfirmationUI", false) ||
|
||||
Preferences.get("xpinstall.signatures.required", true) ||
|
||||
if (!Services.prefs.getBoolPref("xpinstall.customConfirmationUI", false) ||
|
||||
Services.prefs.getBoolPref("xpinstall.signatures.required", true) ||
|
||||
AppConstants.MOZ_REQUIRE_SIGNING) {
|
||||
return;
|
||||
}
|
||||
@ -620,7 +620,7 @@ async function test_localFile() {
|
||||
},
|
||||
|
||||
async function test_tabClose() {
|
||||
if (!Preferences.get("xpinstall.customConfirmationUI", false)) {
|
||||
if (!Services.prefs.getBoolPref("xpinstall.customConfirmationUI", false)) {
|
||||
info("Test skipped due to xpinstall.customConfirmationUI being false.");
|
||||
return;
|
||||
}
|
||||
@ -647,7 +647,7 @@ async function test_tabClose() {
|
||||
// Add-ons should be cancelled and the install notification destroyed when
|
||||
// navigating to a new origin
|
||||
async function test_tabNavigate() {
|
||||
if (!Preferences.get("xpinstall.customConfirmationUI", false)) {
|
||||
if (!Services.prefs.getBoolPref("xpinstall.customConfirmationUI", false)) {
|
||||
return;
|
||||
}
|
||||
let pm = Services.perms;
|
||||
|
@ -205,7 +205,7 @@ var tests = [
|
||||
// dismissal callback if privacy.permissionPrompts.showCloseButton is set.
|
||||
{ id: "Test#10",
|
||||
run() {
|
||||
Preferences.set("privacy.permissionPrompts.showCloseButton", true);
|
||||
Services.prefs.setBoolPref("privacy.permissionPrompts.showCloseButton", true);
|
||||
this.notifyObj = new BasicNotification(this.id);
|
||||
this.notification = showNotification(this.notifyObj);
|
||||
},
|
||||
@ -217,7 +217,7 @@ var tests = [
|
||||
onHidden(popup) {
|
||||
ok(!this.notifyObj.dismissalCallbackTriggered, "dismissal callback not triggered");
|
||||
ok(this.notifyObj.secondaryActionClicked, "secondary action clicked");
|
||||
Preferences.reset("privacy.permissionPrompts.showCloseButton");
|
||||
Services.prefs.clearUserPref("privacy.permissionPrompts.showCloseButton");
|
||||
this.notification.remove();
|
||||
ok(this.notifyObj.removedCallbackTriggered, "removed callback triggered");
|
||||
}
|
||||
|
@ -2454,7 +2454,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
if (downloadingCount == 0) {
|
||||
this.destroy();
|
||||
if (Preferences.get("xpinstall.customConfirmationUI", false)) {
|
||||
if (Services.prefs.getBoolPref("xpinstall.customConfirmationUI", false)) {
|
||||
this.progressmeter.setAttribute("mode", "undetermined");
|
||||
let status = gNavigatorBundle.getString("addonDownloadVerifying");
|
||||
this.progresstext.setAttribute("value", status);
|
||||
|
@ -14,7 +14,8 @@ const DISTRIBUTION_CUSTOMIZATION_COMPLETE_TOPIC =
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
|
||||
"resource://gre/modules/Preferences.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
|
||||
"resource://gre/modules/PlacesUtils.jsm");
|
||||
|
||||
|
@ -34,6 +34,7 @@ PromiseTestUtils.whitelistRejectionsGlobally(/Receiving end does not exist/);
|
||||
|
||||
const {AppConstants} = Cu.import("resource://gre/modules/AppConstants.jsm", {});
|
||||
const {CustomizableUI} = Cu.import("resource:///modules/CustomizableUI.jsm", {});
|
||||
const {Preferences} = Cu.import("resource://gre/modules/Preferences.jsm", {});
|
||||
|
||||
// We run tests under two different configurations, from browser.ini and
|
||||
// browser-remote.ini. When running from browser-remote.ini, the tests are
|
||||
|
@ -4,7 +4,6 @@ this.EXPORTED_SYMBOLS = ["NewTabPrefsProvider"];
|
||||
|
||||
const {interfaces: Ci, utils: Cu} = Components;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "EventEmitter", function() {
|
||||
@ -46,16 +45,20 @@ PrefsProvider.prototype = {
|
||||
if (gPrefsMap.has(data)) {
|
||||
switch (gPrefsMap.get(data)) {
|
||||
case "bool":
|
||||
this.emit(data, Preferences.get(data, false));
|
||||
this.emit(data, Services.prefs.getBoolPref(data, false));
|
||||
break;
|
||||
case "str":
|
||||
this.emit(data, Preferences.get(data, ""));
|
||||
this.emit(data, Services.prefs.getStringPref(data, ""));
|
||||
break;
|
||||
case "localized":
|
||||
try {
|
||||
this.emit(data, Preferences.get(data, "", Ci.nsIPrefLocalizedString));
|
||||
} catch (e) {
|
||||
this.emit(data, Preferences.get(data, ""));
|
||||
if (Services.prefs.getPrefType(data) == Ci.nsIPrefBranch.PREF_INVALID) {
|
||||
this.emit(data, "");
|
||||
} else {
|
||||
try {
|
||||
this.emit(data, Services.prefs.getComplexValue(data, Ci.nsIPrefLocalizedString));
|
||||
} catch (e) {
|
||||
this.emit(data, Services.prefs.getStringPref(data));
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -74,7 +77,25 @@ PrefsProvider.prototype = {
|
||||
get newtabPagePrefs() {
|
||||
let results = {};
|
||||
for (let pref of gNewtabPagePrefs) {
|
||||
results[pref] = Preferences.get(pref, null);
|
||||
results[pref] = null;
|
||||
|
||||
if (Services.prefs.getPrefType(pref) != Ci.nsIPrefBranch.PREF_INVALID) {
|
||||
switch (gPrefsMap.get(pref)) {
|
||||
case "bool":
|
||||
results[pref] = Services.prefs.getBoolPref(pref);
|
||||
break;
|
||||
case "str":
|
||||
results[pref] = Services.prefs.getStringPref(pref);
|
||||
break;
|
||||
case "localized":
|
||||
try {
|
||||
results[pref] = Services.prefs.getComplexValue(pref, Ci.nsIPrefLocalizedString);
|
||||
} catch (e) {
|
||||
results[pref] = Services.prefs.getStringPref(pref);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
},
|
||||
|
@ -5,7 +5,6 @@ this.EXPORTED_SYMBOLS = ["NewTabWebChannel"];
|
||||
const {utils: Cu} = Components;
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "NewTabPrefsProvider",
|
||||
"resource:///modules/NewTabPrefsProvider.jsm");
|
||||
@ -245,9 +244,9 @@ NewTabWebChannelImpl.prototype = {
|
||||
* Sets up the internal state
|
||||
*/
|
||||
setupState() {
|
||||
this._prefs.enabled = Preferences.get(PREF_ENABLED, false);
|
||||
this._prefs.enabled = Services.prefs.getBoolPref(PREF_ENABLED, false);
|
||||
|
||||
let mode = Preferences.get(PREF_MODE, "production");
|
||||
let mode = Services.prefs.getStringPref(PREF_MODE, "production");
|
||||
if (!(mode in NewTabRemoteResources.MODE_CHANNEL_MAP)) {
|
||||
mode = "production";
|
||||
}
|
||||
|
@ -10,7 +10,8 @@ const {utils: Cu, interfaces: Ci} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
|
||||
"resource://gre/modules/Preferences.jsm");
|
||||
|
||||
const LOCAL_NEWTAB_URL = "chrome://browser/content/newtab/newTab.xhtml";
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
let Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
const PREF_NEWTAB_ACTIVITY_STREAM = "browser.newtabpage.activity-stream.enabled";
|
||||
|
||||
Services.prefs.setBoolPref(PREF_NEWTAB_ACTIVITY_STREAM, false);
|
||||
|
@ -478,13 +478,10 @@ BrowserGlue.prototype = {
|
||||
// an engine, and that newly added engines are visible.
|
||||
if (data == "engine-added" || data == "engine-removed") {
|
||||
let engineName = subject.QueryInterface(Ci.nsISearchEngine).name;
|
||||
let Preferences =
|
||||
Cu.import("resource://gre/modules/Preferences.jsm", {}).Preferences;
|
||||
let pref = Preferences.get("browser.search.hiddenOneOffs");
|
||||
let pref = Services.prefs.getStringPref("browser.search.hiddenOneOffs");
|
||||
let hiddenList = pref ? pref.split(",") : [];
|
||||
hiddenList = hiddenList.filter(x => x !== engineName);
|
||||
Preferences.set("browser.search.hiddenOneOffs",
|
||||
hiddenList.join(","));
|
||||
Services.prefs.setStringPref("browser.search.hiddenOneOffs", hiddenList.join(","));
|
||||
}
|
||||
break;
|
||||
case "flash-plugin-hang":
|
||||
|
@ -18,11 +18,11 @@ server.registerPathHandler("/file.html", fileHandler);
|
||||
server.start(-1);
|
||||
|
||||
// Disable rcwn to make cache behavior deterministic.
|
||||
let rcwnEnabled = Preferences.get("network.http.rcwn.enabled");
|
||||
Preferences.set("network.http.rcwn.enabled", false);
|
||||
let rcwnEnabled = Services.prefs.getBoolPref("network.http.rcwn.enabled");
|
||||
Services.prefs.setBoolPref("network.http.rcwn.enabled", false);
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
Preferences.set("network.http.rcwn.enabled", rcwnEnabled);
|
||||
Services.prefs.setBoolPref("network.http.rcwn.enabled", rcwnEnabled);
|
||||
|
||||
server.stop(() => {
|
||||
server = null;
|
||||
|
@ -8,7 +8,6 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
|
||||
const PREF_FHR_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
|
||||
|
||||
@ -35,11 +34,11 @@ MozSelfSupportInterface.prototype = {
|
||||
},
|
||||
|
||||
get healthReportDataSubmissionEnabled() {
|
||||
return Preferences.get(PREF_FHR_UPLOAD_ENABLED, false);
|
||||
return Services.prefs.getBoolPref(PREF_FHR_UPLOAD_ENABLED, false);
|
||||
},
|
||||
|
||||
set healthReportDataSubmissionEnabled(enabled) {
|
||||
Preferences.set(PREF_FHR_UPLOAD_ENABLED, enabled);
|
||||
Services.prefs.setBoolPref(PREF_FHR_UPLOAD_ENABLED, enabled);
|
||||
},
|
||||
|
||||
resetPref(name) {
|
||||
|
@ -1,44 +1,50 @@
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
function prefHas(pref) {
|
||||
return Services.prefs.getPrefType(pref) != Ci.nsIPrefBranch.PREF_INVALID;
|
||||
}
|
||||
|
||||
function prefIsSet(pref) {
|
||||
return Services.prefs.prefHasUserValue(pref);
|
||||
}
|
||||
|
||||
function test_resetPref() {
|
||||
const prefNewName = "browser.newpref.fake";
|
||||
Assert.ok(!Preferences.has(prefNewName), "pref should not exist");
|
||||
Assert.ok(!prefHas(prefNewName), "pref should not exist");
|
||||
|
||||
const prefExistingName = "extensions.hotfix.id";
|
||||
Assert.ok(Preferences.has(prefExistingName), "pref should exist");
|
||||
Assert.ok(!Preferences.isSet(prefExistingName), "pref should not be user-set");
|
||||
let prefExistingOriginalValue = Preferences.get(prefExistingName);
|
||||
Assert.ok(prefHas(prefExistingName), "pref should exist");
|
||||
Assert.ok(!prefIsSet(prefExistingName), "pref should not be user-set");
|
||||
let prefExistingOriginalValue = Services.prefs.getStringPref(prefExistingName);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Preferences.set(prefExistingName, prefExistingOriginalValue);
|
||||
Services.prefs.setStringPref(prefExistingName, prefExistingOriginalValue);
|
||||
Services.prefs.deleteBranch(prefNewName);
|
||||
});
|
||||
|
||||
// 1. do nothing on an inexistent pref
|
||||
MozSelfSupport.resetPref(prefNewName);
|
||||
Assert.ok(!Preferences.has(prefNewName), "pref should still not exist");
|
||||
Assert.ok(!prefHas(prefNewName), "pref should still not exist");
|
||||
|
||||
// 2. creation of a new pref
|
||||
Preferences.set(prefNewName, 10);
|
||||
Assert.ok(Preferences.has(prefNewName), "pref should exist");
|
||||
Assert.equal(Preferences.get(prefNewName), 10, "pref value should be 10");
|
||||
Services.prefs.setIntPref(prefNewName, 10);
|
||||
Assert.ok(prefHas(prefNewName), "pref should exist");
|
||||
Assert.equal(Services.prefs.getIntPref(prefNewName), 10, "pref value should be 10");
|
||||
|
||||
MozSelfSupport.resetPref(prefNewName);
|
||||
Assert.ok(!Preferences.has(prefNewName), "pref should not exist any more");
|
||||
Assert.ok(!prefHas(prefNewName), "pref should not exist any more");
|
||||
|
||||
// 3. do nothing on an unchanged existing pref
|
||||
MozSelfSupport.resetPref(prefExistingName);
|
||||
Assert.ok(Preferences.has(prefExistingName), "pref should still exist");
|
||||
Assert.equal(Preferences.get(prefExistingName), prefExistingOriginalValue, "pref value should be the same as original");
|
||||
Assert.ok(prefHas(prefExistingName), "pref should still exist");
|
||||
Assert.equal(Services.prefs.getStringPref(prefExistingName), prefExistingOriginalValue, "pref value should be the same as original");
|
||||
|
||||
// 4. change the value of an existing pref
|
||||
Preferences.set(prefExistingName, "anyone@mozilla.org");
|
||||
Assert.ok(Preferences.has(prefExistingName), "pref should exist");
|
||||
Assert.equal(Preferences.get(prefExistingName), "anyone@mozilla.org", "pref value should have changed");
|
||||
Services.prefs.setStringPref(prefExistingName, "anyone@mozilla.org");
|
||||
Assert.ok(prefHas(prefExistingName), "pref should exist");
|
||||
Assert.equal(Services.prefs.getStringPref(prefExistingName), "anyone@mozilla.org", "pref value should have changed");
|
||||
|
||||
MozSelfSupport.resetPref(prefExistingName);
|
||||
Assert.ok(Preferences.has(prefExistingName), "pref should still exist");
|
||||
Assert.equal(Preferences.get(prefExistingName), prefExistingOriginalValue, "pref value should be the same as original");
|
||||
Assert.ok(prefHas(prefExistingName), "pref should still exist");
|
||||
Assert.equal(Services.prefs.getStringPref(prefExistingName), prefExistingOriginalValue, "pref value should be the same as original");
|
||||
|
||||
// 5. delete an existing pref
|
||||
// deleteBranch is implemented in such a way that
|
||||
|
@ -34,7 +34,6 @@ Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/osfile.jsm");
|
||||
Cu.import("resource://gre/modules/AsyncShutdown.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "console",
|
||||
"resource://gre/modules/Console.jsm");
|
||||
@ -303,9 +302,9 @@ var SessionFileInternal = {
|
||||
// Initialize the worker (in the background) to let it handle backups and also
|
||||
// as a workaround for bug 964531.
|
||||
let promiseInitialized = SessionWorker.post("init", [result.origin, result.useOldExtension, this.Paths, {
|
||||
maxUpgradeBackups: Preferences.get(PREF_MAX_UPGRADE_BACKUPS, 3),
|
||||
maxSerializeBack: Preferences.get(PREF_MAX_SERIALIZE_BACK, 10),
|
||||
maxSerializeForward: Preferences.get(PREF_MAX_SERIALIZE_FWD, -1)
|
||||
maxUpgradeBackups: Services.prefs.getIntPref(PREF_MAX_UPGRADE_BACKUPS, 3),
|
||||
maxSerializeBack: Services.prefs.getIntPref(PREF_MAX_SERIALIZE_BACK, 10),
|
||||
maxSerializeForward: Services.prefs.getIntPref(PREF_MAX_SERIALIZE_FWD, -1)
|
||||
}]);
|
||||
|
||||
promiseInitialized.catch(err => {
|
||||
|
@ -24,8 +24,6 @@ function debug(msg) {
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "FormData",
|
||||
"resource://gre/modules/FormData.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
|
||||
"resource://gre/modules/Preferences.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "DocShellCapabilities",
|
||||
"resource:///modules/sessionstore/DocShellCapabilities.jsm");
|
||||
@ -565,7 +563,7 @@ var SessionStorageListener = {
|
||||
|
||||
// Don't store any data if we exceed the limit. Wipe any data we previously
|
||||
// collected so that we don't confuse websites with partial state.
|
||||
if (usage > Preferences.get(DOM_STORAGE_LIMIT_PREF)) {
|
||||
if (usage > Services.prefs.getIntPref(DOM_STORAGE_LIMIT_PREF)) {
|
||||
MessageQueue.push("storage", () => null);
|
||||
return;
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
Cu.import("resource://gre/modules/TelemetryController.jsm");
|
||||
Cu.import("resource://gre/modules/Timer.jsm");
|
||||
|
||||
@ -1541,9 +1540,9 @@ this.UITour = {
|
||||
case "sync":
|
||||
this.sendPageCallback(aMessageManager, aCallbackID, {
|
||||
setup: Services.prefs.prefHasUserValue("services.sync.username"),
|
||||
desktopDevices: Preferences.get("services.sync.clients.devices.desktop", 0),
|
||||
mobileDevices: Preferences.get("services.sync.clients.devices.mobile", 0),
|
||||
totalDevices: Preferences.get("services.sync.numClients", 0),
|
||||
desktopDevices: Services.prefs.getIntPref("services.sync.clients.devices.desktop", 0),
|
||||
mobileDevices: Services.prefs.getIntPref("services.sync.clients.devices.mobile", 0),
|
||||
totalDevices: Services.prefs.getIntPref("services.sync.numClients", 0),
|
||||
});
|
||||
break;
|
||||
case "canReset":
|
||||
|
@ -14,7 +14,6 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/osfile.jsm");
|
||||
Cu.import("resource://gre/modules/Log.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
Cu.import("resource://gre/modules/AsyncShutdown.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils",
|
||||
@ -38,6 +37,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "gCrashReporter",
|
||||
|
||||
const FILE_CACHE = "experiments.json";
|
||||
const EXPERIMENTS_CHANGED_TOPIC = "experiments-changed";
|
||||
const PREF_CHANGED_TOPIC = "nsPref:changed";
|
||||
const MANIFEST_VERSION = 1;
|
||||
const CACHE_VERSION = 1;
|
||||
|
||||
@ -52,8 +52,7 @@ const PREF_LOGGING_DUMP = PREF_LOGGING + ".dump"; // experiments.logging
|
||||
const PREF_MANIFEST_URI = "manifest.uri"; // experiments.logging.manifest.uri
|
||||
const PREF_FORCE_SAMPLE = "force-sample-value"; // experiments.force-sample-value
|
||||
|
||||
const PREF_BRANCH_TELEMETRY = "toolkit.telemetry.";
|
||||
const PREF_TELEMETRY_ENABLED = "enabled";
|
||||
const PREF_TELEMETRY_ENABLED = "toolkit.telemetry.enabled";
|
||||
|
||||
const URI_EXTENSION_STRINGS = "chrome://mozapps/locale/extensions/extensions.properties";
|
||||
const STRING_TYPE_NAME = "type.%ID%.name";
|
||||
@ -92,8 +91,7 @@ const TELEMETRY_LOG = {
|
||||
};
|
||||
XPCOMUtils.defineConstant(this, "TELEMETRY_LOG", TELEMETRY_LOG);
|
||||
|
||||
const gPrefs = new Preferences(PREF_BRANCH);
|
||||
const gPrefsTelemetry = new Preferences(PREF_BRANCH_TELEMETRY);
|
||||
const gPrefs = Services.prefs.getBranch(PREF_BRANCH);
|
||||
var gExperimentsEnabled = false;
|
||||
var gAddonProvider = null;
|
||||
var gExperiments = null;
|
||||
@ -119,9 +117,9 @@ function configureLogging() {
|
||||
gLogger = Log.repository.getLogger("Browser.Experiments");
|
||||
gLogger.addAppender(new Log.ConsoleAppender(new Log.BasicFormatter()));
|
||||
}
|
||||
gLogger.level = gPrefs.get(PREF_LOGGING_LEVEL, Log.Level.Warn);
|
||||
gLogger.level = gPrefs.getIntPref(PREF_LOGGING_LEVEL, Log.Level.Warn);
|
||||
|
||||
let logDumping = gPrefs.get(PREF_LOGGING_DUMP, false);
|
||||
let logDumping = gPrefs.getBoolPref(PREF_LOGGING_DUMP, false);
|
||||
if (logDumping != gLogDumping) {
|
||||
if (logDumping) {
|
||||
gLogAppenderDump = new Log.DumpAppender(new Log.BasicFormatter());
|
||||
@ -251,7 +249,7 @@ Experiments.Policy.prototype = {
|
||||
},
|
||||
|
||||
random() {
|
||||
let pref = gPrefs.get(PREF_FORCE_SAMPLE);
|
||||
let pref = gPrefs.getStringPref(PREF_FORCE_SAMPLE, undefined);
|
||||
if (pref !== undefined) {
|
||||
let val = Number.parseFloat(pref);
|
||||
this._log.debug("random sample forced: " + val);
|
||||
@ -372,7 +370,7 @@ Experiments.Experiments = function(policy = new Experiments.Policy()) {
|
||||
};
|
||||
|
||||
Experiments.Experiments.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsITimerCallback, Ci.nsIObserver]),
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsITimerCallback, Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
|
||||
/**
|
||||
* `true` if the experiments manager is currently setup (has been fully initialized
|
||||
@ -382,18 +380,32 @@ Experiments.Experiments.prototype = {
|
||||
return !this._shutdown;
|
||||
},
|
||||
|
||||
observe(subject, topic, data) {
|
||||
switch (topic) {
|
||||
case PREF_CHANGED_TOPIC:
|
||||
if (data == PREF_BRANCH + PREF_MANIFEST_URI) {
|
||||
this.updateManifest();
|
||||
} else if (data == PREF_BRANCH + PREF_ENABLED) {
|
||||
this._toggleExperimentsEnabled(gPrefs.getBoolPref(PREF_ENABLED, false));
|
||||
} else if (data == PREF_TELEMETRY_ENABLED) {
|
||||
this._telemetryStatusChanged();
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
init() {
|
||||
this._shutdown = false;
|
||||
configureLogging();
|
||||
|
||||
gExperimentsEnabled = gPrefs.get(PREF_ENABLED, false) && TelemetryUtils.isTelemetryEnabled;
|
||||
gExperimentsEnabled = gPrefs.getBoolPref(PREF_ENABLED, false) && TelemetryUtils.isTelemetryEnabled;
|
||||
this._log.trace("enabled=" + gExperimentsEnabled + ", " + this.enabled);
|
||||
|
||||
gPrefs.observe(PREF_LOGGING, configureLogging);
|
||||
gPrefs.observe(PREF_MANIFEST_URI, this.updateManifest, this);
|
||||
gPrefs.observe(PREF_ENABLED, this._toggleExperimentsEnabled, this);
|
||||
Services.prefs.addObserver(PREF_BRANCH + PREF_LOGGING, configureLogging);
|
||||
Services.prefs.addObserver(PREF_BRANCH + PREF_MANIFEST_URI, this, true);
|
||||
Services.prefs.addObserver(PREF_BRANCH + PREF_ENABLED, this, true);
|
||||
|
||||
gPrefsTelemetry.observe(PREF_TELEMETRY_ENABLED, this._telemetryStatusChanged, this);
|
||||
Services.prefs.addObserver(PREF_TELEMETRY_ENABLED, this, true);
|
||||
|
||||
AddonManager.shutdown.addBlocker("Experiments.jsm shutdown",
|
||||
this.uninit.bind(this),
|
||||
@ -438,11 +450,11 @@ Experiments.Experiments.prototype = {
|
||||
this._log.trace("uninit: no previous shutdown");
|
||||
this._unregisterWithAddonManager();
|
||||
|
||||
gPrefs.ignore(PREF_LOGGING, configureLogging);
|
||||
gPrefs.ignore(PREF_MANIFEST_URI, this.updateManifest, this);
|
||||
gPrefs.ignore(PREF_ENABLED, this._toggleExperimentsEnabled, this);
|
||||
Services.prefs.removeObserver(PREF_BRANCH + PREF_LOGGING, configureLogging);
|
||||
Services.prefs.removeObserver(PREF_BRANCH + PREF_MANIFEST_URI, this);
|
||||
Services.prefs.removeObserver(PREF_BRANCH + PREF_ENABLED, this);
|
||||
|
||||
gPrefsTelemetry.ignore(PREF_TELEMETRY_ENABLED, this._telemetryStatusChanged, this);
|
||||
Services.prefs.removeObserver(PREF_TELEMETRY_ENABLED, this);
|
||||
|
||||
if (this._timer) {
|
||||
this._timer.clear();
|
||||
@ -581,7 +593,7 @@ Experiments.Experiments.prototype = {
|
||||
*/
|
||||
set enabled(enabled) {
|
||||
this._log.trace("set enabled(" + enabled + ")");
|
||||
gPrefs.set(PREF_ENABLED, enabled);
|
||||
gPrefs.setBoolPref(PREF_ENABLED, enabled);
|
||||
},
|
||||
|
||||
async _toggleExperimentsEnabled(enabled) {
|
||||
@ -604,7 +616,7 @@ Experiments.Experiments.prototype = {
|
||||
},
|
||||
|
||||
_telemetryStatusChanged() {
|
||||
this._toggleExperimentsEnabled(gPrefs.get(PREF_ENABLED, false));
|
||||
this._toggleExperimentsEnabled(gPrefs.getBoolPref(PREF_ENABLED, false));
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1223,7 +1235,7 @@ Experiments.Experiments.prototype = {
|
||||
|
||||
if (!activeExperiment) {
|
||||
// Avoid this pref staying out of sync if there were e.g. crashes.
|
||||
gPrefs.set(PREF_ACTIVE_EXPERIMENT, false);
|
||||
gPrefs.setBoolPref(PREF_ACTIVE_EXPERIMENT, false);
|
||||
}
|
||||
|
||||
// Ensure the active experiment is in the proper state. This may install,
|
||||
@ -1303,7 +1315,7 @@ Experiments.Experiments.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
gPrefs.set(PREF_ACTIVE_EXPERIMENT, activeExperiment != null);
|
||||
gPrefs.setBoolPref(PREF_ACTIVE_EXPERIMENT, activeExperiment != null);
|
||||
|
||||
if (activeChanged || this._firstEvaluate) {
|
||||
Services.obs.notifyObservers(null, EXPERIMENTS_CHANGED_TOPIC);
|
||||
|
@ -8,7 +8,6 @@ const {interfaces: Ci, utils: Cu} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Experiments",
|
||||
"resource:///modules/experiments/Experiments.jsm");
|
||||
@ -24,16 +23,6 @@ const PREF_EXPERIMENTS_ENABLED = "experiments.enabled";
|
||||
const PREF_ACTIVE_EXPERIMENT = "experiments.activeExperiment"; // whether we have an active experiment
|
||||
const DELAY_INIT_MS = 30 * 1000;
|
||||
|
||||
XPCOMUtils.defineLazyGetter(
|
||||
this, "gPrefs", () => {
|
||||
return new Preferences();
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(
|
||||
this, "gActiveExperiment", () => {
|
||||
return gPrefs.get(PREF_ACTIVE_EXPERIMENT);
|
||||
});
|
||||
|
||||
function ExperimentsService() {
|
||||
this._initialized = false;
|
||||
this._delayedInitTimer = null;
|
||||
@ -46,7 +35,7 @@ ExperimentsService.prototype = {
|
||||
get _experimentsEnabled() {
|
||||
// We can enable experiments if either unified Telemetry or FHR is on, and the user
|
||||
// has opted into Telemetry.
|
||||
return gPrefs.get(PREF_EXPERIMENTS_ENABLED, false) &&
|
||||
return Services.prefs.getBoolPref(PREF_EXPERIMENTS_ENABLED, false) &&
|
||||
TelemetryUtils.isTelemetryEnabled;
|
||||
},
|
||||
|
||||
@ -82,7 +71,7 @@ ExperimentsService.prototype = {
|
||||
Services.obs.addObserver(this, "sessionstore-state-finalized");
|
||||
Services.obs.addObserver(this, "EM-loaded");
|
||||
|
||||
if (gActiveExperiment) {
|
||||
if (Services.prefs.getBoolPref(PREF_ACTIVE_EXPERIMENT, false)) {
|
||||
this._initialized = true;
|
||||
Experiments.instance(); // for side effects
|
||||
}
|
||||
|
@ -1,12 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
Cu.import("resource://gre/modules/TelemetryController.jsm", this);
|
||||
Cu.import("resource://shield-recipe-client/lib/ClientEnvironment.jsm", this);
|
||||
Cu.import("resource://shield-recipe-client/lib/PreferenceExperiments.jsm", this);
|
||||
|
||||
|
||||
add_task(async function testTelemetry() {
|
||||
// setup
|
||||
await TelemetryController.submitExternalPing("testfoo", {foo: 1});
|
||||
|
@ -1,6 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
Cu.import("resource://shield-recipe-client/lib/RecipeRunner.jsm", this);
|
||||
Cu.import("resource://shield-recipe-client/lib/ClientEnvironment.jsm", this);
|
||||
Cu.import("resource://shield-recipe-client/lib/CleanupManager.jsm", this);
|
||||
|
@ -1,7 +1,7 @@
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||
|
||||
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm", this);
|
||||
Cu.import("resource://shield-recipe-client/lib/SandboxManager.jsm", this);
|
||||
Cu.import("resource://shield-recipe-client/lib/NormandyDriver.jsm", this);
|
||||
Cu.import("resource://shield-recipe-client/lib/NormandyApi.jsm", this);
|
||||
|
@ -1642,7 +1642,8 @@ nsScriptSecurityManager::EnsureFileURIWhitelist()
|
||||
//
|
||||
|
||||
mFileURIWhitelist.emplace();
|
||||
auto policies = mozilla::Preferences::GetCString("capability.policy.policynames");
|
||||
nsAutoCString policies;
|
||||
mozilla::Preferences::GetCString("capability.policy.policynames", policies);
|
||||
for (uint32_t base = SkipPast<IsWhitespaceOrComma>(policies, 0), bound = 0;
|
||||
base < policies.Length();
|
||||
base = SkipPast<IsWhitespaceOrComma>(policies, bound))
|
||||
@ -1655,7 +1656,9 @@ nsScriptSecurityManager::EnsureFileURIWhitelist()
|
||||
nsCString checkLoadURIPrefName = NS_LITERAL_CSTRING("capability.policy.") +
|
||||
policyName +
|
||||
NS_LITERAL_CSTRING(".checkloaduri.enabled");
|
||||
if (!Preferences::GetString(checkLoadURIPrefName.get()).LowerCaseEqualsLiteral("allaccess")) {
|
||||
nsAutoString value;
|
||||
nsresult rv = Preferences::GetString(checkLoadURIPrefName.get(), value);
|
||||
if (NS_FAILED(rv) || !value.LowerCaseEqualsLiteral("allaccess")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1663,7 +1666,8 @@ nsScriptSecurityManager::EnsureFileURIWhitelist()
|
||||
nsCString domainPrefName = NS_LITERAL_CSTRING("capability.policy.") +
|
||||
policyName +
|
||||
NS_LITERAL_CSTRING(".sites");
|
||||
auto siteList = Preferences::GetCString(domainPrefName.get());
|
||||
nsAutoCString siteList;
|
||||
Preferences::GetCString(domainPrefName.get(), siteList);
|
||||
AddSitesToFileURIWhitelist(siteList);
|
||||
}
|
||||
|
||||
|
@ -251,11 +251,12 @@ nsChromeRegistryChrome::OverrideLocalePackage(const nsACString& aPackage,
|
||||
nsACString& aOverride)
|
||||
{
|
||||
const nsACString& pref = NS_LITERAL_CSTRING(PACKAGE_OVERRIDE_BRANCH) + aPackage;
|
||||
nsAdoptingCString override = mozilla::Preferences::GetCString(PromiseFlatCString(pref).get());
|
||||
if (override) {
|
||||
nsAutoCString override;
|
||||
nsresult rv =
|
||||
mozilla::Preferences::GetCString(PromiseFlatCString(pref).get(), override);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aOverride = override;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
aOverride = aPackage;
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -578,16 +578,17 @@ nsDefaultURIFixup::MakeAlternateURI(nsIURI* aURI)
|
||||
// are www. & .com but they could be any other value, e.g. www. & .org
|
||||
|
||||
nsAutoCString prefix("www.");
|
||||
nsAdoptingCString prefPrefix =
|
||||
Preferences::GetCString("browser.fixup.alternate.prefix");
|
||||
if (prefPrefix) {
|
||||
nsAutoCString prefPrefix;
|
||||
nsresult rv =
|
||||
Preferences::GetCString("browser.fixup.alternate.prefix", prefPrefix);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
prefix.Assign(prefPrefix);
|
||||
}
|
||||
|
||||
nsAutoCString suffix(".com");
|
||||
nsAdoptingCString prefSuffix =
|
||||
Preferences::GetCString("browser.fixup.alternate.suffix");
|
||||
if (prefSuffix) {
|
||||
nsAutoCString prefSuffix;
|
||||
rv = Preferences::GetCString("browser.fixup.alternate.suffix", prefSuffix);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
suffix.Assign(prefSuffix);
|
||||
}
|
||||
|
||||
|
@ -5099,9 +5099,11 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
|
||||
}
|
||||
|
||||
// See if an alternate cert error page is registered
|
||||
nsAdoptingCString alternateErrorPage =
|
||||
Preferences::GetCString("security.alternate_certificate_error_page");
|
||||
if (alternateErrorPage) {
|
||||
nsAutoCString alternateErrorPage;
|
||||
nsresult rv =
|
||||
Preferences::GetCString("security.alternate_certificate_error_page",
|
||||
alternateErrorPage);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
errorPage.Assign(alternateErrorPage);
|
||||
}
|
||||
|
||||
@ -5123,9 +5125,10 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
|
||||
|
||||
// Malware and phishing detectors may want to use an alternate error
|
||||
// page, but if the pref's not set, we'll fall back on the standard page
|
||||
nsAdoptingCString alternateErrorPage =
|
||||
Preferences::GetCString("urlclassifier.alternate_error_page");
|
||||
if (alternateErrorPage) {
|
||||
nsAutoCString alternateErrorPage;
|
||||
nsresult rv = Preferences::GetCString("urlclassifier.alternate_error_page",
|
||||
alternateErrorPage);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
errorPage.Assign(alternateErrorPage);
|
||||
}
|
||||
|
||||
|
@ -118,9 +118,10 @@ AudioChannelAgent::FindCorrectWindow(nsPIDOMWindowInner* aWindow)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAdoptingCString systemAppUrl =
|
||||
mozilla::Preferences::GetCString("b2g.system_startup_url");
|
||||
if (!systemAppUrl) {
|
||||
nsAutoCString systemAppUrl;
|
||||
nsresult rv =
|
||||
mozilla::Preferences::GetCString("b2g.system_startup_url", systemAppUrl);
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -563,7 +563,8 @@ AudioChannelService::GetAudioChannel(const nsAString& aChannel)
|
||||
/* static */ AudioChannel
|
||||
AudioChannelService::GetDefaultAudioChannel()
|
||||
{
|
||||
nsAutoString audioChannel(Preferences::GetString("media.defaultAudioChannel"));
|
||||
nsAutoString audioChannel;
|
||||
Preferences::GetString("media.defaultAudioChannel", audioChannel);
|
||||
if (audioChannel.IsEmpty()) {
|
||||
return AudioChannel::Normal;
|
||||
}
|
||||
|
@ -379,8 +379,8 @@ Navigator::GetAcceptLanguages(nsTArray<nsString>& aLanguages)
|
||||
aLanguages.Clear();
|
||||
|
||||
// E.g. "de-de, en-us,en".
|
||||
const nsAdoptingString& acceptLang =
|
||||
Preferences::GetLocalizedString("intl.accept_languages");
|
||||
nsAutoString acceptLang;
|
||||
Preferences::GetLocalizedString("intl.accept_languages", acceptLang);
|
||||
|
||||
// Split values on commas.
|
||||
nsCharSeparatedTokenizer langTokenizer(acceptLang, ',');
|
||||
@ -473,10 +473,9 @@ Navigator::GetOscpu(nsAString& aOSCPU, CallerType aCallerType,
|
||||
return;
|
||||
}
|
||||
|
||||
const nsAdoptingString& override =
|
||||
Preferences::GetString("general.oscpu.override");
|
||||
|
||||
if (override) {
|
||||
nsAutoString override;
|
||||
nsresult rv = Preferences::GetString("general.oscpu.override", override);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aOSCPU = override;
|
||||
return;
|
||||
}
|
||||
@ -653,10 +652,9 @@ Navigator::GetBuildID(nsAString& aBuildID, CallerType aCallerType,
|
||||
aBuildID.AssignLiteral(LEGACY_BUILD_ID);
|
||||
return;
|
||||
}
|
||||
const nsAdoptingString& override =
|
||||
Preferences::GetString("general.buildID.override");
|
||||
|
||||
if (override) {
|
||||
nsAutoString override;
|
||||
nsresult rv = Preferences::GetString("general.buildID.override", override);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aBuildID = override;
|
||||
return;
|
||||
}
|
||||
@ -704,7 +702,8 @@ Navigator::JavaEnabled(CallerType aCallerType, ErrorResult& aRv)
|
||||
Telemetry::AutoTimer<Telemetry::CHECK_JAVA_ENABLED> telemetryTimer;
|
||||
|
||||
// Return true if we have a handler for the java mime
|
||||
nsAdoptingString javaMIME = Preferences::GetString("plugin.java.mime");
|
||||
nsAutoString javaMIME;
|
||||
Preferences::GetString("plugin.java.mime", javaMIME);
|
||||
NS_ENSURE_TRUE(!javaMIME.IsEmpty(), false);
|
||||
|
||||
if (!mMimeTypes) {
|
||||
@ -1783,10 +1782,11 @@ Navigator::GetPlatform(nsAString& aPlatform, bool aUsePrefOverriddenValue)
|
||||
aPlatform.AssignLiteral(SPOOFED_PLATFORM);
|
||||
return NS_OK;
|
||||
}
|
||||
const nsAdoptingString& override =
|
||||
mozilla::Preferences::GetString("general.platform.override");
|
||||
nsAutoString override;
|
||||
nsresult rv =
|
||||
mozilla::Preferences::GetString("general.platform.override", override);
|
||||
|
||||
if (override) {
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aPlatform = override;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1834,10 +1834,11 @@ Navigator::GetAppVersion(nsAString& aAppVersion, bool aUsePrefOverriddenValue)
|
||||
aAppVersion.AssignLiteral(SPOOFED_APPVERSION);
|
||||
return NS_OK;
|
||||
}
|
||||
const nsAdoptingString& override =
|
||||
mozilla::Preferences::GetString("general.appversion.override");
|
||||
nsAutoString override;
|
||||
nsresult rv =
|
||||
mozilla::Preferences::GetString("general.appversion.override", override);
|
||||
|
||||
if (override) {
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aAppVersion = override;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1878,10 +1879,11 @@ Navigator::AppName(nsAString& aAppName, bool aUsePrefOverriddenValue)
|
||||
return;
|
||||
}
|
||||
|
||||
const nsAdoptingString& override =
|
||||
mozilla::Preferences::GetString("general.appname.override");
|
||||
nsAutoString override;
|
||||
nsresult rv =
|
||||
mozilla::Preferences::GetString("general.appname.override", override);
|
||||
|
||||
if (override) {
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aAppName = override;
|
||||
return;
|
||||
}
|
||||
@ -1907,10 +1909,11 @@ Navigator::GetUserAgent(nsPIDOMWindowInner* aWindow,
|
||||
// when 'privacy.resistFingerprinting' is true.
|
||||
if (!aIsCallerChrome &&
|
||||
!nsContentUtils::ShouldResistFingerprinting()) {
|
||||
const nsAdoptingString& override =
|
||||
mozilla::Preferences::GetString("general.useragent.override");
|
||||
nsAutoString override;
|
||||
nsresult rv =
|
||||
mozilla::Preferences::GetString("general.useragent.override", override);
|
||||
|
||||
if (override) {
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aUserAgent = override;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2706,9 +2706,7 @@ GetCommonAncestorInternal(Node* aNode1,
|
||||
Node* aNode2,
|
||||
GetParentFunc aGetParentFunc)
|
||||
{
|
||||
if (aNode1 == aNode2) {
|
||||
return aNode1;
|
||||
}
|
||||
MOZ_ASSERT(aNode1 != aNode2);
|
||||
|
||||
// Build the chain of parents
|
||||
AutoTArray<Node*, 30> parents1, parents2;
|
||||
@ -2740,7 +2738,7 @@ GetCommonAncestorInternal(Node* aNode1,
|
||||
|
||||
/* static */
|
||||
nsINode*
|
||||
nsContentUtils::GetCommonAncestor(nsINode* aNode1, nsINode* aNode2)
|
||||
nsContentUtils::GetCommonAncestorHelper(nsINode* aNode1, nsINode* aNode2)
|
||||
{
|
||||
return GetCommonAncestorInternal(aNode1, aNode2, [](nsINode* aNode) {
|
||||
return aNode->GetParentNode();
|
||||
@ -2749,8 +2747,8 @@ nsContentUtils::GetCommonAncestor(nsINode* aNode1, nsINode* aNode2)
|
||||
|
||||
/* static */
|
||||
nsIContent*
|
||||
nsContentUtils::GetCommonFlattenedTreeAncestor(nsIContent* aContent1,
|
||||
nsIContent* aContent2)
|
||||
nsContentUtils::GetCommonFlattenedTreeAncestorHelper(nsIContent* aContent1,
|
||||
nsIContent* aContent2)
|
||||
{
|
||||
return GetCommonAncestorInternal(aContent1, aContent2, [](nsIContent* aContent) {
|
||||
return aContent->GetFlattenedTreeParent();
|
||||
@ -5577,7 +5575,8 @@ nsContentUtils::GetLocalizedEllipsis()
|
||||
{
|
||||
static char16_t sBuf[4] = { 0, 0, 0, 0 };
|
||||
if (!sBuf[0]) {
|
||||
nsAdoptingString tmp = Preferences::GetLocalizedString("intl.ellipsis");
|
||||
nsAutoString tmp;
|
||||
Preferences::GetLocalizedString("intl.ellipsis", tmp);
|
||||
uint32_t len = std::min(uint32_t(tmp.Length()),
|
||||
uint32_t(ArrayLength(sBuf) - 1));
|
||||
CopyUnicodeTo(tmp, 0, sBuf, len);
|
||||
|
@ -383,14 +383,28 @@ public:
|
||||
*
|
||||
* Returns null if the nodes are disconnected.
|
||||
*/
|
||||
static nsINode* GetCommonAncestor(nsINode* aNode1, nsINode* aNode2);
|
||||
static nsINode* GetCommonAncestor(nsINode* aNode1, nsINode* aNode2)
|
||||
{
|
||||
if (aNode1 == aNode2) {
|
||||
return aNode1;
|
||||
}
|
||||
|
||||
return GetCommonAncestorHelper(aNode1, aNode2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the common flattened tree ancestor, if any, for two given content
|
||||
* nodes.
|
||||
*/
|
||||
static nsIContent* GetCommonFlattenedTreeAncestor(nsIContent* aContent1,
|
||||
nsIContent* aContent2);
|
||||
nsIContent* aContent2)
|
||||
{
|
||||
if (aContent1 == aContent2) {
|
||||
return aContent1;
|
||||
}
|
||||
|
||||
return GetCommonFlattenedTreeAncestorHelper(aContent1, aContent2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if aNode1 is before aNode2 in the same connected
|
||||
@ -3181,6 +3195,10 @@ private:
|
||||
static StorageAccess InternalStorageAllowedForPrincipal(nsIPrincipal* aPrincipal,
|
||||
nsPIDOMWindowInner* aWindow);
|
||||
|
||||
static nsINode* GetCommonAncestorHelper(nsINode* aNode1, nsINode* aNode2);
|
||||
static nsIContent* GetCommonFlattenedTreeAncestorHelper(nsIContent* aContent1,
|
||||
nsIContent* aContent2);
|
||||
|
||||
static nsIXPConnect *sXPConnect;
|
||||
|
||||
static nsIScriptSecurityManager *sSecurityManager;
|
||||
|
@ -2764,8 +2764,9 @@ nsDocument::InitCSP(nsIChannel* aChannel)
|
||||
// Note that when the content signing becomes a standard, we might have
|
||||
// to restrict this enforcement to "remote content" only.
|
||||
if (applySignedContentCSP) {
|
||||
nsAdoptingString signedContentCSP =
|
||||
Preferences::GetString("security.signed_content.CSP.default");
|
||||
nsAutoString signedContentCSP;
|
||||
Preferences::GetString("security.signed_content.CSP.default",
|
||||
signedContentCSP);
|
||||
csp->AppendPolicy(signedContentCSP, false, false);
|
||||
}
|
||||
|
||||
@ -13291,24 +13292,24 @@ nsDocument::PrincipalFlashClassification()
|
||||
denyTables, denyExceptionsTables,
|
||||
subDocDenyTables, subDocDenyExceptionsTables,
|
||||
tables;
|
||||
Preferences::GetCString("urlclassifier.flashAllowTable", &allowTables);
|
||||
Preferences::GetCString("urlclassifier.flashAllowTable", allowTables);
|
||||
MaybeAddTableToTableList(allowTables, tables);
|
||||
Preferences::GetCString("urlclassifier.flashAllowExceptTable",
|
||||
&allowExceptionsTables);
|
||||
allowExceptionsTables);
|
||||
MaybeAddTableToTableList(allowExceptionsTables, tables);
|
||||
Preferences::GetCString("urlclassifier.flashTable", &denyTables);
|
||||
Preferences::GetCString("urlclassifier.flashTable", denyTables);
|
||||
MaybeAddTableToTableList(denyTables, tables);
|
||||
Preferences::GetCString("urlclassifier.flashExceptTable",
|
||||
&denyExceptionsTables);
|
||||
denyExceptionsTables);
|
||||
MaybeAddTableToTableList(denyExceptionsTables, tables);
|
||||
|
||||
bool isThirdPartyDoc = IsThirdParty();
|
||||
if (isThirdPartyDoc) {
|
||||
Preferences::GetCString("urlclassifier.flashSubDocTable",
|
||||
&subDocDenyTables);
|
||||
subDocDenyTables);
|
||||
MaybeAddTableToTableList(subDocDenyTables, tables);
|
||||
Preferences::GetCString("urlclassifier.flashSubDocExceptTable",
|
||||
&subDocDenyExceptionsTables);
|
||||
subDocDenyExceptionsTables);
|
||||
MaybeAddTableToTableList(subDocDenyExceptionsTables, tables);
|
||||
}
|
||||
|
||||
|
@ -1705,12 +1705,11 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
|
||||
}
|
||||
|
||||
if (gDumpFile == nullptr) {
|
||||
const nsAdoptingCString& fname =
|
||||
Preferences::GetCString("browser.dom.window.dump.file");
|
||||
nsAutoCString fname;
|
||||
Preferences::GetCString("browser.dom.window.dump.file", fname);
|
||||
if (!fname.IsEmpty()) {
|
||||
// if this fails to open, Dump() knows to just go to stdout
|
||||
// on null.
|
||||
gDumpFile = fopen(fname, "wb+");
|
||||
// If this fails to open, Dump() knows to just go to stdout on null.
|
||||
gDumpFile = fopen(fname.get(), "wb+");
|
||||
} else {
|
||||
gDumpFile = stdout;
|
||||
}
|
||||
@ -6941,7 +6940,8 @@ GetFullscreenTransitionDuration(bool aEnterFullscreen,
|
||||
const char* pref = aEnterFullscreen ?
|
||||
"full-screen-api.transition-duration.enter" :
|
||||
"full-screen-api.transition-duration.leave";
|
||||
nsAdoptingCString prefValue = Preferences::GetCString(pref);
|
||||
nsAutoCString prefValue;
|
||||
Preferences::GetCString(pref, prefValue);
|
||||
if (!prefValue.IsEmpty()) {
|
||||
sscanf(prefValue.get(), "%hu%hu",
|
||||
&aDuration->mFadeIn, &aDuration->mFadeOut);
|
||||
@ -8046,8 +8046,8 @@ nsGlobalWindow::HomeOuter(nsIPrincipal& aSubjectPrincipal, ErrorResult& aError)
|
||||
return;
|
||||
}
|
||||
|
||||
nsAdoptingString homeURL =
|
||||
Preferences::GetLocalizedString(PREF_BROWSER_STARTUP_HOMEPAGE);
|
||||
nsAutoString homeURL;
|
||||
Preferences::GetLocalizedString(PREF_BROWSER_STARTUP_HOMEPAGE, homeURL);
|
||||
|
||||
if (homeURL.IsEmpty()) {
|
||||
// if all else fails, use this
|
||||
|
@ -933,7 +933,9 @@ nsObjectLoadingContent::BuildParametersArray()
|
||||
mCachedAttributes.AppendElement(param);
|
||||
}
|
||||
|
||||
nsAdoptingCString wmodeOverride = Preferences::GetCString("plugins.force.wmode");
|
||||
nsAutoCString wmodeOverride;
|
||||
Preferences::GetCString("plugins.force.wmode", wmodeOverride);
|
||||
|
||||
for (uint32_t i = 0; i < mCachedAttributes.Length(); i++) {
|
||||
if (!wmodeOverride.IsEmpty() && mCachedAttributes[i].mName.EqualsIgnoreCase("wmode")) {
|
||||
CopyASCIItoUTF16(wmodeOverride, mCachedAttributes[i].mValue);
|
||||
@ -3368,8 +3370,8 @@ nsObjectLoadingContent::FavorFallbackMode(bool aIsPluginClickToPlay) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCString prefString;
|
||||
if (NS_SUCCEEDED(Preferences::GetCString(kPrefFavorFallbackMode, &prefString))) {
|
||||
nsAutoCString prefString;
|
||||
if (NS_SUCCEEDED(Preferences::GetCString(kPrefFavorFallbackMode, prefString))) {
|
||||
if (aIsPluginClickToPlay &&
|
||||
prefString.EqualsLiteral("follow-ctp")) {
|
||||
return true;
|
||||
@ -3395,8 +3397,8 @@ nsObjectLoadingContent::HasGoodFallback() {
|
||||
}
|
||||
|
||||
nsTArray<nsCString> rulesList;
|
||||
nsCString prefString;
|
||||
if (NS_SUCCEEDED(Preferences::GetCString(kPrefFavorFallbackRules, &prefString))) {
|
||||
nsAutoCString prefString;
|
||||
if (NS_SUCCEEDED(Preferences::GetCString(kPrefFavorFallbackRules, prefString))) {
|
||||
ParseString(prefString, ',', rulesList);
|
||||
}
|
||||
|
||||
|
@ -333,7 +333,9 @@ operator<(const RefPtr<nsPluginElement>& lhs,
|
||||
static bool
|
||||
PluginShouldBeHidden(const nsCString& aName) {
|
||||
// This only supports one hidden plugin
|
||||
return Preferences::GetCString("plugins.navigator.hidden_ctp_plugin").Equals(aName);
|
||||
nsAutoCString value;
|
||||
Preferences::GetCString("plugins.navigator.hidden_ctp_plugin", value);
|
||||
return value.Equals(aName);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -307,7 +307,7 @@ WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
|
||||
|
||||
nsAutoString ret;
|
||||
if (overridePref) {
|
||||
nsresult res = Preferences::GetString(overridePref, &ret);
|
||||
nsresult res = Preferences::GetString(overridePref, ret);
|
||||
if (NS_SUCCEEDED(res) && ret.Length() > 0)
|
||||
hasRetVal = true;
|
||||
}
|
||||
|
@ -49,8 +49,8 @@ FallbackEncoding::Get()
|
||||
return WrapNotNull(mFallback);
|
||||
}
|
||||
|
||||
const nsAdoptingCString& override =
|
||||
Preferences::GetCString("intl.charset.fallback.override");
|
||||
nsAutoCString override;
|
||||
Preferences::GetCString("intl.charset.fallback.override", override);
|
||||
// Don't let the user break things by setting the override to unreasonable
|
||||
// values via about:config
|
||||
auto encoding = Encoding::ForLabel(override);
|
||||
|
@ -900,7 +900,8 @@ Event::PopupAllowedEventsChanged()
|
||||
free(sPopupAllowedEvents);
|
||||
}
|
||||
|
||||
nsAdoptingCString str = Preferences::GetCString("dom.popup_allowed_events");
|
||||
nsAutoCString str;
|
||||
Preferences::GetCString("dom.popup_allowed_events", str);
|
||||
|
||||
// We'll want to do this even if str is empty to avoid looking up
|
||||
// this pref all the time if it's not set.
|
||||
|
@ -484,7 +484,7 @@ UploadLastDir::ContentPrefCallback::HandleCompletion(uint16_t aReason)
|
||||
nsAutoString prefStr;
|
||||
|
||||
if (aReason == nsIContentPrefCallback2::COMPLETE_ERROR || !mResult) {
|
||||
prefStr = Preferences::GetString("dom.input.fallbackUploadDir");
|
||||
Preferences::GetString("dom.input.fallbackUploadDir", prefStr);
|
||||
}
|
||||
|
||||
if (prefStr.IsEmpty() && mResult) {
|
||||
|
@ -431,8 +431,8 @@ IndexedDatabaseManager::Init()
|
||||
kPrefMaxSerilizedMsgSize);
|
||||
|
||||
#ifdef ENABLE_INTL_API
|
||||
const nsAdoptingCString& acceptLang =
|
||||
Preferences::GetLocalizedCString("intl.accept_languages");
|
||||
nsAutoCString acceptLang;
|
||||
Preferences::GetLocalizedCString("intl.accept_languages", acceptLang);
|
||||
|
||||
// Split values on commas.
|
||||
nsCCharSeparatedTokenizer langTokenizer(acceptLang, ',');
|
||||
|
@ -1511,13 +1511,15 @@ StartMacOSContentSandbox()
|
||||
// These paths are used to whitelist certain directories used by the testing
|
||||
// system. They should not be considered a public API, and are only intended
|
||||
// for use in automation.
|
||||
nsAdoptingCString testingReadPath1 =
|
||||
Preferences::GetCString("security.sandbox.content.mac.testing_read_path1");
|
||||
nsAutoCString testingReadPath1;
|
||||
Preferences::GetCString("security.sandbox.content.mac.testing_read_path1",
|
||||
testingReadPath1);
|
||||
if (!testingReadPath1.IsEmpty()) {
|
||||
info.testingReadPath1.assign(testingReadPath1.get());
|
||||
}
|
||||
nsAdoptingCString testingReadPath2 =
|
||||
Preferences::GetCString("security.sandbox.content.mac.testing_read_path2");
|
||||
nsAutoCString testingReadPath2;
|
||||
Preferences::GetCString("security.sandbox.content.mac.testing_read_path2",
|
||||
testingReadPath2);
|
||||
if (!testingReadPath2.IsEmpty()) {
|
||||
info.testingReadPath2.assign(testingReadPath2.get());
|
||||
}
|
||||
@ -1605,11 +1607,12 @@ ContentChild::RecvSetProcessSandbox(const MaybeFileDesc& aBroker)
|
||||
}
|
||||
// Allow user overrides of seccomp-bpf syscall filtering
|
||||
std::vector<int> syscallWhitelist;
|
||||
nsAdoptingCString extraSyscalls =
|
||||
Preferences::GetCString("security.sandbox.content.syscall_whitelist");
|
||||
if (extraSyscalls) {
|
||||
nsAutoCString extraSyscalls;
|
||||
nsresult rv =
|
||||
Preferences::GetCString("security.sandbox.content.syscall_whitelist",
|
||||
extraSyscalls);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
for (const nsACString& callNrString : extraSyscalls.Split(',')) {
|
||||
nsresult rv;
|
||||
int callNr = PromiseFlatCString(callNrString).ToInteger(&rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
syscallWhitelist.push_back(callNr);
|
||||
|
@ -2040,7 +2040,8 @@ ContentParent::LaunchSubprocess(ProcessPriority aInitialPriority /* = PROCESS_PR
|
||||
boolPrefs.Append(nsPrintfCString("%u:%d|", i, Preferences::GetBool(ContentPrefs::GetContentPref(i))));
|
||||
break;
|
||||
case nsIPrefBranch::PREF_STRING: {
|
||||
nsAdoptingCString value(Preferences::GetCString(ContentPrefs::GetContentPref(i)));
|
||||
nsAutoCString value;
|
||||
Preferences::GetCString(ContentPrefs::GetContentPref(i), value);
|
||||
stringPrefs.Append(nsPrintfCString("%u:%d;%s|", i, value.Length(), value.get()));
|
||||
|
||||
}
|
||||
|
@ -162,13 +162,13 @@ namespace CubebUtils {
|
||||
void PrefChanged(const char* aPref, void* aClosure)
|
||||
{
|
||||
if (strcmp(aPref, PREF_VOLUME_SCALE) == 0) {
|
||||
nsAdoptingString value = Preferences::GetString(aPref);
|
||||
nsAutoCString value;
|
||||
Preferences::GetCString(aPref, value);
|
||||
StaticMutexAutoLock lock(sMutex);
|
||||
if (value.IsEmpty()) {
|
||||
sVolumeScale = 1.0;
|
||||
} else {
|
||||
NS_ConvertUTF16toUTF8 utf8(value);
|
||||
sVolumeScale = std::max<double>(0, PR_strtod(utf8.get(), nullptr));
|
||||
sVolumeScale = std::max<double>(0, PR_strtod(value.get(), nullptr));
|
||||
}
|
||||
} else if (strcmp(aPref, PREF_CUBEB_LATENCY_PLAYBACK) == 0) {
|
||||
// Arbitrary default stream latency of 100ms. The higher this
|
||||
@ -188,28 +188,28 @@ void PrefChanged(const char* aPref, void* aClosure)
|
||||
// experiment.
|
||||
sCubebMSGLatencyInFrames = std::min<uint32_t>(std::max<uint32_t>(value, 128), 1e6);
|
||||
} else if (strcmp(aPref, PREF_CUBEB_LOGGING_LEVEL) == 0) {
|
||||
nsAdoptingString value = Preferences::GetString(aPref);
|
||||
NS_ConvertUTF16toUTF8 utf8(value);
|
||||
nsAutoCString value;
|
||||
Preferences::GetCString(aPref, value);
|
||||
LogModule* cubebLog = LogModule::Get("cubeb");
|
||||
if (strcmp(utf8.get(), "verbose") == 0) {
|
||||
if (value.EqualsLiteral("verbose")) {
|
||||
cubeb_set_log_callback(CUBEB_LOG_VERBOSE, CubebLogCallback);
|
||||
cubebLog->SetLevel(LogLevel::Verbose);
|
||||
} else if (strcmp(utf8.get(), "normal") == 0) {
|
||||
} else if (value.EqualsLiteral("normal")) {
|
||||
cubeb_set_log_callback(CUBEB_LOG_NORMAL, CubebLogCallback);
|
||||
cubebLog->SetLevel(LogLevel::Error);
|
||||
} else if (utf8.IsEmpty()) {
|
||||
} else if (value.IsEmpty()) {
|
||||
cubeb_set_log_callback(CUBEB_LOG_DISABLED, nullptr);
|
||||
cubebLog->SetLevel(LogLevel::Disabled);
|
||||
}
|
||||
} else if (strcmp(aPref, PREF_CUBEB_BACKEND) == 0) {
|
||||
nsAdoptingString value = Preferences::GetString(aPref);
|
||||
nsAutoCString value;
|
||||
Preferences::GetCString(aPref, value);
|
||||
if (value.IsEmpty()) {
|
||||
sCubebBackendName = nullptr;
|
||||
} else {
|
||||
NS_LossyConvertUTF16toASCII ascii(value);
|
||||
sCubebBackendName = new char[ascii.Length() + 1];
|
||||
PodCopy(sCubebBackendName.get(), ascii.get(), ascii.Length());
|
||||
sCubebBackendName[ascii.Length()] = 0;
|
||||
sCubebBackendName = new char[value.Length() + 1];
|
||||
PodCopy(sCubebBackendName.get(), value.get(), value.Length());
|
||||
sCubebBackendName[value.Length()] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -404,8 +404,8 @@ AllowNotification(const NotificationAndReportStringId& aNotification)
|
||||
// - Comma-separater list of ids -> Allow if aReportStringId (from
|
||||
// dom.properties) is one of them.
|
||||
// - Nothing (missing or empty) -> Disable everything.
|
||||
nsAdoptingCString filter =
|
||||
Preferences::GetCString("media.decoder-doctor.notifications-allowed");
|
||||
nsAutoCString filter;
|
||||
Preferences::GetCString("media.decoder-doctor.notifications-allowed", filter);
|
||||
return filter.EqualsLiteral("*") ||
|
||||
StringListContains(filter, aNotification.mReportStringId);
|
||||
}
|
||||
@ -424,10 +424,11 @@ AllowDecodeIssue(const MediaResult& aDecodeIssue, bool aDecodeIssueIsError)
|
||||
// - '*' -> Allow everything.
|
||||
// - Comma-separater list of ids -> Allow if the issue name is one of them.
|
||||
// - Nothing (missing or empty) -> Disable everything.
|
||||
nsAdoptingCString filter =
|
||||
Preferences::GetCString(aDecodeIssueIsError
|
||||
? "media.decoder-doctor.decode-errors-allowed"
|
||||
: "media.decoder-doctor.decode-warnings-allowed");
|
||||
nsAutoCString filter;
|
||||
Preferences::GetCString(aDecodeIssueIsError
|
||||
? "media.decoder-doctor.decode-errors-allowed"
|
||||
: "media.decoder-doctor.decode-warnings-allowed",
|
||||
filter);
|
||||
if (filter.EqualsLiteral("*")) {
|
||||
return true;
|
||||
}
|
||||
@ -628,8 +629,8 @@ DecoderDoctorDocumentWatcher::SynthesizeAnalysis()
|
||||
nsAutoCString formatsPref("media.decoder-doctor.");
|
||||
formatsPref += id->mReportStringId;
|
||||
formatsPref += ".formats";
|
||||
nsAdoptingString formatsWithIssues =
|
||||
Preferences::GetString(formatsPref.Data());
|
||||
nsAutoString formatsWithIssues;
|
||||
Preferences::GetString(formatsPref.Data(), formatsWithIssues);
|
||||
if (formatsWithIssues.IsEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1701,16 +1701,16 @@ MediaManager::EnumerateRawDevices(uint64_t aWindowId,
|
||||
RefPtr<PledgeSourceSet> p = new PledgeSourceSet();
|
||||
uint32_t id = mOutstandingPledges.Append(*p);
|
||||
|
||||
nsAdoptingCString audioLoopDev, videoLoopDev;
|
||||
nsAutoCString audioLoopDev, videoLoopDev;
|
||||
if (!aFake) {
|
||||
// Fake stream not requested. The entire device stack is available.
|
||||
// Loop in loopback devices if they are set, and their respective type is
|
||||
// requested. This is currently used for automated media tests only.
|
||||
if (aVideoType == MediaSourceEnum::Camera) {
|
||||
videoLoopDev = Preferences::GetCString("media.video_loopback_dev");
|
||||
Preferences::GetCString("media.video_loopback_dev", videoLoopDev);
|
||||
}
|
||||
if (aAudioType == MediaSourceEnum::Microphone) {
|
||||
audioLoopDev = Preferences::GetCString("media.audio_loopback_dev");
|
||||
Preferences::GetCString("media.audio_loopback_dev", audioLoopDev);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1739,7 +1739,8 @@ MediaManager::EnumerateRawDevices(uint64_t aWindowId,
|
||||
if (hasVideo) {
|
||||
nsTArray<RefPtr<VideoDevice>> videos;
|
||||
GetSources(fakeCams? fakeBackend : realBackend, aVideoType,
|
||||
&MediaEngine::EnumerateVideoDevices, videos, videoLoopDev);
|
||||
&MediaEngine::EnumerateVideoDevices, videos,
|
||||
videoLoopDev.get());
|
||||
for (auto& source : videos) {
|
||||
result->AppendElement(source);
|
||||
}
|
||||
@ -1747,7 +1748,8 @@ MediaManager::EnumerateRawDevices(uint64_t aWindowId,
|
||||
if (hasAudio) {
|
||||
nsTArray<RefPtr<AudioDevice>> audios;
|
||||
GetSources(fakeMics? fakeBackend : realBackend, aAudioType,
|
||||
&MediaEngine::EnumerateAudioDevices, audios, audioLoopDev);
|
||||
&MediaEngine::EnumerateAudioDevices, audios,
|
||||
audioLoopDev.get());
|
||||
for (auto& source : audios) {
|
||||
result->AppendElement(source);
|
||||
}
|
||||
|
@ -72,8 +72,8 @@ GetSpeechRecognitionService(const nsAString& aLang)
|
||||
{
|
||||
nsAutoCString speechRecognitionServiceCID;
|
||||
|
||||
nsAdoptingCString prefValue =
|
||||
Preferences::GetCString(PREFERENCE_DEFAULT_RECOGNITION_SERVICE);
|
||||
nsAutoCString prefValue;
|
||||
Preferences::GetCString(PREFERENCE_DEFAULT_RECOGNITION_SERVICE, prefValue);
|
||||
nsAutoCString speechRecognitionService;
|
||||
|
||||
if (!aLang.IsEmpty()) {
|
||||
|
@ -1552,8 +1552,8 @@ nsPluginHost::RegisterFakePlugin(JS::Handle<JS::Value> aInitDictionary,
|
||||
|
||||
mFakePlugins.AppendElement(newTag);
|
||||
|
||||
nsAdoptingCString disableFullPage =
|
||||
Preferences::GetCString(kPrefDisableFullPage);
|
||||
nsAutoCString disableFullPage;
|
||||
Preferences::GetCString(kPrefDisableFullPage, disableFullPage);
|
||||
for (uint32_t i = 0; i < newTag->MimeTypes().Length(); i++) {
|
||||
if (!IsTypeInList(newTag->MimeTypes()[i], disableFullPage)) {
|
||||
RegisterWithCategoryManager(newTag->MimeTypes()[i],
|
||||
@ -1996,8 +1996,8 @@ nsPluginHost::AddPluginTag(nsPluginTag* aPluginTag)
|
||||
mPlugins = aPluginTag;
|
||||
|
||||
if (aPluginTag->IsActive()) {
|
||||
nsAdoptingCString disableFullPage =
|
||||
Preferences::GetCString(kPrefDisableFullPage);
|
||||
nsAutoCString disableFullPage;
|
||||
Preferences::GetCString(kPrefDisableFullPage, disableFullPage);
|
||||
for (uint32_t i = 0; i < aPluginTag->MimeTypes().Length(); i++) {
|
||||
if (!IsTypeInList(aPluginTag->MimeTypes()[i], disableFullPage)) {
|
||||
RegisterWithCategoryManager(aPluginTag->MimeTypes()[i],
|
||||
@ -2389,8 +2389,8 @@ nsPluginHost::SetPluginsInContent(uint32_t aPluginEpoch,
|
||||
tag.extensions(),
|
||||
tag.niceName(),
|
||||
tag.sandboxScript()));
|
||||
nsAdoptingCString disableFullPage =
|
||||
Preferences::GetCString(kPrefDisableFullPage);
|
||||
nsAutoCString disableFullPage;
|
||||
Preferences::GetCString(kPrefDisableFullPage, disableFullPage);
|
||||
for (uint32_t i = 0; i < pluginTag->MimeTypes().Length(); i++) {
|
||||
if (!IsTypeInList(pluginTag->MimeTypes()[i], disableFullPage)) {
|
||||
RegisterWithCategoryManager(pluginTag->MimeTypes()[i],
|
||||
@ -2636,8 +2636,8 @@ nsPluginHost::UpdateInMemoryPluginInfo(nsPluginTag* aPluginTag)
|
||||
}
|
||||
|
||||
// Update types with category manager
|
||||
nsAdoptingCString disableFullPage =
|
||||
Preferences::GetCString(kPrefDisableFullPage);
|
||||
nsAutoCString disableFullPage;
|
||||
Preferences::GetCString(kPrefDisableFullPage, disableFullPage);
|
||||
for (uint32_t i = 0; i < aPluginTag->MimeTypes().Length(); i++) {
|
||||
nsRegisterType shouldRegister;
|
||||
|
||||
@ -2675,8 +2675,9 @@ nsPluginHost::UpdatePluginInfo(nsPluginTag* aPluginTag)
|
||||
/* static */ bool
|
||||
nsPluginHost::IsTypeWhitelisted(const char *aMimeType)
|
||||
{
|
||||
nsAdoptingCString whitelist = Preferences::GetCString(kPrefWhitelist);
|
||||
if (!whitelist.Length()) {
|
||||
nsAutoCString whitelist;
|
||||
Preferences::GetCString(kPrefWhitelist, whitelist);
|
||||
if (whitelist.IsEmpty()) {
|
||||
return true;
|
||||
}
|
||||
nsDependentCString wrap(aMimeType);
|
||||
|
@ -160,7 +160,8 @@ MulticastDNSDeviceProvider::Init()
|
||||
mDiscoverable = Preferences::GetBool(PREF_PRESENTATION_DISCOVERABLE);
|
||||
mDiscoverableEncrypted = Preferences::GetBool(PREF_PRESENTATION_DISCOVERABLE_ENCRYPTED);
|
||||
mServerRetryMs = Preferences::GetUint(PREF_PRESENTATION_DISCOVERABLE_RETRY_MS);
|
||||
mServiceName = Preferences::GetCString(PREF_PRESENTATION_DEVICE_NAME);
|
||||
mServiceName.Truncate();
|
||||
Preferences::GetCString(PREF_PRESENTATION_DEVICE_NAME, mServiceName);
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
// FIXME: Bug 1185806 - Provide a common device name setting.
|
||||
@ -1098,7 +1099,8 @@ MulticastDNSDeviceProvider::Observe(nsISupports* aSubject,
|
||||
} else if (data.EqualsLiteral(PREF_PRESENTATION_DISCOVERABLE)) {
|
||||
OnDiscoverableChanged(Preferences::GetBool(PREF_PRESENTATION_DISCOVERABLE));
|
||||
} else if (data.EqualsLiteral(PREF_PRESENTATION_DEVICE_NAME)) {
|
||||
nsAdoptingCString newServiceName = Preferences::GetCString(PREF_PRESENTATION_DEVICE_NAME);
|
||||
nsAutoCString newServiceName;
|
||||
Preferences::GetCString(PREF_PRESENTATION_DEVICE_NAME, newServiceName);
|
||||
if (!mServiceName.Equals(newServiceName)) {
|
||||
OnServiceNameChanged(newServiceName);
|
||||
}
|
||||
|
@ -714,8 +714,10 @@ nsContentSecurityManager::IsOriginPotentiallyTrustworthy(nsIPrincipal* aPrincipa
|
||||
// whitelist for network resources, i.e., those with scheme "http" or "ws".
|
||||
// The pref should contain a comma-separated list of hostnames.
|
||||
if (scheme.EqualsLiteral("http") || scheme.EqualsLiteral("ws")) {
|
||||
nsAdoptingCString whitelist = Preferences::GetCString("dom.securecontext.whitelist");
|
||||
if (whitelist) {
|
||||
nsAutoCString whitelist;
|
||||
nsresult rv =
|
||||
Preferences::GetCString("dom.securecontext.whitelist", whitelist);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCCharSeparatedTokenizer tokenizer(whitelist, ',');
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
const nsACString& allowedHost = tokenizer.nextToken();
|
||||
|
@ -127,8 +127,8 @@ SVGSwitchElement::IsAttributeMapped(const nsIAtom* name) const
|
||||
nsIContent *
|
||||
SVGSwitchElement::FindActiveChild() const
|
||||
{
|
||||
const nsAdoptingString& acceptLangs =
|
||||
Preferences::GetLocalizedString("intl.accept_languages");
|
||||
nsAutoString acceptLangs;
|
||||
Preferences::GetLocalizedString("intl.accept_languages", acceptLangs);
|
||||
|
||||
if (!acceptLangs.IsEmpty()) {
|
||||
int32_t bestLanguagePreferenceRank = -1;
|
||||
|
@ -147,8 +147,12 @@ SVGTests::PassesConditionalProcessingTests(const nsString *aAcceptLangs) const
|
||||
}
|
||||
|
||||
// Get our language preferences
|
||||
const nsAutoString acceptLangs(aAcceptLangs ? *aAcceptLangs :
|
||||
Preferences::GetLocalizedString("intl.accept_languages"));
|
||||
nsAutoString acceptLangs;
|
||||
if (aAcceptLangs) {
|
||||
acceptLangs.Assign(*aAcceptLangs);
|
||||
} else {
|
||||
Preferences::GetLocalizedString("intl.accept_languages", acceptLangs);
|
||||
}
|
||||
|
||||
if (acceptLangs.IsEmpty()) {
|
||||
NS_WARNING("no default language specified for systemLanguage conditional test");
|
||||
|
@ -1324,8 +1324,8 @@ AppNameOverrideChanged(const char* /* aPrefName */, void* /* aClosure */)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
const nsAdoptingString& override =
|
||||
mozilla::Preferences::GetString("general.appname.override");
|
||||
nsAutoString override;
|
||||
Preferences::GetString("general.appname.override", override);
|
||||
|
||||
RuntimeService* runtime = RuntimeService::GetService();
|
||||
if (runtime) {
|
||||
@ -1338,8 +1338,8 @@ AppVersionOverrideChanged(const char* /* aPrefName */, void* /* aClosure */)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
const nsAdoptingString& override =
|
||||
mozilla::Preferences::GetString("general.appversion.override");
|
||||
nsAutoString override;
|
||||
Preferences::GetString("general.appversion.override", override);
|
||||
|
||||
RuntimeService* runtime = RuntimeService::GetService();
|
||||
if (runtime) {
|
||||
@ -1352,8 +1352,8 @@ PlatformOverrideChanged(const char* /* aPrefName */, void* /* aClosure */)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
const nsAdoptingString& override =
|
||||
mozilla::Preferences::GetString("general.platform.override");
|
||||
nsAutoString override;
|
||||
Preferences::GetString("general.platform.override", override);
|
||||
|
||||
RuntimeService* runtime = RuntimeService::GetService();
|
||||
if (runtime) {
|
||||
|
@ -904,7 +904,7 @@ nsEditorSpellCheck::SetFallbackDictionary(DictionaryFetcher* aFetcher)
|
||||
|
||||
// Get the preference value.
|
||||
nsAutoString preferredDict;
|
||||
preferredDict = Preferences::GetLocalizedString("spellchecker.dictionary");
|
||||
Preferences::GetLocalizedString("spellchecker.dictionary", preferredDict);
|
||||
|
||||
if (!dictName.IsEmpty()) {
|
||||
// RFC 5646 explicitly states that matches should be case-insensitive.
|
||||
|
@ -613,7 +613,7 @@ void
|
||||
CSSEditUtils::GetDefaultBackgroundColor(nsAString& aColor)
|
||||
{
|
||||
if (Preferences::GetBool("editor.use_custom_colors", false)) {
|
||||
nsresult rv = Preferences::GetString("editor.background_color", &aColor);
|
||||
nsresult rv = Preferences::GetString("editor.background_color", aColor);
|
||||
// XXX Why don't you validate the pref value?
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("failed to get editor.background_color");
|
||||
@ -627,7 +627,7 @@ CSSEditUtils::GetDefaultBackgroundColor(nsAString& aColor)
|
||||
}
|
||||
|
||||
nsresult rv =
|
||||
Preferences::GetString("browser.display.background_color", &aColor);
|
||||
Preferences::GetString("browser.display.background_color", aColor);
|
||||
// XXX Why don't you validate the pref value?
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("failed to get browser.display.background_color");
|
||||
@ -640,7 +640,7 @@ void
|
||||
CSSEditUtils::GetDefaultLengthUnit(nsAString& aLengthUnit)
|
||||
{
|
||||
nsresult rv =
|
||||
Preferences::GetString("editor.css.default_length_unit", &aLengthUnit);
|
||||
Preferences::GetString("editor.css.default_length_unit", aLengthUnit);
|
||||
// XXX Why don't you validate the pref value?
|
||||
if (NS_FAILED(rv)) {
|
||||
aLengthUnit.AssignLiteral("px");
|
||||
|
@ -175,6 +175,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(EditorBase)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocStateListeners)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mEventTarget)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mEventListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPlaceholderTransaction)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSavedSel);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRangeUpdater);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
@ -195,6 +196,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(EditorBase)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocStateListeners)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mEventTarget)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mEventListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPlaceholderTransaction)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSavedSel);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRangeUpdater);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
@ -688,15 +690,18 @@ EditorBase::GetSelection(SelectionType aSelectionType)
|
||||
NS_IMETHODIMP
|
||||
EditorBase::DoTransaction(nsITransaction* aTxn)
|
||||
{
|
||||
if (mPlaceholderBatch && !mPlaceholderTransactionWeak) {
|
||||
RefPtr<PlaceholderTransaction> placeholderTransaction =
|
||||
return DoTransaction(nullptr, aTxn);
|
||||
}
|
||||
|
||||
nsresult
|
||||
EditorBase::DoTransaction(Selection* aSelection, nsITransaction* aTxn)
|
||||
{
|
||||
if (mPlaceholderBatch && !mPlaceholderTransaction) {
|
||||
mPlaceholderTransaction =
|
||||
new PlaceholderTransaction(*this, mPlaceholderName, Move(mSelState));
|
||||
|
||||
// Save off weak reference to placeholder transaction
|
||||
mPlaceholderTransactionWeak = placeholderTransaction;
|
||||
|
||||
// We will recurse, but will not hit this case in the nested call
|
||||
DoTransaction(placeholderTransaction);
|
||||
DoTransaction(mPlaceholderTransaction);
|
||||
|
||||
if (mTxnMgr) {
|
||||
nsCOMPtr<nsITransaction> topTransaction = mTxnMgr->PeekUndoStack();
|
||||
@ -710,7 +715,7 @@ EditorBase::DoTransaction(nsITransaction* aTxn)
|
||||
// is either the one we just created, or an earlier one that we are
|
||||
// now merging into. From here on out remember this placeholder
|
||||
// instead of the one we just created.
|
||||
mPlaceholderTransactionWeak = topPlaceholderTransaction;
|
||||
mPlaceholderTransaction = topPlaceholderTransaction;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -737,7 +742,7 @@ EditorBase::DoTransaction(nsITransaction* aTxn)
|
||||
// XXX: re-entry during initial reflow. - kin
|
||||
|
||||
// get the selection and start a batch change
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
RefPtr<Selection> selection = aSelection ? aSelection : GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
selection->StartBatchChanges();
|
||||
@ -965,7 +970,7 @@ EditorBase::BeginPlaceHolderTransaction(nsIAtom* aName)
|
||||
NotifyEditorObservers(eNotifyEditorObserversOfBefore);
|
||||
// time to turn on the batch
|
||||
BeginUpdateViewBatch();
|
||||
mPlaceholderTransactionWeak = nullptr;
|
||||
mPlaceholderTransaction = nullptr;
|
||||
mPlaceholderName = aName;
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (selection) {
|
||||
@ -1037,15 +1042,14 @@ EditorBase::EndPlaceHolderTransaction()
|
||||
mSelState = nullptr;
|
||||
}
|
||||
// We might have never made a placeholder if no action took place.
|
||||
if (mPlaceholderTransactionWeak) {
|
||||
RefPtr<PlaceholderTransaction> placeholderTransaction =
|
||||
mPlaceholderTransactionWeak.get();
|
||||
placeholderTransaction->EndPlaceHolderBatch();
|
||||
if (mPlaceholderTransaction) {
|
||||
mPlaceholderTransaction->EndPlaceHolderBatch();
|
||||
// notify editor observers of action but if composing, it's done by
|
||||
// compositionchange event handler.
|
||||
if (!mComposition) {
|
||||
NotifyEditorObservers(eNotifyEditorObserversOfEnd);
|
||||
}
|
||||
mPlaceholderTransaction = nullptr;
|
||||
} else {
|
||||
NotifyEditorObservers(eNotifyEditorObserversOfCancel);
|
||||
}
|
||||
@ -2716,7 +2720,8 @@ EditorBase::NotifyDocumentListeners(
|
||||
}
|
||||
|
||||
nsresult
|
||||
EditorBase::SetTextImpl(const nsAString& aString, Text& aCharData)
|
||||
EditorBase::SetTextImpl(Selection& aSelection, const nsAString& aString,
|
||||
Text& aCharData)
|
||||
{
|
||||
RefPtr<SetTextTransaction> transaction =
|
||||
CreateTxnForSetText(aString, aCharData);
|
||||
@ -2746,7 +2751,7 @@ EditorBase::SetTextImpl(const nsAString& aString, Text& aCharData)
|
||||
}
|
||||
}
|
||||
|
||||
nsresult rv = DoTransaction(transaction);
|
||||
nsresult rv = DoTransaction(&aSelection, transaction);
|
||||
|
||||
// Let listeners know what happened
|
||||
{
|
||||
|
@ -279,7 +279,8 @@ public:
|
||||
Text& aTextNode, int32_t aOffset,
|
||||
bool aSuppressIME = false);
|
||||
|
||||
nsresult SetTextImpl(const nsAString& aString,
|
||||
nsresult SetTextImpl(Selection& aSelection,
|
||||
const nsAString& aString,
|
||||
Text& aTextNode);
|
||||
|
||||
NS_IMETHOD DeleteSelectionImpl(EDirection aAction,
|
||||
@ -495,6 +496,10 @@ protected:
|
||||
*/
|
||||
void DoAfterRedoTransaction();
|
||||
|
||||
// Note that aSelection is optional and can be nullptr.
|
||||
nsresult DoTransaction(Selection* aSelection,
|
||||
nsITransaction* aTxn);
|
||||
|
||||
enum TDocumentListenerNotification
|
||||
{
|
||||
eDocumentCreated,
|
||||
@ -1126,8 +1131,8 @@ protected:
|
||||
// The form field as an event receiver.
|
||||
nsCOMPtr<dom::EventTarget> mEventTarget;
|
||||
nsCOMPtr<nsIDOMEventListener> mEventListener;
|
||||
// Weak reference to placeholder for begin/end batch purposes.
|
||||
WeakPtr<PlaceholderTransaction> mPlaceholderTransactionWeak;
|
||||
// Strong reference to placeholder for begin/end batch purposes.
|
||||
RefPtr<PlaceholderTransaction> mPlaceholderTransaction;
|
||||
// Name of placeholder transaction.
|
||||
nsIAtom* mPlaceholderName;
|
||||
// Saved selection state for placeholder transaction batching.
|
||||
|
@ -276,8 +276,8 @@ HTMLEditRules::Init(TextEditor* aTextEditor)
|
||||
// cache any prefs we care about
|
||||
static const char kPrefName[] =
|
||||
"editor.html.typing.returnInEmptyListItemClosesList";
|
||||
nsAdoptingCString returnInEmptyLIKillsList =
|
||||
Preferences::GetCString(kPrefName);
|
||||
nsAutoCString returnInEmptyLIKillsList;
|
||||
Preferences::GetCString(kPrefName, returnInEmptyLIKillsList);
|
||||
|
||||
// only when "false", becomes FALSE. Otherwise (including empty), TRUE.
|
||||
// XXX Why was this pref designed as a string and not bool?
|
||||
@ -476,7 +476,7 @@ HTMLEditRules::AfterEditInner(EditAction action,
|
||||
// don't let any txns in here move the selection around behind our back.
|
||||
// Note that this won't prevent explicit selection setting from working.
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(mHTMLEditor);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(mHTMLEditor);
|
||||
|
||||
// expand the "changed doc range" as needed
|
||||
PromoteRange(*mDocChangeRange, action);
|
||||
@ -1351,9 +1351,9 @@ HTMLEditRules::WillInsertText(EditAction aAction,
|
||||
// the changes one at a time.
|
||||
AutoLockListener lockit(&mListenerEnabled);
|
||||
|
||||
// don't spaz my selection in subtransactions
|
||||
// don't change my selection in subtransactions
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(mHTMLEditor);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(mHTMLEditor);
|
||||
nsAutoString tString(*inString);
|
||||
const char16_t *unicodeBuf = tString.get();
|
||||
int32_t pos = 0;
|
||||
@ -2382,7 +2382,7 @@ HTMLEditRules::WillDeleteSelection(Selection* aSelection,
|
||||
// surrounding whitespace in preparation to delete selection.
|
||||
if (!IsPlaintextEditor()) {
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(mHTMLEditor);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(mHTMLEditor);
|
||||
rv = WSRunObject::PrepareToDeleteRange(mHTMLEditor,
|
||||
address_of(startNode), &startOffset,
|
||||
address_of(endNode), &endOffset);
|
||||
@ -2755,7 +2755,7 @@ HTMLEditRules::TryToJoinBlocks(nsIContent& aLeftNode,
|
||||
}
|
||||
}
|
||||
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(htmlEditor);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(htmlEditor);
|
||||
|
||||
int32_t rightOffset = 0;
|
||||
int32_t leftOffset = -1;
|
||||
@ -3564,7 +3564,7 @@ HTMLEditRules::MakeBasicBlock(Selection& aSelection, nsIAtom& blockType)
|
||||
nsresult rv = NormalizeSelection(&aSelection);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
AutoSelectionRestorer selectionRestorer(&aSelection, htmlEditor);
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(htmlEditor);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(htmlEditor);
|
||||
|
||||
// Contruct a list of nodes to act on.
|
||||
nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
|
||||
@ -5984,7 +5984,7 @@ HTMLEditRules::GetListActionNodes(
|
||||
|
||||
{
|
||||
// We don't like other people messing with our selection!
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(htmlEditor);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(htmlEditor);
|
||||
|
||||
// contruct a list of nodes to act on.
|
||||
nsresult rv = GetNodesFromSelection(*selection, EditAction::makeList,
|
||||
|
@ -3774,7 +3774,7 @@ nsresult
|
||||
HTMLEditor::CollapseAdjacentTextNodes(nsRange* aInRange)
|
||||
{
|
||||
NS_ENSURE_TRUE(aInRange, NS_ERROR_NULL_POINTER);
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(this);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(this);
|
||||
nsTArray<nsCOMPtr<nsIDOMNode> > textNodes;
|
||||
// we can't actually do anything during iteration, so store the text nodes in an array
|
||||
// don't bother ref counting them because we know we can hold them for the
|
||||
@ -4557,7 +4557,7 @@ HTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
|
||||
AutoRules beginRulesSniffing(this, EditAction::insertElement,
|
||||
nsIEditor::eNext);
|
||||
AutoSelectionRestorer selectionRestorer(selection, this);
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(this);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(this);
|
||||
|
||||
bool cancel, handled;
|
||||
TextRulesInfo ruleInfo(EditAction::setTextProperty);
|
||||
|
@ -1151,7 +1151,7 @@ HTMLEditor::InsertFromTransferable(nsITransferable* transferable,
|
||||
transferable->GetAnyTransferData(bestFlavor,
|
||||
getter_AddRefs(genericDataObj),
|
||||
&len))) {
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(this);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(this);
|
||||
nsAutoString flavor;
|
||||
CopyASCIItoUTF16(bestFlavor, flavor);
|
||||
nsAutoString stuffToPaste;
|
||||
|
@ -126,7 +126,7 @@ HTMLEditor::SetInlineProperty(nsIAtom* aProperty,
|
||||
AutoRules beginRulesSniffing(this, EditAction::insertElement,
|
||||
nsIEditor::eNext);
|
||||
AutoSelectionRestorer selectionRestorer(selection, this);
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(this);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(this);
|
||||
|
||||
bool cancel, handled;
|
||||
TextRulesInfo ruleInfo(EditAction::setTextProperty);
|
||||
@ -1228,7 +1228,7 @@ HTMLEditor::RemoveInlinePropertyImpl(nsIAtom* aProperty,
|
||||
AutoRules beginRulesSniffing(this, EditAction::removeTextProperty,
|
||||
nsIEditor::eNext);
|
||||
AutoSelectionRestorer selectionRestorer(selection, this);
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(this);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(this);
|
||||
|
||||
bool cancel, handled;
|
||||
TextRulesInfo ruleInfo(EditAction::removeTextProperty);
|
||||
@ -1385,7 +1385,7 @@ HTMLEditor::RelativeFontChange(FontSize aDir)
|
||||
AutoRules beginRulesSniffing(this, EditAction::setTextProperty,
|
||||
nsIEditor::eNext);
|
||||
AutoSelectionRestorer selectionRestorer(selection, this);
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(this);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(this);
|
||||
|
||||
// Loop through the ranges in the selection
|
||||
AutoRangeArray arrayOfRanges(selection);
|
||||
|
@ -9,12 +9,10 @@
|
||||
#include "EditAggregateTransaction.h"
|
||||
#include "mozilla/EditorUtils.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/WeakPtr.h"
|
||||
#include "nsIAbsorbingTransaction.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -30,11 +28,8 @@ class CompositionTransaction;
|
||||
class PlaceholderTransaction final
|
||||
: public EditAggregateTransaction
|
||||
, public nsIAbsorbingTransaction
|
||||
, public SupportsWeakPtr<PlaceholderTransaction>
|
||||
{
|
||||
public:
|
||||
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(PlaceholderTransaction)
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
PlaceholderTransaction(EditorBase& aEditorBase, nsIAtom* aName,
|
||||
|
@ -317,7 +317,7 @@ TextEditRules::DidDoAction(Selection* aSelection,
|
||||
NS_ENSURE_STATE(mTextEditor);
|
||||
// don't let any txns in here move the selection around behind our back.
|
||||
// Note that this won't prevent explicit selection setting from working.
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(mTextEditor);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(mTextEditor);
|
||||
|
||||
NS_ENSURE_TRUE(aSelection && aInfo, NS_ERROR_NULL_POINTER);
|
||||
|
||||
@ -788,9 +788,9 @@ TextEditRules::WillInsertText(EditAction aAction,
|
||||
nsCOMPtr<nsINode> curNode = selNode;
|
||||
int32_t curOffset = selOffset;
|
||||
|
||||
// don't spaz my selection in subtransactions
|
||||
// don't change my selection in subtransactions
|
||||
NS_ENSURE_STATE(mTextEditor);
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(mTextEditor);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(mTextEditor);
|
||||
|
||||
rv = mTextEditor->InsertTextImpl(*outString, address_of(curNode),
|
||||
&curOffset, doc);
|
||||
@ -901,9 +901,13 @@ TextEditRules::WillSetText(Selection& aSelection,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// don't change my selection in subtransactions
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(textEditor);
|
||||
|
||||
// Even if empty text, we don't remove text node and set empty text
|
||||
// for performance
|
||||
nsresult rv = textEditor->SetTextImpl(tString, *curNode->GetAsText());
|
||||
nsresult rv = textEditor->SetTextImpl(aSelection, tString,
|
||||
*curNode->GetAsText());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -1391,7 +1395,7 @@ TextEditRules::CreateTrailingBRIfNeeded()
|
||||
NS_ENSURE_TRUE(lastChild, NS_ERROR_NULL_POINTER);
|
||||
|
||||
if (!lastChild->IsHTMLElement(nsGkAtoms::br)) {
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(mTextEditor);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(mTextEditor);
|
||||
nsCOMPtr<nsIDOMNode> domBody = do_QueryInterface(body);
|
||||
return CreateMozBR(domBody, body->Length());
|
||||
}
|
||||
|
@ -728,8 +728,8 @@ TextEditor::InsertLineBreak()
|
||||
nsCOMPtr<nsIDocument> doc = GetDocument();
|
||||
NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
// don't spaz my selection in subtransactions
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(this);
|
||||
// don't change my selection in subtransactions
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(this);
|
||||
|
||||
// insert a linefeed character
|
||||
rv = InsertTextImpl(NS_LITERAL_STRING("\n"), address_of(selNode),
|
||||
|
@ -113,7 +113,7 @@ TextEditor::InsertTextFromTransferable(nsITransferable* aTransferable,
|
||||
&len)) &&
|
||||
(bestFlavor.EqualsLiteral(kUnicodeMime) ||
|
||||
bestFlavor.EqualsLiteral(kMozTextInternal))) {
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(this);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(this);
|
||||
nsCOMPtr<nsISupportsString> textDataObj ( do_QueryInterface(genericDataObj) );
|
||||
if (textDataObj && len > 0) {
|
||||
nsAutoString stuffToPaste;
|
||||
|
@ -1424,7 +1424,7 @@ WSRunObject::ConvertToNBSP(WSPoint aPoint)
|
||||
NS_ENSURE_TRUE(aPoint.mTextNode, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// First, insert an nbsp
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(mHTMLEditor);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(mHTMLEditor);
|
||||
nsAutoString nbspStr(nbsp);
|
||||
nsresult rv =
|
||||
mHTMLEditor->InsertTextIntoTextNodeImpl(nbspStr, *aPoint.mTextNode,
|
||||
@ -1748,7 +1748,7 @@ WSRunObject::CheckTrailingNBSPOfRun(WSFragment *aRun)
|
||||
}
|
||||
if (leftCheck && rightCheck) {
|
||||
// Now replace nbsp with space. First, insert a space
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(mHTMLEditor);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(mHTMLEditor);
|
||||
nsAutoString spaceStr(char16_t(32));
|
||||
nsresult rv =
|
||||
mHTMLEditor->InsertTextIntoTextNodeImpl(spaceStr, *thePoint.mTextNode,
|
||||
@ -1779,7 +1779,7 @@ WSRunObject::CheckTrailingNBSPOfRun(WSFragment *aRun)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Finally, insert that nbsp before the ASCII ws run
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(mHTMLEditor);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(mHTMLEditor);
|
||||
nsAutoString nbspStr(nbsp);
|
||||
rv = mHTMLEditor->InsertTextIntoTextNodeImpl(nbspStr, *startNode,
|
||||
startOffset, true);
|
||||
@ -1815,7 +1815,7 @@ WSRunObject::CheckTrailingNBSP(WSFragment* aRun,
|
||||
}
|
||||
if (canConvert) {
|
||||
// First, insert a space
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(mHTMLEditor);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(mHTMLEditor);
|
||||
nsAutoString spaceStr(char16_t(32));
|
||||
nsresult rv =
|
||||
mHTMLEditor->InsertTextIntoTextNodeImpl(spaceStr, *thePoint.mTextNode,
|
||||
@ -1858,7 +1858,7 @@ WSRunObject::CheckLeadingNBSP(WSFragment* aRun,
|
||||
}
|
||||
if (canConvert) {
|
||||
// First, insert a space
|
||||
AutoTransactionsConserveSelection dontSpazMySelection(mHTMLEditor);
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(mHTMLEditor);
|
||||
nsAutoString spaceStr(char16_t(32));
|
||||
nsresult rv =
|
||||
mHTMLEditor->InsertTextIntoTextNodeImpl(spaceStr, *thePoint.mTextNode,
|
||||
|
@ -2857,7 +2857,8 @@ nsPermissionManager::Import()
|
||||
nsresult
|
||||
nsPermissionManager::ImportDefaults()
|
||||
{
|
||||
nsCString defaultsURL = mozilla::Preferences::GetCString(kDefaultsUrlPrefName);
|
||||
nsAutoCString defaultsURL;
|
||||
mozilla::Preferences::GetCString(kDefaultsUrlPrefName, defaultsURL);
|
||||
if (defaultsURL.IsEmpty()) { // == Don't use built-in permissions.
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -78,8 +78,8 @@ static PRLibrary* LoadApitraceLibrary()
|
||||
if (sApitraceLibrary)
|
||||
return sApitraceLibrary;
|
||||
|
||||
nsCString logFile = Preferences::GetCString("gfx.apitrace.logfile");
|
||||
|
||||
nsAutoCString logFile;
|
||||
Preferences::GetCString("gfx.apitrace.logfile", logFile);
|
||||
if (logFile.IsEmpty()) {
|
||||
logFile = "firefox.trace";
|
||||
}
|
||||
|
@ -351,7 +351,8 @@ DriverCrashGuard::CheckAndUpdatePref(const char* aPrefName, const nsAString& aCu
|
||||
{
|
||||
std::string pref = GetFullPrefName(aPrefName);
|
||||
|
||||
nsAdoptingString oldValue = Preferences::GetString(pref.c_str());
|
||||
nsAutoString oldValue;
|
||||
Preferences::GetString(pref.c_str(), oldValue);
|
||||
if (oldValue == aCurrentValue) {
|
||||
return false;
|
||||
}
|
||||
|
@ -991,9 +991,11 @@ gfxDWriteFontList::InitFontListForPlatform()
|
||||
}
|
||||
}
|
||||
|
||||
nsAdoptingCString classicFamilies =
|
||||
Preferences::GetCString("gfx.font_rendering.cleartype_params.force_gdi_classic_for_families");
|
||||
if (classicFamilies) {
|
||||
nsAutoCString classicFamilies;
|
||||
nsresult rv = Preferences::GetCString(
|
||||
"gfx.font_rendering.cleartype_params.force_gdi_classic_for_families",
|
||||
classicFamilies);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCCharSeparatedTokenizer tokenizer(classicFamilies, ',');
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
NS_ConvertUTF8toUTF16 name(tokenizer.nextToken());
|
||||
|
@ -1698,17 +1698,21 @@ gfxFcPlatformFontList::AddGenericFonts(mozilla::FontFamilyType aGenericType,
|
||||
if ((!mAlwaysUseFontconfigGenerics && aLanguage) ||
|
||||
aLanguage == nsGkAtoms::x_math) {
|
||||
nsIAtom* langGroup = GetLangGroup(aLanguage);
|
||||
nsAdoptingString fontlistValue =
|
||||
Preferences::GetString(NamePref(generic, langGroup).get());
|
||||
nsAutoString fontlistValue;
|
||||
Preferences::GetString(NamePref(generic, langGroup).get(),
|
||||
fontlistValue);
|
||||
nsresult rv;
|
||||
if (fontlistValue.IsEmpty()) {
|
||||
// The font name list may have two or more family names as comma
|
||||
// separated list. In such case, not matching with generic font
|
||||
// name is fine because if the list prefers specific font, we
|
||||
// should try to use the pref with complicated path.
|
||||
fontlistValue =
|
||||
Preferences::GetString(NameListPref(generic, langGroup).get());
|
||||
rv = Preferences::GetString(NameListPref(generic, langGroup).get(),
|
||||
fontlistValue);
|
||||
} else {
|
||||
rv = NS_OK;
|
||||
}
|
||||
if (fontlistValue) {
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (!fontlistValue.EqualsLiteral("serif") &&
|
||||
!fontlistValue.EqualsLiteral("sans-serif") &&
|
||||
!fontlistValue.EqualsLiteral("monospace")) {
|
||||
@ -1898,15 +1902,15 @@ gfxFcPlatformFontList::PrefFontListsUseOnlyGenerics()
|
||||
nsCCharSeparatedTokenizer tokenizer(prefName, '.');
|
||||
const nsDependentCSubstring& generic = tokenizer.nextToken();
|
||||
const nsDependentCSubstring& langGroup = tokenizer.nextToken();
|
||||
nsAdoptingCString fontPrefValue = Preferences::GetCString(names[i]);
|
||||
nsAutoCString fontPrefValue;
|
||||
Preferences::GetCString(names[i], fontPrefValue);
|
||||
if (fontPrefValue.IsEmpty()) {
|
||||
// The font name list may have two or more family names as comma
|
||||
// separated list. In such case, not matching with generic font
|
||||
// name is fine because if the list prefers specific font, this
|
||||
// should return false.
|
||||
fontPrefValue =
|
||||
Preferences::GetCString(NameListPref(generic,
|
||||
langGroup).get());
|
||||
Preferences::GetCString(NameListPref(generic, langGroup).get(),
|
||||
fontPrefValue);
|
||||
}
|
||||
|
||||
if (!langGroup.EqualsLiteral("x-math") &&
|
||||
|
@ -860,8 +860,9 @@ void gfxFontUtils::AppendPrefsFontList(const char *aPrefName,
|
||||
nsTArray<nsString>& aFontList)
|
||||
{
|
||||
// get the list of single-face font families
|
||||
nsAdoptingString fontlistValue = Preferences::GetString(aPrefName);
|
||||
if (!fontlistValue) {
|
||||
nsAutoString fontlistValue;
|
||||
nsresult rv = Preferences::GetString(aPrefName, fontlistValue);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -570,9 +570,9 @@ void RecordingPrefChanged(const char *aPrefName, void *aClosure)
|
||||
{
|
||||
if (Preferences::GetBool("gfx.2d.recording", false)) {
|
||||
nsAutoCString fileName;
|
||||
nsAdoptingString prefFileName = Preferences::GetString("gfx.2d.recordingfile");
|
||||
|
||||
if (prefFileName) {
|
||||
nsAutoString prefFileName;
|
||||
nsresult rv = Preferences::GetString("gfx.2d.recordingfile", prefFileName);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
fileName.Append(NS_ConvertUTF16toUTF8(prefFileName));
|
||||
} else {
|
||||
nsCOMPtr<nsIFile> tmpFile;
|
||||
@ -645,8 +645,12 @@ gfxPlatform::Init()
|
||||
gfxVars::SetPDMWMFDisableD3D11Dlls(nsCString());
|
||||
gfxVars::SetPDMWMFDisableD3D9Dlls(nsCString());
|
||||
} else {
|
||||
gfxVars::SetPDMWMFDisableD3D11Dlls(Preferences::GetCString("media.wmf.disable-d3d11-for-dlls"));
|
||||
gfxVars::SetPDMWMFDisableD3D9Dlls(Preferences::GetCString("media.wmf.disable-d3d9-for-dlls"));
|
||||
nsAutoCString d3d11;
|
||||
Preferences::GetCString("media.wmf.disable-d3d11-for-dlls", d3d11);
|
||||
gfxVars::SetPDMWMFDisableD3D11Dlls(d3d11);
|
||||
nsAutoCString d3d9;
|
||||
Preferences::GetCString("media.wmf.disable-d3d9-for-dlls", d3d9);
|
||||
gfxVars::SetPDMWMFDisableD3D9Dlls(d3d9);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
@ -1825,8 +1829,8 @@ gfxPlatform::GetContentBackendPref(uint32_t &aBackendBitmask)
|
||||
gfxPlatform::GetBackendPref(const char* aBackendPrefName, uint32_t &aBackendBitmask)
|
||||
{
|
||||
nsTArray<nsCString> backendList;
|
||||
nsCString prefString;
|
||||
if (NS_SUCCEEDED(Preferences::GetCString(aBackendPrefName, &prefString))) {
|
||||
nsAutoCString prefString;
|
||||
if (NS_SUCCEEDED(Preferences::GetCString(aBackendPrefName, prefString))) {
|
||||
ParseString(prefString, ',', backendList);
|
||||
}
|
||||
|
||||
@ -1942,9 +1946,10 @@ gfxPlatform::GetPlatformCMSOutputProfile(void *&mem, size_t &size)
|
||||
void
|
||||
gfxPlatform::GetCMSOutputProfileData(void *&mem, size_t &size)
|
||||
{
|
||||
nsAdoptingCString fname = Preferences::GetCString("gfx.color_management.display_profile");
|
||||
nsAutoCString fname;
|
||||
Preferences::GetCString("gfx.color_management.display_profile", fname);
|
||||
if (!fname.IsEmpty()) {
|
||||
qcms_data_from_path(fname, &mem, &size);
|
||||
qcms_data_from_path(fname.get(), &mem, &size);
|
||||
}
|
||||
else {
|
||||
gfxPlatform::GetPlatform()->GetPlatformCMSOutputProfile(mem, size);
|
||||
|
@ -1089,7 +1089,8 @@ gfxPlatformFontList::AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], uint32_t &aL
|
||||
uint32_t tempLen = 0;
|
||||
|
||||
// Add the CJK pref fonts from accept languages, the order should be same order
|
||||
nsAdoptingCString list = Preferences::GetLocalizedCString("intl.accept_languages");
|
||||
nsAutoCString list;
|
||||
Preferences::GetLocalizedCString("intl.accept_languages", list);
|
||||
if (!list.IsEmpty()) {
|
||||
const char kComma = ',';
|
||||
const char *p, *p_end;
|
||||
@ -1215,8 +1216,8 @@ gfxPlatformFontList::GetDefaultGeneric(eFontPrefLang aLang)
|
||||
for (uint32_t i = 0; i < ArrayLength(gPrefLangNames); i++) {
|
||||
nsAutoCString prefDefaultFontType("font.default.");
|
||||
prefDefaultFontType.Append(GetPrefLangName(eFontPrefLang(i)));
|
||||
nsAdoptingCString serifOrSans =
|
||||
Preferences::GetCString(prefDefaultFontType.get());
|
||||
nsAutoCString serifOrSans;
|
||||
Preferences::GetCString(prefDefaultFontType.get(), serifOrSans);
|
||||
if (serifOrSans.EqualsLiteral("sans-serif")) {
|
||||
mDefaultGenericsLangGroup[i] = eFamily_sans_serif;
|
||||
} else {
|
||||
|
@ -198,7 +198,7 @@ std::string gfxPrefs::PrefGet(const char* aPref, std::string aDefault)
|
||||
MOZ_ASSERT(IsPrefsServiceAvailable());
|
||||
|
||||
nsAdoptingCString result;
|
||||
Preferences::GetCString(aPref, &result);
|
||||
Preferences::GetCString(aPref, result);
|
||||
|
||||
if (result.IsEmpty()) {
|
||||
return aDefault;
|
||||
|
@ -115,18 +115,16 @@ LoadOSVRRuntime()
|
||||
static PRLibrary* osvrClientLib = nullptr;
|
||||
static PRLibrary* osvrClientKitLib = nullptr;
|
||||
//this looks up the path in the about:config setting, from greprefs.js or modules\libpref\init\all.js
|
||||
nsAdoptingCString osvrUtilPath =
|
||||
mozilla::Preferences::GetCString("gfx.vr.osvr.utilLibPath");
|
||||
nsAdoptingCString osvrCommonPath =
|
||||
mozilla::Preferences::GetCString("gfx.vr.osvr.commonLibPath");
|
||||
nsAdoptingCString osvrClientPath =
|
||||
mozilla::Preferences::GetCString("gfx.vr.osvr.clientLibPath");
|
||||
nsAdoptingCString osvrClientKitPath =
|
||||
mozilla::Preferences::GetCString("gfx.vr.osvr.clientKitLibPath");
|
||||
|
||||
//we need all the libs to be valid
|
||||
if ((!osvrUtilPath) || (!osvrCommonPath) || (!osvrClientPath) ||
|
||||
(!osvrClientKitPath)) {
|
||||
nsAutoCString osvrUtilPath, osvrCommonPath, osvrClientPath, osvrClientKitPath;
|
||||
if (NS_FAILED(mozilla::Preferences::GetCString("gfx.vr.osvr.utilLibPath",
|
||||
osvrUtilPath)) ||
|
||||
NS_FAILED(mozilla::Preferences::GetCString("gfx.vr.osvr.commonLibPath",
|
||||
osvrCommonPath)) ||
|
||||
NS_FAILED(mozilla::Preferences::GetCString("gfx.vr.osvr.clientLibPath",
|
||||
osvrClientPath)) ||
|
||||
NS_FAILED(mozilla::Preferences::GetCString("gfx.vr.osvr.clientKitLibPath",
|
||||
osvrClientKitPath))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1346,12 +1346,13 @@ imgLoader::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
|
||||
void imgLoader::ReadAcceptHeaderPref()
|
||||
{
|
||||
nsAdoptingCString accept = Preferences::GetCString("image.http.accept");
|
||||
if (accept) {
|
||||
nsAutoCString accept;
|
||||
nsresult rv = Preferences::GetCString("image.http.accept", accept);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mAcceptHeader = accept;
|
||||
} else {
|
||||
mAcceptHeader =
|
||||
IMAGE_PNG "," IMAGE_WILDCARD ";q=0.8," ANY_WILDCARD ";q=0.5";
|
||||
IMAGE_PNG "," IMAGE_WILDCARD ";q=0.8," ANY_WILDCARD ";q=0.5";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,8 +305,9 @@ nsHyphenationManager::LoadAliases()
|
||||
&prefCount, &prefNames);
|
||||
if (NS_SUCCEEDED(rv) && prefCount > 0) {
|
||||
for (uint32_t i = 0; i < prefCount; ++i) {
|
||||
nsAdoptingCString value = Preferences::GetCString(prefNames[i]);
|
||||
if (value) {
|
||||
nsAutoCString value;
|
||||
rv = Preferences::GetCString(prefNames[i], value);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsAutoCString alias(prefNames[i]);
|
||||
alias.Cut(0, sizeof(kIntlHyphenationAliasPrefix) - 1);
|
||||
ToLowerCase(alias);
|
||||
|
@ -95,7 +95,7 @@ ReadRequestedLocales(nsTArray<nsCString>& aRetVal)
|
||||
}
|
||||
|
||||
// Otherwise, we'll try to get the requested locale from the prefs.
|
||||
if (!NS_SUCCEEDED(Preferences::GetCString(SELECTED_LOCALE_PREF, &locale))) {
|
||||
if (!NS_SUCCEEDED(Preferences::GetCString(SELECTED_LOCALE_PREF, locale))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -512,12 +512,12 @@ LocaleService::IsAppLocaleRTL()
|
||||
// the locale. If that isn't set, default to left-to-right.
|
||||
nsAutoCString prefString = NS_LITERAL_CSTRING("intl.uidirection.") + locale;
|
||||
nsAutoCString dir;
|
||||
Preferences::GetCString(prefString.get(), &dir);
|
||||
Preferences::GetCString(prefString.get(), dir);
|
||||
if (dir.IsEmpty()) {
|
||||
int32_t hyphen = prefString.FindChar('-');
|
||||
if (hyphen >= 1) {
|
||||
prefString.Truncate(hyphen);
|
||||
Preferences::GetCString(prefString.get(), &dir);
|
||||
Preferences::GetCString(prefString.get(), dir);
|
||||
}
|
||||
}
|
||||
return dir.EqualsLiteral("rtl");
|
||||
|
@ -19,7 +19,8 @@ OSPreferences::ReadSystemLocales(nsTArray<nsCString>& aLocaleList)
|
||||
//XXX: Notice, this value may be empty on an early read. In that case
|
||||
// we won't add anything to the return list so that it doesn't get
|
||||
// cached in mSystemLocales.
|
||||
nsAdoptingCString locale = Preferences::GetCString("intl.locale.os");
|
||||
nsAutoCString locale;
|
||||
Preferences::GetCString("intl.locale.os", locale);
|
||||
if (!locale.IsEmpty()) {
|
||||
aLocaleList.AppendElement(locale);
|
||||
return true;
|
||||
|
@ -154,7 +154,7 @@ NS_IMETHODIMP nsTextToSubURI::UnEscapeURIForUI(const nsACString & aCharset,
|
||||
if (mUnsafeChars.IsEmpty()) {
|
||||
nsAdoptingString blacklist;
|
||||
nsresult rv = mozilla::Preferences::GetString("network.IDN.blacklist_chars",
|
||||
&blacklist);
|
||||
blacklist);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// we allow SPACE and IDEOGRAPHIC SPACE in this method
|
||||
blacklist.StripChars(u" \u3000");
|
||||
|
@ -73,9 +73,11 @@ ForbidCPOWsInCompatibleAddon(const nsACString& aAddonId)
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCString allow;
|
||||
nsAutoCString allow;
|
||||
allow.Assign(',');
|
||||
allow.Append(Preferences::GetCString("dom.ipc.cpows.allow-cpows-in-compat-addons"));
|
||||
nsAutoCString pref;
|
||||
Preferences::GetCString("dom.ipc.cpows.allow-cpows-in-compat-addons", pref);
|
||||
allow.Append(pref);
|
||||
allow.Append(',');
|
||||
|
||||
nsCString searchString(",");
|
||||
|
@ -488,6 +488,54 @@ GetBuiltinTagSlow(JSContext* cx, HandleObject obj, MutableHandleString builtinTa
|
||||
}
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE JSString*
|
||||
GetBuiltinTagFast(JSObject* obj, const Class* clasp, JSContext* cx)
|
||||
{
|
||||
MOZ_ASSERT(clasp == obj->getClass());
|
||||
MOZ_ASSERT(!clasp->isProxy());
|
||||
|
||||
// Optimize the non-proxy case to bypass GetBuiltinClass.
|
||||
if (clasp == &PlainObject::class_ || clasp == &UnboxedPlainObject::class_) {
|
||||
// This is not handled by GetBuiltinTagSlow, but this case is by far
|
||||
// the most common so we optimize it here.
|
||||
return cx->names().objectObject;
|
||||
}
|
||||
|
||||
if (clasp == &ArrayObject::class_ || clasp == &UnboxedArrayObject::class_)
|
||||
return cx->names().objectArray;
|
||||
|
||||
if (clasp == &JSFunction::class_)
|
||||
return cx->names().objectFunction;
|
||||
|
||||
if (clasp == &StringObject::class_)
|
||||
return cx->names().objectString;
|
||||
|
||||
if (clasp == &NumberObject::class_)
|
||||
return cx->names().objectNumber;
|
||||
|
||||
if (clasp == &BooleanObject::class_)
|
||||
return cx->names().objectBoolean;
|
||||
|
||||
if (clasp == &DateObject::class_)
|
||||
return cx->names().objectDate;
|
||||
|
||||
if (clasp == &RegExpObject::class_)
|
||||
return cx->names().objectRegExp;
|
||||
|
||||
if (obj->is<ArgumentsObject>())
|
||||
return cx->names().objectArguments;
|
||||
|
||||
if (obj->is<ErrorObject>())
|
||||
return cx->names().objectError;
|
||||
|
||||
if (obj->isCallable() && !obj->getClass()->isDOMClass()) {
|
||||
// Non-standard: Prevent <object> from showing up as Function.
|
||||
return cx->names().objectFunction;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// ES6 19.1.3.6
|
||||
bool
|
||||
js::obj_toString(JSContext* cx, unsigned argc, Value* vp)
|
||||
@ -517,43 +565,7 @@ js::obj_toString(JSContext* cx, unsigned argc, Value* vp)
|
||||
if (!GetBuiltinTagSlow(cx, obj, &builtinTag))
|
||||
return false;
|
||||
} else {
|
||||
// Optimize the non-proxy case to bypass GetBuiltinClass.
|
||||
if (clasp == &PlainObject::class_ || clasp == &UnboxedPlainObject::class_) {
|
||||
// This is not handled by GetBuiltinTagSlow, but this case is by far
|
||||
// the most common so we optimize it here.
|
||||
builtinTag = cx->names().objectObject;
|
||||
|
||||
} else if (clasp == &ArrayObject::class_ || clasp == &UnboxedArrayObject::class_) {
|
||||
builtinTag = cx->names().objectArray;
|
||||
|
||||
} else if (clasp == &JSFunction::class_) {
|
||||
builtinTag = cx->names().objectFunction;
|
||||
|
||||
} else if (clasp == &StringObject::class_) {
|
||||
builtinTag = cx->names().objectString;
|
||||
|
||||
} else if (clasp == &NumberObject::class_) {
|
||||
builtinTag = cx->names().objectNumber;
|
||||
|
||||
} else if (clasp == &BooleanObject::class_) {
|
||||
builtinTag = cx->names().objectBoolean;
|
||||
|
||||
} else if (clasp == &DateObject::class_) {
|
||||
builtinTag = cx->names().objectDate;
|
||||
|
||||
} else if (clasp == &RegExpObject::class_) {
|
||||
builtinTag = cx->names().objectRegExp;
|
||||
|
||||
} else if (obj->is<ArgumentsObject>()) {
|
||||
builtinTag = cx->names().objectArguments;
|
||||
|
||||
} else if (obj->is<ErrorObject>()) {
|
||||
builtinTag = cx->names().objectError;
|
||||
|
||||
} else if (obj->isCallable() && !obj->getClass()->isDOMClass()) {
|
||||
// Non-standard: Prevent <object> from showing up as Function.
|
||||
builtinTag = cx->names().objectFunction;
|
||||
}
|
||||
builtinTag = GetBuiltinTagFast(obj, clasp, cx);
|
||||
#ifdef DEBUG
|
||||
// Assert this fast path is correct and matches BuiltinTagSlow. The
|
||||
// only exception is the PlainObject case: we special-case it here
|
||||
@ -610,6 +622,26 @@ js::obj_toString(JSContext* cx, unsigned argc, Value* vp)
|
||||
return true;
|
||||
}
|
||||
|
||||
JSString*
|
||||
js::ObjectClassToString(JSContext* cx, HandleObject obj)
|
||||
{
|
||||
const Class* clasp = obj->getClass();
|
||||
|
||||
if (JSString* tag = GetBuiltinTagFast(obj, clasp, cx))
|
||||
return tag;
|
||||
|
||||
const char* className = clasp->name;
|
||||
StringBuffer sb(cx);
|
||||
if (!sb.append("[object ") ||
|
||||
!sb.append(className, strlen(className)) ||
|
||||
!sb.append(']'))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return sb.finishAtom();
|
||||
}
|
||||
|
||||
static bool
|
||||
obj_setPrototypeOf(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
@ -1509,7 +1541,7 @@ static const JSFunctionSpec object_methods[] = {
|
||||
#if JS_HAS_TOSOURCE
|
||||
JS_FN(js_toSource_str, obj_toSource, 0,0),
|
||||
#endif
|
||||
JS_FN(js_toString_str, obj_toString, 0,0),
|
||||
JS_INLINABLE_FN(js_toString_str, obj_toString, 0,0, ObjectToString),
|
||||
JS_SELF_HOSTED_FN(js_toLocaleString_str, "Object_toLocaleString", 0, 0),
|
||||
JS_SELF_HOSTED_FN(js_valueOf_str, "Object_valueOf", 0,0),
|
||||
#if JS_HAS_OBJ_WATCHPOINT
|
||||
|
@ -55,6 +55,9 @@ obj_isExtensible(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
MOZ_MUST_USE bool
|
||||
obj_toString(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
|
||||
JSString*
|
||||
ObjectClassToString(JSContext* cx, HandleObject obj);
|
||||
|
||||
// Exposed so SelfHosting.cpp can use it in the OwnPropertyKeys intrinsic
|
||||
MOZ_MUST_USE bool
|
||||
GetOwnPropertyKeys(JSContext* cx, const JS::CallArgs& args, unsigned flags);
|
||||
|
@ -63,10 +63,10 @@ function FUNC_NAME(rx, S, lengthS, replaceValue, fullUnicode
|
||||
var matched = result[0];
|
||||
|
||||
// Step 14.d.
|
||||
var matchLength = matched.length;
|
||||
var matchLength = matched.length | 0;
|
||||
|
||||
// Steps 14.e-f.
|
||||
var position = result.index;
|
||||
var position = result.index | 0;
|
||||
lastIndex = position + matchLength;
|
||||
|
||||
// Steps g-k.
|
||||
@ -107,6 +107,7 @@ function FUNC_NAME(rx, S, lengthS, replaceValue, fullUnicode
|
||||
lastIndex = fullUnicode ? AdvanceStringIndex(S, lastIndex) : lastIndex + 1;
|
||||
if (lastIndex > lengthS)
|
||||
break;
|
||||
lastIndex |= 0;
|
||||
}
|
||||
|
||||
#if defined(FUNCTIONAL) || defined(ELEMBASE)
|
||||
|
@ -516,7 +516,7 @@ FOR_EACH_NURSERY_PROFILE_TIME(EXTRACT_NAME)
|
||||
/* static */ void
|
||||
js::Nursery::printProfileHeader()
|
||||
{
|
||||
fprintf(stderr, "MinorGC: Reason PRate Size ");
|
||||
fprintf(stderr, "MinorGC: Reason PRate Size ");
|
||||
#define PRINT_HEADER(name, text) \
|
||||
fprintf(stderr, " %6s", text);
|
||||
FOR_EACH_NURSERY_PROFILE_TIME(PRINT_HEADER)
|
||||
@ -536,7 +536,7 @@ void
|
||||
js::Nursery::printTotalProfileTimes()
|
||||
{
|
||||
if (enableProfiling_) {
|
||||
fprintf(stderr, "MinorGC TOTALS: %7" PRIu64 " collections: ", minorGcCount_);
|
||||
fprintf(stderr, "MinorGC TOTALS: %7" PRIu64 " collections: ", minorGcCount_);
|
||||
printProfileDurations(totalDurations_);
|
||||
}
|
||||
}
|
||||
@ -669,7 +669,7 @@ js::Nursery::collect(JS::gcreason::Reason reason)
|
||||
if (enableProfiling_ && totalTime >= profileThreshold_) {
|
||||
rt->gc.stats().maybePrintProfileHeaders();
|
||||
|
||||
fprintf(stderr, "MinorGC: %20s %5.1f%% %4u ",
|
||||
fprintf(stderr, "MinorGC: %20s %5.1f%% %4u ",
|
||||
JS::gcreason::ExplainReason(reason),
|
||||
promotionRate * 100,
|
||||
numChunks());
|
||||
|
@ -462,6 +462,13 @@ Statistics::formatDetailedSliceDescription(unsigned i, const SliceData& slice) c
|
||||
return DuplicateString(buffer);
|
||||
}
|
||||
|
||||
static bool
|
||||
IncludePhase(TimeDuration duration)
|
||||
{
|
||||
// Don't include durations that will print as "0.000ms".
|
||||
return duration.ToMilliseconds() >= 0.001;
|
||||
}
|
||||
|
||||
UniqueChars
|
||||
Statistics::formatDetailedPhaseTimes(const PhaseTimeTable& phaseTimes) const
|
||||
{
|
||||
@ -473,15 +480,15 @@ Statistics::formatDetailedPhaseTimes(const PhaseTimeTable& phaseTimes) const
|
||||
uint8_t level = phases[phase].depth;
|
||||
TimeDuration ownTime = phaseTimes[phase];
|
||||
TimeDuration childTime = SumChildTimes(phase, phaseTimes);
|
||||
if (!ownTime.IsZero()) {
|
||||
SprintfLiteral(buffer, " %*s: %.3fms\n",
|
||||
level * 2, phases[phase].name, t(ownTime));
|
||||
if (IncludePhase(ownTime)) {
|
||||
SprintfLiteral(buffer, " %*s%s: %.3fms\n",
|
||||
level * 2, "", phases[phase].name, t(ownTime));
|
||||
if (!fragments.append(DuplicateString(buffer)))
|
||||
return UniqueChars(nullptr);
|
||||
|
||||
if (childTime && (ownTime - childTime) > MaxUnaccountedChildTime) {
|
||||
SprintfLiteral(buffer, " %*s: %.3fms\n",
|
||||
(level + 1) * 2, "Other", t(ownTime - childTime));
|
||||
SprintfLiteral(buffer, " %*s%s: %.3fms\n",
|
||||
(level + 1) * 2, "", "Other", t(ownTime - childTime));
|
||||
if (!fragments.append(DuplicateString(buffer)))
|
||||
return UniqueChars(nullptr);
|
||||
}
|
||||
@ -1298,12 +1305,8 @@ Statistics::maybePrintProfileHeaders()
|
||||
static int printedHeader = 0;
|
||||
if ((printedHeader++ % 200) == 0) {
|
||||
printProfileHeader();
|
||||
for (ZoneGroupsIter group(runtime); !group.done(); group.next()) {
|
||||
if (group->nursery().enableProfiling()) {
|
||||
Nursery::printProfileHeader();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (runtime->gc.nursery().enableProfiling())
|
||||
Nursery::printProfileHeader();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1313,7 +1316,8 @@ Statistics::printProfileHeader()
|
||||
if (!enableProfiling_)
|
||||
return;
|
||||
|
||||
fprintf(stderr, "MajorGC: Reason States ");
|
||||
fprintf(stderr, "MajorGC: Reason States SRN ");
|
||||
fprintf(stderr, " %6s", "budget");
|
||||
fprintf(stderr, " %6s", "total");
|
||||
#define PRINT_PROFILE_HEADER(name, text, phase) \
|
||||
fprintf(stderr, " %6s", text);
|
||||
@ -1337,8 +1341,21 @@ Statistics::printSliceProfile()
|
||||
|
||||
maybePrintProfileHeaders();
|
||||
|
||||
fprintf(stderr, "MajorGC: %20s %1d -> %1d ",
|
||||
ExplainReason(slice.reason), int(slice.initialState), int(slice.finalState));
|
||||
bool shrinking = gckind == GC_SHRINK;
|
||||
bool reset = slice.resetReason != AbortReason::None;
|
||||
bool nonIncremental = nonincrementalReason_ != AbortReason::None;
|
||||
|
||||
fprintf(stderr, "MajorGC: %20s %1d -> %1d %1s%1s%1s ",
|
||||
ExplainReason(slice.reason),
|
||||
int(slice.initialState), int(slice.finalState),
|
||||
shrinking ? "S" : "",
|
||||
reset ? "R" : "",
|
||||
nonIncremental ? "N" : "");
|
||||
|
||||
if (!nonIncremental && !slice.budget.isUnlimited() && slice.budget.isTimeBudget())
|
||||
fprintf(stderr, " %6" PRIi64, static_cast<int64_t>(slice.budget.timeBudget.budget));
|
||||
else
|
||||
fprintf(stderr, " ");
|
||||
|
||||
ProfileDurations times;
|
||||
times[ProfileKey::Total] = slice.duration();
|
||||
@ -1357,7 +1374,7 @@ void
|
||||
Statistics::printTotalProfileTimes()
|
||||
{
|
||||
if (enableProfiling_) {
|
||||
fprintf(stderr, "MajorGC TOTALS: %7" PRIu64 " slices: ", sliceCount_);
|
||||
fprintf(stderr, "MajorGC TOTALS: %7" PRIu64 " slices: ", sliceCount_);
|
||||
printProfileTimes(totalTimes_);
|
||||
}
|
||||
}
|
||||
|
@ -80,15 +80,15 @@ struct ZoneGCStats
|
||||
|
||||
#define FOR_EACH_GC_PROFILE_TIME(_) \
|
||||
_(BeginCallback, "bgnCB", PhaseKind::GC_BEGIN) \
|
||||
_(MinorForMajor, "evct4m", PhaseKind::EVICT_NURSERY_FOR_MAJOR_GC) \
|
||||
_(WaitBgThread, "waitBG", PhaseKind::WAIT_BACKGROUND_THREAD) \
|
||||
_(DiscardCode, "discrd", PhaseKind::MARK_DISCARD_CODE) \
|
||||
_(RelazifyFunc, "relzfy", PhaseKind::RELAZIFY_FUNCTIONS) \
|
||||
_(PurgeTables, "prgTbl", PhaseKind::PURGE_SHAPE_TABLES) \
|
||||
_(Purge, "purge", PhaseKind::PURGE) \
|
||||
_(Prepare, "prep", PhaseKind::PREPARE) \
|
||||
_(Mark, "mark", PhaseKind::MARK) \
|
||||
_(Sweep, "sweep", PhaseKind::SWEEP) \
|
||||
_(Compact, "cmpct", PhaseKind::COMPACT) \
|
||||
_(EndCallback, "endCB", PhaseKind::GC_END) \
|
||||
_(MinorGC, "minor", PhaseKind::MINOR_GC) \
|
||||
_(EvictNursery, "evict", PhaseKind::EVICT_NURSERY) \
|
||||
_(Barriers, "brrier", PhaseKind::BARRIER)
|
||||
|
||||
const char* ExplainAbortReason(gc::AbortReason reason);
|
||||
|
45
js/src/jit-test/tests/ion/object-prototype-tostring.js
Normal file
45
js/src/jit-test/tests/ion/object-prototype-tostring.js
Normal file
@ -0,0 +1,45 @@
|
||||
var toString = Object.prototype.toString;
|
||||
var iter = 500;
|
||||
|
||||
function testConstant() {
|
||||
for (var i = 0; i < iter; i++) {
|
||||
assertEq(({}).toString(), "[object Object]");
|
||||
assertEq(toString.call([]), "[object Array]");
|
||||
assertEq(toString.call(Math.abs), "[object Function]");
|
||||
}
|
||||
}
|
||||
testConstant();
|
||||
|
||||
function testOwnToStringTag() {
|
||||
var stringify = o => toString.call(o);
|
||||
var o = {};
|
||||
for (var i = 0; i < iter; i++)
|
||||
assertEq(stringify(o), "[object Object]");
|
||||
o[Symbol.toStringTag] = "foo";
|
||||
for (var i = 0; i < iter; i++)
|
||||
assertEq(stringify(o), "[object foo]");
|
||||
}
|
||||
testOwnToStringTag();
|
||||
|
||||
function testDynamic() {
|
||||
var arr = [{}, [], new Date, /a/];
|
||||
var expected = ["[object Object]", "[object Array]", "[object Date]", "[object RegExp]"];
|
||||
for (var i = 0; i < iter; i++) {
|
||||
for (var j = 0; j < arr.length; j++)
|
||||
assertEq(toString.call(arr[j]), expected[j]);
|
||||
}
|
||||
}
|
||||
testDynamic();
|
||||
|
||||
function testToStringTagProto() {
|
||||
var c = 0;
|
||||
Object.defineProperty(Date.prototype, Symbol.toStringTag, {get() { c++; return "evil"; }});
|
||||
var arr = [{}, [], new Date, /a/];
|
||||
var expected = ["[object Object]", "[object Array]", "[object evil]", "[object RegExp]"];
|
||||
for (var i = 0; i < iter; i++) {
|
||||
for (var j = 0; j < arr.length; j++)
|
||||
assertEq(toString.call(arr[j]), expected[j]);
|
||||
}
|
||||
assertEq(c, iter);
|
||||
}
|
||||
testToStringTagProto();
|
@ -12131,6 +12131,17 @@ CodeGenerator::visitHasClass(LHasClass* ins)
|
||||
masm.cmpPtrSet(Assembler::Equal, output, ImmPtr(ins->mir()->getClass()), output);
|
||||
}
|
||||
|
||||
typedef JSString* (*ObjectClassToStringFn)(JSContext*, HandleObject);
|
||||
static const VMFunction ObjectClassToStringInfo =
|
||||
FunctionInfo<ObjectClassToStringFn>(js::ObjectClassToString, "ObjectClassToString");
|
||||
|
||||
void
|
||||
CodeGenerator::visitObjectClassToString(LObjectClassToString* lir)
|
||||
{
|
||||
pushArg(ToRegister(lir->object()));
|
||||
callVM(ObjectClassToStringInfo, lir);
|
||||
}
|
||||
|
||||
void
|
||||
CodeGenerator::visitWasmParameter(LWasmParameter* lir)
|
||||
{
|
||||
|
@ -394,6 +394,7 @@ class CodeGenerator final : public CodeGeneratorSpecific
|
||||
void visitIsObject(LIsObject* lir);
|
||||
void visitIsObjectAndBranch(LIsObjectAndBranch* lir);
|
||||
void visitHasClass(LHasClass* lir);
|
||||
void visitObjectClassToString(LObjectClassToString* lir);
|
||||
void visitWasmParameter(LWasmParameter* lir);
|
||||
void visitWasmParameterI64(LWasmParameterI64* lir);
|
||||
void visitWasmReturn(LWasmReturn* ret);
|
||||
|
@ -88,6 +88,7 @@
|
||||
_(IntrinsicStringSplitString) \
|
||||
\
|
||||
_(ObjectCreate) \
|
||||
_(ObjectToString) \
|
||||
\
|
||||
_(SimdInt32x4) \
|
||||
_(SimdUint32x4) \
|
||||
|
@ -5091,14 +5091,13 @@ IonBuilder::jsop_funcall(uint32_t argc)
|
||||
case InliningDecision_DontInline:
|
||||
case InliningDecision_WarmUpCountTooLow:
|
||||
break;
|
||||
case InliningDecision_Inline:
|
||||
if (target->isInterpreted()) {
|
||||
InliningStatus status;
|
||||
MOZ_TRY_VAR(status, inlineScriptedCall(callInfo, target));
|
||||
if (status == InliningStatus_Inlined)
|
||||
return Ok();
|
||||
}
|
||||
case InliningDecision_Inline: {
|
||||
InliningStatus status;
|
||||
MOZ_TRY_VAR(status, inlineSingleCall(callInfo, target));
|
||||
if (status == InliningStatus_Inlined)
|
||||
return Ok();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5324,13 +5323,12 @@ IonBuilder::jsop_funapplyarguments(uint32_t argc)
|
||||
case InliningDecision_DontInline:
|
||||
case InliningDecision_WarmUpCountTooLow:
|
||||
break;
|
||||
case InliningDecision_Inline:
|
||||
if (target->isInterpreted()) {
|
||||
InliningStatus status;
|
||||
MOZ_TRY_VAR(status, inlineScriptedCall(callInfo, target));
|
||||
if (status == InliningStatus_Inlined)
|
||||
return Ok();
|
||||
}
|
||||
case InliningDecision_Inline: {
|
||||
InliningStatus status;
|
||||
MOZ_TRY_VAR(status, inlineSingleCall(callInfo, target));
|
||||
if (status == InliningStatus_Inlined)
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
|
||||
return makeCall(target, callInfo);
|
||||
|
@ -683,6 +683,7 @@ class IonBuilder
|
||||
|
||||
// Object natives and intrinsics.
|
||||
InliningResult inlineObjectCreate(CallInfo& callInfo);
|
||||
InliningResult inlineObjectToString(CallInfo& callInfo);
|
||||
InliningResult inlineDefineDataProperty(CallInfo& callInfo);
|
||||
|
||||
// Atomics natives.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user