Bug 1417940 - Change various instances of manually calling getService to use Services.jsm in toolkit/. r=mossop

MozReview-Commit-ID: 8eEhjFZc4mT

--HG--
extra : rebase_source : fa73ef148c0ea38226e11824e683daab43f2c0b8
This commit is contained in:
Mark Banner 2017-11-09 16:36:57 +00:00
Родитель 1f62c1d92b
Коммит 4831d3ed89
37 изменённых файлов: 167 добавлений и 309 удалений

Просмотреть файл

@ -2,26 +2,25 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
// get release notes and vendor URL from prefs
var formatter = Components.classes["@mozilla.org/toolkit/URLFormatterService;1"]
.getService(Components.interfaces.nsIURLFormatter);
var releaseNotesURL = formatter.formatURLPref("app.releaseNotesURL");
var releaseNotesURL = Services.urlFormatter.formatURLPref("app.releaseNotesURL");
if (releaseNotesURL != "about:blank") {
var relnotes = document.getElementById("releaseNotesURL");
relnotes.setAttribute("href", releaseNotesURL);
relnotes.parentNode.removeAttribute("hidden");
}
var vendorURL = formatter.formatURLPref("app.vendorURL");
var vendorURL = Services.urlFormatter.formatURLPref("app.vendorURL");
if (vendorURL != "about:blank") {
var vendor = document.getElementById("vendorURL");
vendor.setAttribute("href", vendorURL);
}
// insert the version of the XUL application (!= XULRunner platform version)
var versionNum = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULAppInfo)
.version;
var versionNum = Services.appinfo.version;
var version = document.getElementById("version");
version.textContent += " " + versionNum;

Просмотреть файл

@ -4,6 +4,9 @@
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
var gProtocols = [];
var gContainer;
window.onload = function() {
@ -12,7 +15,6 @@ window.onload = function() {
};
function findAbouts() {
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
for (var cid in Cc) {
var result = cid.match(/@mozilla.org\/network\/protocol\/about;1\?what\=(.*)$/);
if (result) {
@ -20,7 +22,7 @@ function findAbouts() {
var contract = "@mozilla.org/network/protocol/about;1?what=" + aboutType;
try {
var am = Cc[contract].getService(Ci.nsIAboutModule);
var uri = ios.newURI("about:" + aboutType);
var uri = Services.io.newURI("about:" + aboutType);
var flags = am.getURIFlags(uri);
if (!(flags & Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT)) {
gProtocols.push(aboutType);

Просмотреть файл

@ -27,9 +27,7 @@ const bundle = Services.strings.createBundle(
function findCurrentProfile() {
let cpd;
try {
cpd = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
.get("ProfD", Ci.nsIFile);
cpd = Services.dirsvc.get("ProfD", Ci.nsIFile);
} catch (e) {}
if (cpd) {

Просмотреть файл

@ -901,9 +901,7 @@ function copyRawDataToClipboard(button) {
transferable.init(getLoadContext());
transferable.addDataFlavor("text/unicode");
transferable.setTransferData("text/unicode", str, str.data.length * 2);
Cc["@mozilla.org/widget/clipboard;1"].
getService(Ci.nsIClipboard).
setData(transferable, null, Ci.nsIClipboard.kGlobalClipboard);
Services.clipboard.setData(transferable, null, Ci.nsIClipboard.kGlobalClipboard);
if (AppConstants.platform == "android") {
// Present a toast notification.
let message = {
@ -953,9 +951,7 @@ function copyContentsToClipboard() {
transferable.setTransferData("text/unicode", ssText, dataText.length * 2);
// Store the data into the clipboard.
let clipboard = Cc["@mozilla.org/widget/clipboard;1"]
.getService(Ci.nsIClipboard);
clipboard.setData(transferable, null, clipboard.kGlobalClipboard);
Services.clipboard.setData(transferable, null, Services.clipboard.kGlobalClipboard);
if (AppConstants.platform == "android") {
// Present a toast notification.

Просмотреть файл

@ -8,9 +8,7 @@ function closeWindow(aClose, aPromptFunction) {
// Closing the last window doesn't quit the application on OS X.
if (AppConstants.platform != "macosx") {
var windowCount = 0;
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var e = wm.getEnumerator(null);
var e = Services.wm.getEnumerator(null);
while (e.hasMoreElements()) {
var w = e.getNext();
@ -39,14 +37,10 @@ function closeWindow(aClose, aPromptFunction) {
}
function canQuitApplication(aData) {
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
if (!os) return true;
try {
var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
.createInstance(Components.interfaces.nsISupportsPRBool);
os.notifyObservers(cancelQuit, "quit-application-requested", aData || null);
Services.obs.notifyObservers(cancelQuit, "quit-application-requested", aData || null);
// Something aborted the quit process.
if (cancelQuit.data)
@ -59,10 +53,7 @@ function goQuitApplication() {
if (!canQuitApplication())
return false;
var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"].
getService(Components.interfaces.nsIAppStartup);
appStartup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit);
Services.startup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit);
return true;
}

Просмотреть файл

@ -11,9 +11,7 @@
Components.utils.import("resource://gre/modules/Services.jsm");
var Ci = Components.interfaces;
var strBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService);
var pluginsbundle = strBundleService.createBundle("chrome://global/locale/plugins.properties");
var pluginsbundle = Services.strings.createBundle("chrome://global/locale/plugins.properties");
// eslint-disable-next-line no-unsanitized/method
document.writeln("<title>" + pluginsbundle.GetStringFromName("title_label") + "<\/title>");

Просмотреть файл

@ -98,15 +98,11 @@ function test() {
}
/* import-globals-from common/mockTransfer.js */
Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockTransfer.js",
Services.scriptloader.loadSubScript("chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockTransfer.js",
this);
function createTemporarySaveDirectory() {
var saveDir = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
.get("TmpD", Ci.nsIFile);
var saveDir = Services.dirsvc.get("TmpD", Ci.nsIFile);
saveDir.append("testsavedir");
if (!saveDir.exists())
saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);

Просмотреть файл

@ -2,9 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("chrome://mochikit/content/tests/SimpleTest/MockObjects.js", this);
Services.scriptloader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/MockObjects.js", this);
var mockTransferCallback;

Просмотреть файл

@ -6,18 +6,17 @@ const XUL_CACHE_PREF = "nglayout.debug.disable_xul_cache";
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cr = Components.results;
var Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
var gDirSvc = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIDirectoryService).QueryInterface(Ci.nsIProperties);
var gChromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIXULChromeRegistry);
var gPrefs = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
// Create the temporary file in the profile, instead of in TmpD, because
// we know the mochitest harness kills off the profile when it's done.
function copyToTemporaryFile(f) {
let tmpd = gDirSvc.get("ProfD", Ci.nsIFile);
let tmpd = Services.dirsvc.get("ProfD", Ci.nsIFile);
let tmpf = tmpd.clone();
tmpf.append("temp.manifest");
tmpf.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
@ -27,9 +26,7 @@ function copyToTemporaryFile(f) {
}
function* dirIter(directory) {
var ioSvc = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var testsDir = ioSvc.newURI(directory)
var testsDir = Services.io.newURI(directory)
.QueryInterface(Ci.nsIFileURL).file;
let en = testsDir.directoryEntries;
@ -57,7 +54,7 @@ function copyDirToTempProfile(path, subdirname) {
subdirname = "mochikit-tmp";
}
let tmpdir = gDirSvc.get("ProfD", Ci.nsIFile);
let tmpdir = Services.dirsvc.get("ProfD", Ci.nsIFile);
tmpdir.append(subdirname);
tmpdir.createUnique(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o777);
@ -76,8 +73,7 @@ function copyDirToTempProfile(path, subdirname) {
}
function convertChromeURI(chromeURI) {
let uri = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService).newURI(chromeURI);
let uri = Services.io.newURI(chromeURI);
return gChromeReg.convertChromeURL(uri);
}
@ -99,7 +95,7 @@ function chromeURIToFile(chromeURI) {
// Register a chrome manifest temporarily and return a function which un-does
// the registrarion when no longer needed.
function createManifestTemporarily(tempDir, manifestText) {
gPrefs.setBoolPref(XUL_CACHE_PREF, true);
Services.prefs.setBoolPref(XUL_CACHE_PREF, true);
tempDir.append("temp.manifest");
@ -120,14 +116,14 @@ function createManifestTemporarily(tempDir, manifestText) {
tempfile.fileSize = 0; // truncate the manifest
gChromeReg.checkForNewChrome();
gChromeReg.refreshSkins();
gPrefs.clearUserPref(XUL_CACHE_PREF);
Services.prefs.clearUserPref(XUL_CACHE_PREF);
};
}
// Register a chrome manifest temporarily and return a function which un-does
// the registrarion when no longer needed.
function registerManifestTemporarily(manifestURI) {
gPrefs.setBoolPref(XUL_CACHE_PREF, true);
Services.prefs.setBoolPref(XUL_CACHE_PREF, true);
let file = chromeURIToFile(manifestURI);
@ -141,7 +137,7 @@ function registerManifestTemporarily(manifestURI) {
tempfile.fileSize = 0; // truncate the manifest
gChromeReg.checkForNewChrome();
gChromeReg.refreshSkins();
gPrefs.clearUserPref(XUL_CACHE_PREF);
Services.prefs.clearUserPref(XUL_CACHE_PREF);
};
}

Просмотреть файл

@ -6,12 +6,13 @@
var Ci = Components.interfaces;
var Cc = Components.classes;
var Cr = Components.results;
var Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
function loadUtilsScript() {
var loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
/* import-globals-from ../../contentAreaUtils.js */
loader.loadSubScript("chrome://global/content/contentAreaUtils.js");
Services.scriptloader.loadSubScript("chrome://global/content/contentAreaUtils.js");
}
function test_urlSecurityCheck() {

Просмотреть файл

@ -10,29 +10,27 @@
* that accept a browser to be modified.
**/
var ZoomManager = {
get _prefBranch() {
delete this._prefBranch;
return this._prefBranch = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
},
var Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
var ZoomManager = {
get MIN() {
delete this.MIN;
return this.MIN = this._prefBranch.getIntPref("zoom.minPercent") / 100;
return this.MIN = Services.prefs.getIntPref("zoom.minPercent") / 100;
},
get MAX() {
delete this.MAX;
return this.MAX = this._prefBranch.getIntPref("zoom.maxPercent") / 100;
return this.MAX = Services.prefs.getIntPref("zoom.maxPercent") / 100;
},
get useFullZoom() {
return this._prefBranch.getBoolPref("browser.zoom.full");
return Services.prefs.getBoolPref("browser.zoom.full");
},
set useFullZoom(aVal) {
this._prefBranch.setBoolPref("browser.zoom.full", aVal);
Services.prefs.setBoolPref("browser.zoom.full", aVal);
return aVal;
},
@ -66,8 +64,8 @@ var ZoomManager = {
},
get zoomValues() {
var zoomValues = this._prefBranch.getCharPref("toolkit.zoomManager.zoomValues")
.split(",").map(parseFloat);
var zoomValues = Services.prefs.getCharPref("toolkit.zoomManager.zoomValues")
.split(",").map(parseFloat);
zoomValues.sort((a, b) => a - b);
while (zoomValues[0] < this.MIN)

Просмотреть файл

@ -44,9 +44,7 @@ function parseINIStrings(path) {
// Since we're basically re-implementing (with async) part of the crashreporter
// client here, we'll just steal the strings we need from crashreporter.ini
async function getL10nStrings() {
let dirSvc = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
let path = OS.Path.join(dirSvc.get("GreD", Ci.nsIFile).path,
let path = OS.Path.join(Services.dirsvc.get("GreD", Ci.nsIFile).path,
"crashreporter.ini");
let pathExists = await OS.File.exists(path);
@ -75,7 +73,7 @@ async function getL10nStrings() {
"reporturl": crstrings.CrashDetailsURL
};
path = OS.Path.join(dirSvc.get("XCurProcD", Ci.nsIFile).path,
path = OS.Path.join(Services.dirsvc.get("XCurProcD", Ci.nsIFile).path,
"crashreporter-override.ini");
pathExists = await OS.File.exists(path);
@ -95,9 +93,7 @@ async function getL10nStrings() {
}
function getDir(name) {
let dirSvc = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
let uAppDataPath = dirSvc.get("UAppData", Ci.nsIFile).path;
let uAppDataPath = Services.dirsvc.get("UAppData", Ci.nsIFile).path;
return OS.Path.join(uAppDataPath, "Crash Reports", name);
}

Просмотреть файл

@ -49,12 +49,8 @@ function submitPendingReport(event) {
}
function populateReportList() {
var prefService = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
try {
reportURL = prefService.getCharPref("breakpad.reportURL");
reportURL = Services.prefs.getCharPref("breakpad.reportURL");
// Ignore any non http/https urls
if (!/^https?:/i.test(reportURL))
reportURL = null;
@ -93,11 +89,9 @@ function populateReportList() {
}
};
}
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var reportURI = ios.newURI(reportURL);
var reportURI = Services.io.newURI(reportURL);
// resolving this URI relative to /report/index
var aboutThrottling = ios.newURI("../../about/throttling", null, reportURI);
var aboutThrottling = Services.io.newURI("../../about/throttling", null, reportURI);
for (var i = 0; i < reports.length; i++) {
var row = document.createElement("tr");

Просмотреть файл

@ -4,9 +4,7 @@ add_task(async function test() {
crD.append("Crash Reports");
let crashes = add_fake_crashes(crD, 5);
// sanity check
let dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties);
let appDtest = dirSvc.get("UAppData", Components.interfaces.nsIFile);
let appDtest = Services.dirsvc.get("UAppData", Components.interfaces.nsIFile);
ok(appD.equals(appDtest), "directory service provider registered ok");
await BrowserTestUtils.withNewTab({ gBrowser, url: "about:crashes" }, function(browser) {

Просмотреть файл

@ -1,3 +1,5 @@
Cu.import("resource://gre/modules/Services.jsm");
function create_subdir(dir, subdirname) {
let subdir = dir.clone();
subdir.append(subdirname);
@ -15,9 +17,7 @@ function make_fake_appdir() {
// Create a directory inside the profile and register it as UAppData, so
// we can stick fake crash reports inside there. We put it inside the profile
// just because we know that will get cleaned up after the mochitest run.
let dirSvc = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties);
let profD = dirSvc.get("ProfD", Ci.nsIFile);
let profD = Services.dirsvc.get("ProfD", Ci.nsIFile);
// create a subdir just to keep our files out of the way
let appD = create_subdir(profD, "UAppData");
@ -48,23 +48,21 @@ function make_fake_appdir() {
}
};
// register our new provider
dirSvc.QueryInterface(Ci.nsIDirectoryService)
.registerProvider(_provider);
Services.dirsvc.QueryInterface(Ci.nsIDirectoryService)
.registerProvider(_provider);
// and undefine the old value
try {
dirSvc.undefine("UAppData");
Services.dirsvc.undefine("UAppData");
} catch (ex) {} // it's ok if this fails, the value might not be cached yet
return appD.clone();
}
function cleanup_fake_appdir() {
let dirSvc = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties);
dirSvc.QueryInterface(Ci.nsIDirectoryService)
.unregisterProvider(_provider);
Services.dirsvc.QueryInterface(Ci.nsIDirectoryService)
.unregisterProvider(_provider);
// undefine our value so future calls get the real value
try {
dirSvc.undefine("UAppData");
Services.dirsvc.undefine("UAppData");
} catch (ex) {
dump("cleanup_fake_appdir: dirSvc.undefine failed: " + ex.message + "\n");
}

Просмотреть файл

@ -1,7 +1,7 @@
Components.utils.import("resource://gre/modules/Services.jsm");
// enable crash reporting first
var cwd = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("CurWorkD", Components.interfaces.nsIFile);
var cwd = Services.dirsvc.get("CurWorkD", Components.interfaces.nsIFile);
// get the temp dir
var env = Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment);
@ -16,17 +16,14 @@ var crashReporter =
crashReporter.UpdateCrashEventsDir();
// Setting the minidump path is not allowed in content processes
var processType = Components.classes["@mozilla.org/xre/runtime;1"].
getService(Components.interfaces.nsIXULRuntime).processType;
var processType = Services.appinfo.processType;
if (processType == Components.interfaces.nsIXULRuntime.PROCESS_TYPE_DEFAULT) {
crashReporter.minidumpPath = _tmpd;
}
var ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var protocolHandler = ios.getProtocolHandler("resource")
.QueryInterface(Components.interfaces.nsIResProtocolHandler);
var curDirURI = ios.newFileURI(cwd);
var protocolHandler = Services.io.getProtocolHandler("resource")
.QueryInterface(Components.interfaces.nsIResProtocolHandler);
var curDirURI = Services.io.newFileURI(cwd);
protocolHandler.setSubstitution("test", curDirURI);
Components.utils.import("resource://test/CrashTestUtils.jsm");
var crashType = CrashTestUtils.CRASH_INVALID_POINTER_DEREF;

Просмотреть файл

@ -3,12 +3,10 @@
// Let the event loop process a bit before crashing.
if (shouldDelay) {
let shouldCrashNow = false;
let tm = Components.classes["@mozilla.org/thread-manager;1"]
.getService(Components.interfaces.nsIThreadManager);
tm.dispatchToMainThread({ run: () => { shouldCrashNow = true; } });
Services.tm.dispatchToMainThread({ run: () => { shouldCrashNow = true; } });
tm.spinEventLoopUntil(() => shouldCrashNow);
Services.tm.spinEventLoopUntil(() => shouldCrashNow);
}
// now actually crash

Просмотреть файл

@ -39,15 +39,13 @@ function getEventDir() {
*/
function do_crash(setup, callback, canReturnZero) {
// get current process filename (xpcshell)
let ds = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties);
let bin = ds.get("XREExeF", Components.interfaces.nsIFile);
let bin = Services.dirsvc.get("XREExeF", Components.interfaces.nsIFile);
if (!bin.exists()) {
// weird, can't find xpcshell binary?
do_throw("Can't find xpcshell binary!");
}
// get Gre dir (GreD)
let greD = ds.get("GreD", Components.interfaces.nsIFile);
let greD = Services.dirsvc.get("GreD", Components.interfaces.nsIFile);
let headfile = do_get_file("crasher_subprocess_head.js");
let tailfile = do_get_file("crasher_subprocess_tail.js");
// run xpcshell -g GreD -f head -e "some setup code" -f tail
@ -109,9 +107,7 @@ function runMinidumpAnalyzer(dumpFile, additionalArgs) {
}
// find minidump-analyzer executable.
let ds = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties);
let bin = ds.get("XREExeF", Ci.nsIFile);
let bin = Services.dirsvc.get("XREExeF", Ci.nsIFile);
ok(bin && bin.exists());
bin = bin.parent;
ok(bin && bin.exists());

Просмотреть файл

@ -13,9 +13,7 @@ function run_test() {
CrashTestUtils.crash(crashType);
}
var observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
observerService.addObserver(crashWhileReporting, "memory-pressure");
Services.obs.addObserver(crashWhileReporting, "memory-pressure");
Components.utils.getJSTestingFunctions().reportLargeAllocationFailure();
},
function(mdump, extra) {

Просмотреть файл

@ -23,8 +23,6 @@ function run_test() {
.createInstance(Ci.nsIFile);
file.initWithPath(profd);
let dirSvc = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties);
let provider = {
getFile(prop, persistent) {
persistent.value = true;
@ -42,8 +40,8 @@ function run_test() {
throw Components.results.NS_ERROR_NO_INTERFACE;
}
};
dirSvc.QueryInterface(Ci.nsIDirectoryService)
.registerProvider(provider);
Services.dirsvc.QueryInterface(Ci.nsIDirectoryService)
.registerProvider(provider);
crashReporter.saveMemoryReport();
},

Просмотреть файл

@ -14,20 +14,18 @@ function run_test() {
}
// check setting/getting serverURL
var ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
// try it with two different URLs, just for kicks
var testspecs = ["http://example.com/submit",
"https://example.org/anothersubmit"];
for (var i = 0; i < testspecs.length; ++i) {
cr.serverURL = ios.newURI(testspecs[i]);
cr.serverURL = Services.io.newURI(testspecs[i]);
do_check_eq(cr.serverURL.spec, testspecs[i]);
}
// should not allow setting non-http/https URLs
try {
cr.serverURL = ios.newURI("ftp://example.com/submit");
cr.serverURL = Services.io.newURI("ftp://example.com/submit");
do_throw("Setting serverURL to a non-http(s) URL should have thrown!");
} catch (ex) {
do_check_eq(ex.result, Components.results.NS_ERROR_INVALID_ARG);

Просмотреть файл

@ -61,12 +61,10 @@ function run_test() {
do_crash(function() {
// Enable the FHR, official policy bypass (since we're in a test) and
// specify a telemetry server & client ID.
let prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
prefs.setBoolPref("datareporting.policy.dataSubmissionPolicyBypassNotification", true);
prefs.setBoolPref("datareporting.healthreport.uploadEnabled", true);
prefs.setCharPref("toolkit.telemetry.server", "http://a.telemetry.server");
prefs.setCharPref("toolkit.telemetry.cachedClientID",
Services.prefs.setBoolPref("datareporting.policy.dataSubmissionPolicyBypassNotification", true);
Services.prefs.setBoolPref("datareporting.healthreport.uploadEnabled", true);
Services.prefs.setCharPref("toolkit.telemetry.server", "http://a.telemetry.server");
Services.prefs.setCharPref("toolkit.telemetry.cachedClientID",
"f3582dee-22b9-4d73-96d1-79ef5bf2fc24");
// TelemetrySession setup will trigger the session annotation
@ -89,10 +87,8 @@ function run_test() {
do_crash(function() {
// Disable the FHR upload, no telemetry annotations should be present.
let prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
prefs.setBoolPref("datareporting.policy.dataSubmissionPolicyBypassNotification", true);
prefs.setBoolPref("datareporting.healthreport.uploadEnabled", false);
Services.prefs.setBoolPref("datareporting.policy.dataSubmissionPolicyBypassNotification", true);
Services.prefs.setBoolPref("datareporting.healthreport.uploadEnabled", false);
// TelemetrySession setup will trigger the session annotation
let scope = {};
@ -110,10 +106,8 @@ function run_test() {
do_crash(function() {
// No telemetry annotations should be present if the user has not been
// notified yet
let prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
prefs.setBoolPref("datareporting.policy.dataSubmissionPolicyBypassNotification", false);
prefs.setBoolPref("datareporting.healthreport.uploadEnabled", true);
Services.prefs.setBoolPref("datareporting.policy.dataSubmissionPolicyBypassNotification", false);
Services.prefs.setBoolPref("datareporting.healthreport.uploadEnabled", true);
// TelemetrySession setup will trigger the session annotation
let scope = {};

Просмотреть файл

@ -49,11 +49,9 @@ this.ForgetAboutSite = {
let promises = [];
// Cache
promises.push((async function() {
let cs = Cc["@mozilla.org/netwerk/cache-storage-service;1"].
getService(Ci.nsICacheStorageService);
// NOTE: there is no way to clear just that domain, so we clear out
// everything)
cs.clear();
Services.cache2.clear();
})().catch(ex => {
throw new Error("Exception thrown while clearing the cache: " + ex);
}));
@ -70,12 +68,10 @@ this.ForgetAboutSite = {
// Cookies
// Need to maximize the number of cookies cleaned here
promises.push((async function() {
let cm = Cc["@mozilla.org/cookiemanager;1"].
getService(Ci.nsICookieManager);
let enumerator = cm.getCookiesWithOriginAttributes(JSON.stringify({}), aDomain);
let enumerator = Services.cookies.getCookiesWithOriginAttributes(JSON.stringify({}), aDomain);
while (enumerator.hasMoreElements()) {
let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie);
cm.remove(cookie.host, cookie.name, cookie.path, false, cookie.originAttributes);
Services.cookies.remove(cookie.host, cookie.name, cookie.path, false, cookie.originAttributes);
}
})().catch(ex => {
throw new Error("Exception thrown while clearning cookies: " + ex);
@ -119,13 +115,11 @@ this.ForgetAboutSite = {
// Passwords
promises.push((async function() {
let lm = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
// Clear all passwords for domain
let logins = lm.getAllLogins();
let logins = Services.logins.getAllLogins();
for (let i = 0; i < logins.length; i++)
if (hasRootDomain(logins[i].hostname, aDomain))
lm.removeLogin(logins[i]);
Services.logins.removeLogin(logins[i]);
})().catch(ex => {
// XXXehsan: is there a better way to do this rather than this
// hacky comparison?
@ -135,16 +129,14 @@ this.ForgetAboutSite = {
}));
// Permissions
let pm = Cc["@mozilla.org/permissionmanager;1"].
getService(Ci.nsIPermissionManager);
// Enumerate all of the permissions, and if one matches, remove it
let enumerator = pm.enumerator;
let enumerator = Services.perms.enumerator;
while (enumerator.hasMoreElements()) {
let perm = enumerator.getNext().QueryInterface(Ci.nsIPermission);
promises.push(new Promise((resolve, reject) => {
try {
if (hasRootDomain(perm.principal.URI.host, aDomain)) {
pm.removePermission(perm);
Services.perms.removePermission(perm);
}
} catch (ex) {
// Ignore entry
@ -156,8 +148,6 @@ this.ForgetAboutSite = {
// Offline Storages
promises.push((async function() {
let qms = Cc["@mozilla.org/dom/quota-manager-service;1"].
getService(Ci.nsIQuotaManagerService);
// delete data from both HTTP and HTTPS sites
let httpURI = NetUtil.newURI("http://" + aDomain);
let httpsURI = NetUtil.newURI("https://" + aDomain);
@ -168,8 +158,8 @@ this.ForgetAboutSite = {
.createCodebasePrincipal(httpURI, {});
let httpsPrincipal = Services.scriptSecurityManager
.createCodebasePrincipal(httpsURI, {});
qms.clearStoragesForPrincipal(httpPrincipal, null, true);
qms.clearStoragesForPrincipal(httpsPrincipal, null, true);
Services.qms.clearStoragesForPrincipal(httpPrincipal, null, true);
Services.qms.clearStoragesForPrincipal(httpsPrincipal, null, true);
})().catch(ex => {
throw new Error("Exception occured while clearing offline storages: " + ex);
}));

Просмотреть файл

@ -8,7 +8,8 @@ var Cc = Components.classes;
var Ci = Components.interfaces;
var Cu = Components.utils;
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
Cu.import("resource://gre/modules/Services.jsm");
var profileDir = do_get_profile();
/**
@ -23,7 +24,7 @@ function cleanUp() {
];
for (let i = 0; i < files.length; i++) {
let file = dirSvc.get("ProfD", Ci.nsIFile);
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
file.append(files[i]);
if (file.exists())
file.remove(false);

Просмотреть файл

@ -35,19 +35,6 @@ const PREFERENCE_NAME = "test-pref";
// Utility Functions
/**
* Creates an nsIURI object for the given string representation of a URI.
*
* @param aURIString
* The spec of the URI to create.
* @returns an nsIURI representing aURIString.
*/
function uri(aURIString) {
return Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService).
newURI(aURIString);
}
/**
* Asynchronously check a url is visited.
*
@ -74,9 +61,8 @@ function promiseIsURIVisited(aURI) {
*/
function add_cookie(aDomain) {
check_cookie_exists(aDomain, false);
let cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
cm.add(aDomain, COOKIE_PATH, COOKIE_NAME, "", false, false, false,
COOKIE_EXPIRY, {});
Services.cookies.add(aDomain, COOKIE_PATH, COOKIE_NAME, "", false, false, false,
COOKIE_EXPIRY, {});
check_cookie_exists(aDomain, true);
}
@ -89,14 +75,13 @@ function add_cookie(aDomain) {
* True if the cookie should exist, false otherwise.
*/
function check_cookie_exists(aDomain, aExists) {
let cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
let cookie = {
host: aDomain,
name: COOKIE_NAME,
path: COOKIE_PATH
};
let checker = aExists ? do_check_true : do_check_false;
checker(cm.cookieExists(cookie));
checker(Services.cookies.cookieExists(cookie));
}
/**
@ -107,9 +92,7 @@ function check_cookie_exists(aDomain, aExists) {
*/
function add_disabled_host(aHost) {
check_disabled_host(aHost, false);
let lm = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
lm.setLoginSavingEnabled(aHost, false);
Services.logins.setLoginSavingEnabled(aHost, false);
check_disabled_host(aHost, true);
}
@ -122,10 +105,8 @@ function add_disabled_host(aHost) {
* True if the host should be disabled, false otherwise.
*/
function check_disabled_host(aHost, aIsDisabled) {
let lm = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
let checker = aIsDisabled ? do_check_false : do_check_true;
checker(lm.getLoginSavingEnabled(aHost));
checker(Services.logins.getLoginSavingEnabled(aHost));
}
/**
@ -140,9 +121,7 @@ function add_login(aHost) {
createInstance(Ci.nsILoginInfo);
login.init(aHost, "", null, LOGIN_USERNAME, LOGIN_PASSWORD,
LOGIN_USERNAME_FIELD, LOGIN_PASSWORD_FIELD);
let lm = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
lm.addLogin(login);
Services.logins.addLogin(login);
check_login_exists(aHost, true);
}
@ -155,10 +134,8 @@ function add_login(aHost) {
* True if the login should exist, false otherwise.
*/
function check_login_exists(aHost, aExists) {
let lm = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
let count = { value: 0 };
lm.findLogins(count, aHost, "", null);
Services.logins.findLogins(count, aHost, "", null);
do_check_eq(count.value, aExists ? 1 : 0);
}
@ -170,13 +147,9 @@ function check_login_exists(aHost, aExists) {
*/
function add_permission(aURI) {
check_permission_exists(aURI, false);
let pm = Cc["@mozilla.org/permissionmanager;1"].
getService(Ci.nsIPermissionManager);
let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Ci.nsIScriptSecurityManager);
let principal = ssm.createCodebasePrincipal(aURI, {});
let principal = Services.scriptSecurityManager.createCodebasePrincipal(aURI, {});
pm.addFromPrincipal(principal, PERMISSION_TYPE, PERMISSION_VALUE);
Services.perms.addFromPrincipal(principal, PERMISSION_TYPE, PERMISSION_VALUE);
check_permission_exists(aURI, true);
}
@ -189,13 +162,9 @@ function add_permission(aURI) {
* True if the permission should exist, false otherwise.
*/
function check_permission_exists(aURI, aExists) {
let pm = Cc["@mozilla.org/permissionmanager;1"].
getService(Ci.nsIPermissionManager);
let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Ci.nsIScriptSecurityManager);
let principal = ssm.createCodebasePrincipal(aURI, {});
let principal = Services.scriptSecurityManager.createCodebasePrincipal(aURI, {});
let perm = pm.testExactPermissionFromPrincipal(principal, PERMISSION_TYPE);
let perm = Services.perms.testExactPermissionFromPrincipal(principal, PERMISSION_TYPE);
let checker = aExists ? do_check_eq : do_check_neq;
checker(perm, PERMISSION_VALUE);
}
@ -238,7 +207,7 @@ function preference_exists(aURI) {
// History
async function test_history_cleared_with_direct_match() {
const TEST_URI = uri("http://mozilla.org/foo");
const TEST_URI = Services.io.newURI("http://mozilla.org/foo");
do_check_false(await promiseIsURIVisited(TEST_URI));
await PlacesTestUtils.addVisits(TEST_URI);
do_check_true(await promiseIsURIVisited(TEST_URI));
@ -247,7 +216,7 @@ async function test_history_cleared_with_direct_match() {
}
async function test_history_cleared_with_subdomain() {
const TEST_URI = uri("http://www.mozilla.org/foo");
const TEST_URI = Services.io.newURI("http://www.mozilla.org/foo");
do_check_false(await promiseIsURIVisited(TEST_URI));
await PlacesTestUtils.addVisits(TEST_URI);
do_check_true(await promiseIsURIVisited(TEST_URI));
@ -256,7 +225,7 @@ async function test_history_cleared_with_subdomain() {
}
async function test_history_not_cleared_with_uri_contains_domain() {
const TEST_URI = uri("http://ilovemozilla.org/foo");
const TEST_URI = Services.io.newURI("http://ilovemozilla.org/foo");
do_check_false(await promiseIsURIVisited(TEST_URI));
await PlacesTestUtils.addVisits(TEST_URI);
do_check_true(await promiseIsURIVisited(TEST_URI));
@ -311,9 +280,7 @@ async function test_login_manager_disabled_hosts_not_cleared_with_uri_contains_d
check_disabled_host(TEST_HOST, true);
// Reset state
let lm = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
lm.setLoginSavingEnabled(TEST_HOST, true);
Services.logins.setLoginSavingEnabled(TEST_HOST, true);
check_disabled_host(TEST_HOST, false);
}
@ -337,37 +304,33 @@ async function test_login_manager_logins_not_cleared_with_uri_contains_domain()
await ForgetAboutSite.removeDataFromDomain("mozilla.org");
check_login_exists(TEST_HOST, true);
let lm = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
lm.removeAllLogins();
Services.logins.removeAllLogins();
check_login_exists(TEST_HOST, false);
}
// Permission Manager
async function test_permission_manager_cleared_with_direct_match() {
const TEST_URI = uri("http://mozilla.org");
const TEST_URI = Services.io.newURI("http://mozilla.org");
add_permission(TEST_URI);
await ForgetAboutSite.removeDataFromDomain("mozilla.org");
check_permission_exists(TEST_URI, false);
}
async function test_permission_manager_cleared_with_subdomain() {
const TEST_URI = uri("http://www.mozilla.org");
const TEST_URI = Services.io.newURI("http://www.mozilla.org");
add_permission(TEST_URI);
await ForgetAboutSite.removeDataFromDomain("mozilla.org");
check_permission_exists(TEST_URI, false);
}
async function test_permission_manager_not_cleared_with_uri_contains_domain() {
const TEST_URI = uri("http://ilovemozilla.org");
const TEST_URI = Services.io.newURI("http://ilovemozilla.org");
add_permission(TEST_URI);
await ForgetAboutSite.removeDataFromDomain("mozilla.org");
check_permission_exists(TEST_URI, true);
// Reset state
let pm = Cc["@mozilla.org/permissionmanager;1"].
getService(Ci.nsIPermissionManager);
pm.removeAll();
Services.perms.removeAll();
check_permission_exists(TEST_URI, false);
}
@ -392,7 +355,7 @@ function waitForPurgeNotification() {
// Content Preferences
async function test_content_preferences_cleared_with_direct_match() {
const TEST_URI = uri("http://mozilla.org");
const TEST_URI = Services.io.newURI("http://mozilla.org");
do_check_false(await preference_exists(TEST_URI));
await add_preference(TEST_URI);
do_check_true(await preference_exists(TEST_URI));
@ -402,7 +365,7 @@ async function test_content_preferences_cleared_with_direct_match() {
}
async function test_content_preferences_cleared_with_subdomain() {
const TEST_URI = uri("http://www.mozilla.org");
const TEST_URI = Services.io.newURI("http://www.mozilla.org");
do_check_false(await preference_exists(TEST_URI));
await add_preference(TEST_URI);
do_check_true(await preference_exists(TEST_URI));
@ -412,7 +375,7 @@ async function test_content_preferences_cleared_with_subdomain() {
}
async function test_content_preferences_not_cleared_with_uri_contains_domain() {
const TEST_URI = uri("http://ilovemozilla.org");
const TEST_URI = Services.io.newURI("http://ilovemozilla.org");
do_check_false(await preference_exists(TEST_URI));
await add_preference(TEST_URI);
do_check_true(await preference_exists(TEST_URI));
@ -428,9 +391,7 @@ async function test_content_preferences_not_cleared_with_uri_contains_domain() {
function push_registration_exists(aURL, ps) {
return new Promise(resolve => {
let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Ci.nsIScriptSecurityManager);
let principal = ssm.createCodebasePrincipalFromOrigin(aURL);
let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(aURL);
return ps.getSubscription(aURL, principal, (status, record) => {
if (!Components.isSuccessCode(status)) {
resolve(false);
@ -509,36 +470,30 @@ async function test_cache_cleared() {
// the API is well tested, and that when we get the observer
// notification, we have actually cleared the cache.
// This seems to happen asynchronously...
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
let observer = {
observe(aSubject, aTopic, aData) {
os.removeObserver(observer, "cacheservice:empty-cache");
Services.obs.removeObserver(observer, "cacheservice:empty-cache");
// Shutdown the download manager.
Services.obs.notifyObservers(null, "quit-application");
do_test_finished();
}
};
os.addObserver(observer, "cacheservice:empty-cache");
Services.obs.addObserver(observer, "cacheservice:empty-cache");
await ForgetAboutSite.removeDataFromDomain("mozilla.org");
do_test_pending();
}
async function test_storage_cleared() {
function getStorageForURI(aURI) {
let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Ci.nsIScriptSecurityManager);
let principal = ssm.createCodebasePrincipal(aURI, {});
let principal = Services.scriptSecurityManager.createCodebasePrincipal(aURI, {});
let dsm = Cc["@mozilla.org/dom/localStorage-manager;1"].
getService(Ci.nsIDOMStorageManager);
return dsm.createStorage(null, principal, "");
return Services.domStorageManager.createStorage(null, principal, "");
}
let s = [
getStorageForURI(uri("http://mozilla.org")),
getStorageForURI(uri("http://my.mozilla.org")),
getStorageForURI(uri("http://ilovemozilla.org")),
getStorageForURI(Services.io.newURI("http://mozilla.org")),
getStorageForURI(Services.io.newURI("http://my.mozilla.org")),
getStorageForURI(Services.io.newURI("http://ilovemozilla.org")),
];
for (let i = 0; i < s.length; ++i) {

Просмотреть файл

@ -74,8 +74,6 @@ this.BrowserUtils = {
* safe mode if it is already in safe mode.
*/
restartApplication() {
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
.getService(Ci.nsIAppStartup);
let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
.createInstance(Ci.nsISupportsPRBool);
Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart");
@ -84,10 +82,10 @@ this.BrowserUtils = {
}
// if already in safe mode restart in safe mode
if (Services.appinfo.inSafeMode) {
appStartup.restartInSafeMode(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
Services.startup.restartInSafeMode(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
return undefined;
}
appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
return undefined;
},
@ -550,10 +548,8 @@ this.BrowserUtils = {
}
if (delimitedAtStart && delimitedAtEnd) {
let uriFixup = Cc["@mozilla.org/docshell/urifixup;1"]
.getService(Ci.nsIURIFixup);
try {
url = uriFixup.createFixupURI(linkText, uriFixup.FIXUP_FLAG_NONE);
url = Services.uriFixup.createFixupURI(linkText, Services.uriFixup.FIXUP_FLAG_NONE);
} catch (ex) {}
}
}

Просмотреть файл

@ -312,15 +312,14 @@ Finder.prototype = {
}
let fastFind = this._fastFind;
const fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
try {
// Try to find the best possible match that should receive focus and
// block scrolling on focus since find already scrolls. Further
// scrolling is due to user action, so don't override this.
if (fastFind.foundLink) {
fm.setFocus(fastFind.foundLink, fm.FLAG_NOSCROLL);
Services.focus.setFocus(fastFind.foundLink, Services.focus.FLAG_NOSCROLL);
} else if (fastFind.foundEditable) {
fm.setFocus(fastFind.foundEditable, fm.FLAG_NOSCROLL);
Services.focus.setFocus(fastFind.foundEditable, Services.focus.FLAG_NOSCROLL);
fastFind.collapseSelection();
} else {
this._getWindow().focus();

Просмотреть файл

@ -12,6 +12,8 @@ const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
this.InlineSpellChecker = function InlineSpellChecker(aEditor) {
this.init(aEditor);
this.mAddedWordStack = []; // We init this here to preserve it between init/uninit calls
@ -258,11 +260,9 @@ InlineSpellChecker.prototype = {
if (!gLanguageBundle) {
// Create the bundles for language and region names.
var bundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService);
gLanguageBundle = bundleService.createBundle(
gLanguageBundle = Services.strings.createBundle(
"chrome://global/locale/languageNames.properties");
gRegionBundle = bundleService.createBundle(
gRegionBundle = Services.strings.createBundle(
"chrome://global/locale/regionNames.properties");
}

Просмотреть файл

@ -20,6 +20,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "OS",
"resource://gre/modules/osfile.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
const INTERNAL_FIELDS = new Set(["_level", "_message", "_time", "_namespace"]);
@ -757,8 +759,7 @@ ConsoleAppender.prototype = {
},
doAppend: function CApp_doAppend(formatted) {
Cc["@mozilla.org/consoleservice;1"].
getService(Ci.nsIConsoleService).logStringMessage(formatted);
Services.console.logStringMessage(formatted);
}
};

Просмотреть файл

@ -481,8 +481,7 @@ PopupNotifications.prototype = {
notifications.push(notification);
let isActiveBrowser = this._isActiveBrowser(browser);
let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
let isActiveWindow = fm.activeWindow == this.window;
let isActiveWindow = Services.focus.activeWindow == this.window;
if (isActiveBrowser) {
if (isActiveWindow) {

Просмотреть файл

@ -10,17 +10,13 @@ const Cc = Components.classes;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function newURI(spec) {
return Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService)
.newURI(spec);
}
Cu.import("resource://gre/modules/Services.jsm");
function RemoteWebProgressRequest(spec, originalSpec, requestCPOW) {
this.wrappedJSObject = this;
this._uri = newURI(spec);
this._originalURI = newURI(originalSpec);
this._uri = Services.io.newURI(spec);
this._originalURI = Services.io.newURI(originalSpec);
this._requestCPOW = requestCPOW;
}
@ -239,7 +235,7 @@ RemoteWebProgressManager.prototype = {
switch (aMessage.name) {
case "Content:StateChange":
if (isTopLevel) {
this._browser._documentURI = newURI(json.documentURI);
this._browser._documentURI = Services.io.newURI(json.documentURI);
}
this._callProgressListeners(
Ci.nsIWebProgress.NOTIFY_STATE_ALL, "onStateChange", webProgress,
@ -248,7 +244,7 @@ RemoteWebProgressManager.prototype = {
break;
case "Content:LocationChange":
let location = newURI(json.location);
let location = Services.io.newURI(json.location);
let flags = json.flags;
let remoteWebNav = this._browser._remoteWebNavigationImpl;
@ -258,7 +254,7 @@ RemoteWebProgressManager.prototype = {
if (isTopLevel) {
remoteWebNav._currentURI = location;
this._browser._documentURI = newURI(json.documentURI);
this._browser._documentURI = Services.io.newURI(json.documentURI);
this._browser._contentTitle = json.title;
this._browser._imageDocument = null;
this._browser._contentPrincipal = json.principal;

Просмотреть файл

@ -59,7 +59,6 @@ this.ResetProfile = {
.getService(Ci.nsIEnvironment);
env.set("MOZ_RESET_PROFILE_RESTART", "1");
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
appStartup.quit(Ci.nsIAppStartup.eForceQuit | Ci.nsIAppStartup.eRestart);
Services.startup.quit(Ci.nsIAppStartup.eForceQuit | Ci.nsIAppStartup.eRestart);
},
};

Просмотреть файл

@ -170,13 +170,9 @@ this.Troubleshoot = {
var dataProviders = {
application: function application(done) {
let sysInfo = Cc["@mozilla.org/system-info;1"].
getService(Ci.nsIPropertyBag2);
let data = {
name: Services.appinfo.name,
osVersion: sysInfo.getProperty("name") + " " + sysInfo.getProperty("version"),
osVersion: Services.sysinfo.getProperty("name") + " " + Services.sysinfo.getProperty("version"),
version: AppConstants.MOZ_APP_VERSION_DISPLAY,
buildID: Services.appinfo.appBuildID,
userAgent: Cc["@mozilla.org/network/protocol;1?name=http"].
@ -192,10 +188,8 @@ var dataProviders = {
try {
data.vendor = Services.prefs.getCharPref("app.support.vendor");
} catch (e) {}
let urlFormatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].
getService(Ci.nsIURLFormatter);
try {
data.supportURL = urlFormatter.formatURLPref("app.support.baseURL");
data.supportURL = Services.urlFormatter.formatURLPref("app.support.baseURL");
} catch (e) {}
data.numTotalWindows = 0;
@ -692,11 +686,9 @@ if (AppConstants.MOZ_SANDBOX) {
"hasPrivilegedUserNamespaces", "hasUserNamespaces",
"canSandboxContent", "canSandboxMedia"];
let sysInfo = Cc["@mozilla.org/system-info;1"].
getService(Ci.nsIPropertyBag2);
for (let key of keys) {
if (sysInfo.hasKey(key)) {
data[key] = sysInfo.getPropertyAsBool(key);
if (Services.sysinfo.hasKey(key)) {
data[key] = Services.sysinfo.getPropertyAsBool(key);
}
}

Просмотреть файл

@ -10,6 +10,12 @@
this.EXPORTED_SYMBOLS = ["NS_ASSERT"];
var Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
var gTraceOnAssert = false;
/**
@ -34,9 +40,7 @@ this.NS_ASSERT = function NS_ASSERT(condition, message) {
return;
var releaseBuild = true;
var defB = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService)
.getDefaultBranch(null);
var defB = Services.prefs.getDefaultBranch(null);
try {
switch (defB.getCharPref("app.update.channel")) {
case "nightly":

Просмотреть файл

@ -114,10 +114,7 @@ add_test(function test_set_unsupported_pref() {
// Make sure that we can get a string pref that we didn't set ourselves.
add_test(function test_get_string_pref() {
let svc = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService).
getBranch("");
svc.setCharPref("test_get_string_pref", "a normal string");
Services.prefs.setCharPref("test_get_string_pref", "a normal string");
do_check_eq(Preferences.get("test_get_string_pref"), "a normal string");
// Clean up.
@ -127,14 +124,11 @@ add_test(function test_get_string_pref() {
});
add_test(function test_get_localized_string_pref() {
let svc = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService).
getBranch("");
let prefName = "test_get_localized_string_pref";
let localizedString = Cc["@mozilla.org/pref-localizedstring;1"]
.createInstance(Ci.nsIPrefLocalizedString);
localizedString.data = "a localized string";
svc.setComplexValue(prefName, Ci.nsIPrefLocalizedString, localizedString);
Services.prefs.setComplexValue(prefName, Ci.nsIPrefLocalizedString, localizedString);
do_check_eq(Preferences.get(prefName, null, Ci.nsIPrefLocalizedString),
"a localized string");

Просмотреть файл

@ -6,6 +6,7 @@ const C = Components.classes;
const I = Components.interfaces;
Components.utils.import("resource://gre/modules/AppConstants.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
const ToolkitProfileService = "@mozilla.org/toolkit/profile-service;1";
@ -26,8 +27,7 @@ function initWizard() {
gProfileService = C[ToolkitProfileService].getService(I.nsIToolkitProfileService);
gProfileManagerBundle = document.getElementById("bundle_profileManager");
var dirService = C["@mozilla.org/file/directory_service;1"].getService(I.nsIProperties);
gDefaultProfileParent = dirService.get("DefProfRt", I.nsIFile);
gDefaultProfileParent = Services.dirsvc.get("DefProfRt", I.nsIFile);
// Initialize the profile location display.
gProfileDisplay = document.getElementById("profileDisplay").firstChild;
@ -183,10 +183,8 @@ function onFinish() {
gProfileManagerBundle.getString("profileCreationFailed");
var profileCreationFailedTitle =
gProfileManagerBundle.getString("profileCreationFailedTitle");
var promptService = C["@mozilla.org/embedcomp/prompt-service;1"].
getService(I.nsIPromptService);
promptService.alert(window, profileCreationFailedTitle,
profileCreationFailed + "\n" + e);
Services.prompt.alert(window, profileCreationFailedTitle,
profileCreationFailed + "\n" + e);
return false;
}

Просмотреть файл

@ -4,13 +4,9 @@
// Tests that the dll blocklist initializes correctly during test runs.
add_task(async function test() {
await BrowserTestUtils.withNewTab({gBrowser, url: "about:blank" }, function(browser) {
ok(Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime)
.windowsDLLBlocklistStatus,
ok(Services.appinfo.windowsDLLBlocklistStatus,
"Windows dll blocklist status should be true, indicating it is " +
"running properly. A failure in this test is considered a " +
"release blocker.");
});
});