зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1424879 - Enable mozilla/use-services for xpcom/. r=froydnj
MozReview-Commit-ID: FnQDHG3w6RQ --HG-- extra : rebase_source : 7b7b16775eaad6022f544f7a65e8d950a3d6fdd0
This commit is contained in:
Родитель
2002a0afd0
Коммит
2b0445fe18
|
@ -41,7 +41,6 @@ module.exports = {
|
|||
"security/**",
|
||||
"testing/**",
|
||||
"tools/profiler/**",
|
||||
"xpcom/**"
|
||||
],
|
||||
"rules": {
|
||||
"mozilla/use-services": "off",
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function run_test() {
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"].
|
||||
getService(Components.interfaces.nsIIOService);
|
||||
|
||||
var dataFile = do_get_file("data/bug121341.properties");
|
||||
var channel = NetUtil.newChannel({
|
||||
uri: ios.newFileURI(dataFile, null, null),
|
||||
uri: Services.io.newFileURI(dataFile, null, null),
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
var inp = channel.open2();
|
||||
|
@ -53,7 +51,7 @@ function run_test() {
|
|||
dataFile = do_get_file("data/bug121341-2.properties");
|
||||
|
||||
var channel2 = NetUtil.newChannel({
|
||||
uri: ios.newFileURI(dataFile, null, null),
|
||||
uri: Services.io.newFileURI(dataFile, null, null),
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
inp = channel2.open2();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function run_test() {
|
||||
var f =
|
||||
Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties).get("CurProcD", Ci.nsIFile);
|
||||
var f = Services.dirsvc.get("CurProcD", Ci.nsIFile);
|
||||
|
||||
var terminated = false;
|
||||
for (var i = 0; i < 100; i++) {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var nameArray = [
|
||||
"ascii", // ASCII
|
||||
"fran\u00E7ais", // Latin-1
|
||||
|
@ -9,9 +11,7 @@ var nameArray = [
|
|||
];
|
||||
|
||||
function getTempDir() {
|
||||
var dirService = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties);
|
||||
return dirService.get("TmpD", Ci.nsIFile);
|
||||
return Services.dirsvc.get("TmpD", Ci.nsIFile);
|
||||
}
|
||||
|
||||
function create_file(fileName) {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var addedTopic = "xpcom-category-entry-added";
|
||||
var removedTopic = "xpcom-category-entry-removed";
|
||||
var testCategory = "bug-test-category";
|
||||
|
@ -20,9 +22,8 @@ var observer = {
|
|||
if (topic == "timer-callback") {
|
||||
do_check_eq(result, expected);
|
||||
|
||||
var observerService = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
|
||||
observerService.removeObserver(this, addedTopic);
|
||||
observerService.removeObserver(this, removedTopic);
|
||||
Services.obs.removeObserver(this, addedTopic);
|
||||
Services.obs.removeObserver(this, removedTopic);
|
||||
|
||||
do_test_finished();
|
||||
|
||||
|
@ -42,9 +43,8 @@ var observer = {
|
|||
function run_test() {
|
||||
do_test_pending();
|
||||
|
||||
var observerService = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
|
||||
observerService.addObserver(observer, addedTopic);
|
||||
observerService.addObserver(observer, removedTopic);
|
||||
Services.obs.addObserver(observer, addedTopic);
|
||||
Services.obs.addObserver(observer, removedTopic);
|
||||
|
||||
var categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
|
||||
categoryManager.addCategoryEntry(testCategory, testEntry, testValue, false, true);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
/* global registerAppManifest */
|
||||
|
||||
|
@ -19,9 +20,7 @@ const kConsoleListener = {
|
|||
};
|
||||
|
||||
function run_test() {
|
||||
let cs = Components.classes["@mozilla.org/consoleservice;1"].
|
||||
getService(Ci.nsIConsoleService);
|
||||
cs.registerListener(kConsoleListener);
|
||||
Services.console.registerListener(kConsoleListener);
|
||||
|
||||
let manifest = do_get_file("components/bug656331.manifest");
|
||||
registerAppManifest(manifest);
|
||||
|
@ -29,10 +28,9 @@ function run_test() {
|
|||
do_check_false("{f18fb09b-28b4-4435-bc5b-8027f18df743}" in Components.classesByID);
|
||||
|
||||
do_test_pending();
|
||||
Components.classes["@mozilla.org/thread-manager;1"].
|
||||
getService(Ci.nsIThreadManager).dispatchToMainThread(function() {
|
||||
cs.unregisterListener(kConsoleListener);
|
||||
do_check_true(gFound);
|
||||
do_test_finished();
|
||||
});
|
||||
Services.tm.dispatchToMainThread(function() {
|
||||
Services.console.unregisterListener(kConsoleListener);
|
||||
do_check_true(gFound);
|
||||
do_test_finished();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
* 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/. */
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function run_test() {
|
||||
// Generate a leaf name that is 255 characters long.
|
||||
var longLeafName = new Array(256).join("T");
|
||||
|
||||
// Generate the path for a file located in a directory with a long name.
|
||||
var tempFile = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
|
||||
var tempFile = Services.dirsvc.get("TmpD", Ci.nsIFile);
|
||||
tempFile.append(longLeafName);
|
||||
tempFile.append("test.txt");
|
||||
|
||||
|
|
|
@ -6,14 +6,15 @@
|
|||
|
||||
var LocalFile = CC("@mozilla.org/file/local;1", "nsIFile", "initWithPath");
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function run_test() {
|
||||
test_normalized_vs_non_normalized();
|
||||
}
|
||||
|
||||
function test_normalized_vs_non_normalized() {
|
||||
// get a directory that exists on all platforms
|
||||
var dirProvider = Components.classes["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
|
||||
var tmp1 = dirProvider.get("TmpD", Ci.nsIFile);
|
||||
var tmp1 = Services.dirsvc.get("TmpD", Ci.nsIFile);
|
||||
var exists = tmp1.exists();
|
||||
do_check_true(exists);
|
||||
if (!exists)
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
* 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/. */
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function run_test() {
|
||||
// Create the base directory.
|
||||
let base = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("TmpD", Ci.nsIFile);
|
||||
let base = Services.dirsvc.get("TmpD", Ci.nsIFile);
|
||||
base.append("renameTesting");
|
||||
if (base.exists()) {
|
||||
base.remove(true);
|
||||
|
|
|
@ -2,10 +2,11 @@ const NS_OS_TEMP_DIR = "TmpD";
|
|||
|
||||
const CWD = do_get_cwd();
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var hiddenUnixFile;
|
||||
function createUNIXHiddenFile() {
|
||||
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
|
||||
var tmpDir = dirSvc.get(NS_OS_TEMP_DIR, Ci.nsIFile);
|
||||
var tmpDir = Services.dirsvc.get(NS_OS_TEMP_DIR, Ci.nsIFile);
|
||||
hiddenUnixFile = tmpDir.clone();
|
||||
hiddenUnixFile.append(".foo");
|
||||
// we don't care if this already exists because we don't care
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const CWD = do_get_cwd();
|
||||
function checkOS(os) {
|
||||
const nsILocalFile_ = "nsILocalFile" + os;
|
||||
|
@ -10,8 +12,7 @@ const isWin = checkOS("Win");
|
|||
function run_test() {
|
||||
var envVar = isWin ? "USERPROFILE" : "HOME";
|
||||
|
||||
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
|
||||
var homeDir = dirSvc.get("Home", Ci.nsIFile);
|
||||
var homeDir = Services.dirsvc.get("Home", Ci.nsIFile);
|
||||
|
||||
var env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
|
||||
var expected = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
|
||||
|
|
|
@ -125,6 +125,8 @@ var testdata = [
|
|||
testdata.push( { filename: "data/iniparser16-utf8BOM.ini",
|
||||
reference: testdata[15].reference } );
|
||||
|
||||
// Intentional test for appInfo that can't be preloaded.
|
||||
// eslint-disable-next-line mozilla/use-services
|
||||
let os = Cc["@mozilla.org/xre/app-info;1"]
|
||||
.getService(Ci.nsIXULRuntime).OS;
|
||||
if ("WINNT" === os) {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// Versions to test listed in ascending order, none can be equal
|
||||
var comparisons = [
|
||||
"0.9",
|
||||
|
@ -29,12 +31,9 @@ var equality = [
|
|||
];
|
||||
|
||||
function run_test() {
|
||||
var vc = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
|
||||
.getService(Components.interfaces.nsIVersionComparator);
|
||||
|
||||
for (var i = 0; i < comparisons.length; i++) {
|
||||
for (var j = 0; j < comparisons.length; j++) {
|
||||
var result = vc.compare(comparisons[i], comparisons[j]);
|
||||
var result = Services.vc.compare(comparisons[i], comparisons[j]);
|
||||
if (i == j) {
|
||||
if (result != 0)
|
||||
do_throw(comparisons[i] + " should be the same as itself");
|
||||
|
@ -49,7 +48,7 @@ function run_test() {
|
|||
|
||||
for (i = 0; i < equality.length; i++) {
|
||||
for (j = 0; j < equality.length; j++) {
|
||||
if (vc.compare(equality[i], equality[j]) != 0)
|
||||
if (Services.vc.compare(equality[i], equality[j]) != 0)
|
||||
do_throw(equality[i] + " should equal " + equality[j]);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче